Repository: commons-text
Updated Branches:
  refs/heads/master 6c23a516a -> d9cda575a


[TEXT-147] Add a Base64 encoder string lookup. Better Javadoc.

Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/d9cda575
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/d9cda575
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/d9cda575

Branch: refs/heads/master
Commit: d9cda575a21d2258a6750936d82d19ca3e12f4eb
Parents: 6c23a51
Author: Gary Gregory <ggreg...@rocketsoftware.com>
Authored: Fri Oct 5 09:45:24 2018 -0600
Committer: Gary Gregory <ggreg...@rocketsoftware.com>
Committed: Fri Oct 5 09:45:24 2018 -0600

----------------------------------------------------------------------
 src/changes/changes.xml                         |   1 +
 .../text/lookup/Base64DecoderStringLookup.java  |  47 +++
 .../text/lookup/Base64EncoderStringLookup.java  |  47 +++
 .../commons/text/lookup/Base64StringLookup.java |  47 ---
 .../text/lookup/InterpolatorStringLookup.java   |   6 +-
 .../text/lookup/StringLookupFactory.java        | 415 ++++++++++++-------
 .../lookup/Base64DecoderStringLookupTest.java   |  33 ++
 .../lookup/Base64EncoderStringLookupTest.java   |  33 ++
 .../text/lookup/Base64StringLookupTest.java     |  30 --
 .../text/lookup/StringLookupFactoryTest.java    |   3 +-
 10 files changed, 439 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d0067ef..006aa8a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -49,6 +49,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="TEXT-144" type="update" dev="ggregory">Add the resource 
string bundle string lookup to the default set of lookups</action>
     <action issue="TEXT-145" type="update" dev="ggregory">Add 
StringLookupFactory methods for the URL encoder and decoder string 
lookups</action>
     <action issue="TEXT-146" type="update" 
dev="ggregory">org.apache.commons.text.lookup.StringLookupFactory.interpolatorStringLookup()
 should reuse a singleton instance</action>
+    <action issue="TEXT-147" type="update" dev="ggregory">Add a Base64 encoder 
string lookup.</action>
   </release>
 
   <release version="1.5" date="2018-09-29" description="Release 1.5">

http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/main/java/org/apache/commons/text/lookup/Base64DecoderStringLookup.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/text/lookup/Base64DecoderStringLookup.java 
b/src/main/java/org/apache/commons/text/lookup/Base64DecoderStringLookup.java
new file mode 100644
index 0000000..f388ad8
--- /dev/null
+++ 
b/src/main/java/org/apache/commons/text/lookup/Base64DecoderStringLookup.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.commons.text.lookup;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+/**
+ * Decodes Base64 Strings.
+ *
+ * @since 1.5
+ */
+final class Base64DecoderStringLookup extends AbstractStringLookup {
+
+    /**
+     * Defines the singleton for this class.
+     */
+    static final Base64DecoderStringLookup INSTANCE = new 
Base64DecoderStringLookup();
+
+    /**
+     * No need to build instances for now.
+     */
+    private Base64DecoderStringLookup() {
+        // empty
+    }
+
+    @Override
+    public String lookup(final String key) {
+        return new String(Base64.getDecoder().decode(key), 
StandardCharsets.ISO_8859_1);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/main/java/org/apache/commons/text/lookup/Base64EncoderStringLookup.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/text/lookup/Base64EncoderStringLookup.java 
b/src/main/java/org/apache/commons/text/lookup/Base64EncoderStringLookup.java
new file mode 100644
index 0000000..6d4f582
--- /dev/null
+++ 
b/src/main/java/org/apache/commons/text/lookup/Base64EncoderStringLookup.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.commons.text.lookup;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+/**
+ * Encodes Base64 Strings.
+ *
+ * @since 1.6
+ */
+final class Base64EncoderStringLookup extends AbstractStringLookup {
+
+    /**
+     * Defines the singleton for this class.
+     */
+    static final Base64EncoderStringLookup INSTANCE = new 
Base64EncoderStringLookup();
+
+    /**
+     * No need to build instances for now.
+     */
+    private Base64EncoderStringLookup() {
+        // empty
+    }
+
+    @Override
+    public String lookup(final String key) {
+        return new 
String(Base64.getEncoder().encodeToString(key.getBytes(StandardCharsets.ISO_8859_1)));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/main/java/org/apache/commons/text/lookup/Base64StringLookup.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/text/lookup/Base64StringLookup.java 
b/src/main/java/org/apache/commons/text/lookup/Base64StringLookup.java
deleted file mode 100644
index e1607a4..0000000
--- a/src/main/java/org/apache/commons/text/lookup/Base64StringLookup.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.commons.text.lookup;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Base64;
-
-/**
- * Decodes Base64 Strings.
- *
- * @since 1.5
- */
-final class Base64StringLookup extends AbstractStringLookup {
-
-    /**
-     * Defines the singleton for this class.
-     */
-    static final Base64StringLookup INSTANCE = new Base64StringLookup();
-
-    /**
-     * No need to build instances for now.
-     */
-    private Base64StringLookup() {
-        // empty
-    }
-
-    @Override
-    public String lookup(final String key) {
-        return new String(Base64.getDecoder().decode(key), 
StandardCharsets.ISO_8859_1);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java 
b/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
index 6cd09d2..6ae422f 100644
--- a/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
@@ -37,7 +37,7 @@ import java.util.Map.Entry;
  * <li>"script" for the {@link ScriptStringLookup} since 1.5.</li>
  * <li>"file" for the {@link FileStringLookup} since 1.5.</li>
  * <li>"url" for the {@link UrlStringLookup} since 1.5.</li>
- * <li>"base64" for the {@link Base64StringLookup} since 1.5.</li>
+ * <li>"base64" for the {@link Base64DecoderStringLookup} since 1.5.</li>
  * <li>"urlEncode" for the {@link UrlEncoderStringLookup} since 1.5.</li>
  * <li>"urlDecode" for the {@link UrlDecoderStringLookup} since 1.5.</li>
  * </ul>
@@ -76,7 +76,7 @@ class InterpolatorStringLookup extends AbstractStringLookup {
      * <li>"script" for the {@link ScriptStringLookup} since 1.5.</li>
      * <li>"file" for the {@link FileStringLookup} since 1.5.</li>
      * <li>"url" for the {@link UrlStringLookup} since 1.5.</li>
-     * <li>"base64" for the {@link Base64StringLookup} since 1.5.</li>
+     * <li>"base64" for the {@link Base64DecoderStringLookup} since 1.5.</li>
      * <li>"urlEncode" for the {@link UrlEncoderStringLookup} since 1.5.</li>
      * <li>"urlDecode" for the {@link UrlDecoderStringLookup} since 1.5.</li>
      * <li>"const" for the {@link ConstantStringLookup} since 1.5.</li>
@@ -102,7 +102,7 @@ class InterpolatorStringLookup extends AbstractStringLookup 
{
      * <li>"script" for the {@link ScriptStringLookup} since 1.5.</li>
      * <li>"file" for the {@link FileStringLookup} since 1.5.</li>
      * <li>"url" for the {@link UrlStringLookup} since 1.5.</li>
-     * <li>"base64" for the {@link Base64StringLookup} since 1.5.</li>
+     * <li>"base64" for the {@link Base64DecoderStringLookup} since 1.5.</li>
      * <li>"urlEncode" for the {@link UrlEncoderStringLookup} since 1.5.</li>
      * <li>"urlDecode" for the {@link UrlDecoderStringLookup} since 1.5.</li>
      * <li>"const" for the {@link ConstantStringLookup} since 1.5.</li>

http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java 
b/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java
index 3b75103..c3d4dab 100644
--- a/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java
+++ b/src/main/java/org/apache/commons/text/lookup/StringLookupFactory.java
@@ -21,24 +21,114 @@ import java.util.Map;
 
 /**
  * Provides access to lookups defined in this package.
- * <ul>
- * <li>"base64" for the {@link Base64StringLookup} since 1.5.</li>
- * <li>"const" for the {@link ConstantStringLookup} since 1.5.</li>
- * <li>"date" for the {@link DateStringLookup}.</li>
- * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li>
- * <li>"file" for the {@link FileStringLookup} since 1.5.</li>
- * <li>"java" for the {@link JavaPlatformStringLookup}.</li>
- * <li>"localhost" for the {@link LocalHostStringLookup}, see {@link 
#localHostStringLookup()} for key names; since
- * 1.3.</li>
- * <li>"properties" for the {@link PropertiesStringLookup} since 1.5.</li>
- * <li>"resourceBundle" for the {@link ResourceBundleStringLookup} since 
1.6.</li>
- * <li>"script" for the {@link ScriptStringLookup} since 1.5.</li>
- * <li>"sys" for the {@link SystemPropertyStringLookup}.</li>
- * <li>"url" for the {@link UrlStringLookup} since 1.5.</li>
- * <li>"urlDecode" for the {@link UrlDecoderStringLookup} since 1.5.</li>
- * <li>"urlEncode" for the {@link UrlEncoderStringLookup} since 1.5.</li>
- * <li>"xml" for the {@link XmlStringLookup} since 1.5.</li>
- * </ul>
+ * <p>
+ * The default lookups are:
+ * </p>
+ * <table>
+ * <caption>Default String Lookups</caption>
+ * <tr>
+ * <th>Key</th>
+ * <th>Implementation</th>
+ * <th>Factory Method</th>
+ * <th>Since</th>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_BASE64_DECODER}</td>
+ * <td>{@link Base64DecoderStringLookup}</td>
+ * <td>{@link #base64DecoderStringLookup()}</td>
+ * <td>1.6</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_BASE64_ENCODER}</td>
+ * <td>{@link Base64EncoderStringLookup}</td>
+ * <td>{@link #base64EncoderStringLookup()}</td>
+ * <td>1.6</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_CONST}</td>
+ * <td>{@link ConstantStringLookup}</td>
+ * <td>{@link #constantStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_DATE}</td>
+ * <td>{@link DateStringLookup}</td>
+ * <td>{@link #dateStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_ENV}</td>
+ * <td>{@link EnvironmentVariableStringLookup}</td>
+ * <td>{@link #environmentVariableStringLookup()}</td>
+ * <td>1.3</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_FILE}</td>
+ * <td>{@link FileStringLookup}</td>
+ * <td>{@link #fileStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_JAVA}</td>
+ * <td>{@link JavaPlatformStringLookup}</td>
+ * <td>{@link #javaPlatformStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_LOCALHOST}</td>
+ * <td>{@link LocalHostStringLookup}</td>
+ * <td>{@link #localHostStringLookup()}</td>
+ * <td>1.3</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_PROPERTIES}</td>
+ * <td>{@link PropertiesStringLookup}</td>
+ * <td>{@link #propertiesStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_RESOURCE_BUNDLE}</td>
+ * <td>{@link ResourceBundleStringLookup}</td>
+ * <td>{@link #resourceBundleStringLookup()}</td>
+ * <td>1.6</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_SCRIPT}</td>
+ * <td>{@link ScriptStringLookup}</td>
+ * <td>{@link #scriptStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_SYS}</td>
+ * <td>{@link SystemPropertyStringLookup}</td>
+ * <td>{@link #systemPropertyStringLookup()}</td>
+ * <td>1.3</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_URL}</td>
+ * <td>{@link UrlStringLookup}</td>
+ * <td>{@link #urlStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_URL_DECODER}</td>
+ * <td>{@link UrlDecoderStringLookup}</td>
+ * <td>{@link #urlDecoderStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_URL_ENCODER}</td>
+ * <td>{@link UrlEncoderStringLookup}</td>
+ * <td>{@link #urlEncoderStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * <tr>
+ * <td>{@value #KEY_XML}</td>
+ * <td>{@link XmlStringLookup}</td>
+ * <td>{@link #xmlStringLookup()}</td>
+ * <td>1.5</td>
+ * </tr>
+ * </table>
  *
  * @since 1.3
  */
@@ -50,6 +140,118 @@ public final class StringLookupFactory {
     public static final StringLookupFactory INSTANCE = new 
StringLookupFactory();
 
     /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_BASE64_DECODER = "base64Decoder";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_BASE64_ENCODER = "base64Encoder";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_CONST = "const";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_DATE = "date";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_ENV = "env";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_FILE = "file";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_JAVA = "java";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_LOCALHOST = "localhost";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_PROPERTIES = "properties";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_RESOURCE_BUNDLE = "resourceBundle";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_SCRIPT = "script";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_SYS = "sys";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_URL = "url";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_URL_DECODER = "urlDecoder";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_URL_ENCODER = "urlEncoder";
+
+    /**
+     * Default lookup key for interpolation.
+     * 
+     * @since 1.6
+     */
+    public static final String KEY_XML = "xml";
+
+    /**
      * Clears any static resources.
      *
      * @since 1.5
@@ -66,25 +268,7 @@ public final class StringLookupFactory {
     }
 
     /**
-     * The following lookups are installed:
-     * <ul>
-     * <li>"base64" for the {@link Base64StringLookup} since 1.5.</li>
-     * <li>"const" for the {@link ConstantStringLookup} since 1.5.</li>
-     * <li>"date" for the {@link DateStringLookup}.</li>
-     * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li>
-     * <li>"file" for the {@link FileStringLookup} since 1.5.</li>
-     * <li>"java" for the {@link JavaPlatformStringLookup}.</li>
-     * <li>"localhost" for the {@link LocalHostStringLookup}, see {@link 
#localHostStringLookup()} for key names; since
-     * 1.3.</li>
-     * <li>"properties" for the {@link PropertiesStringLookup} since 1.5.</li>
-     * <li>"resourceBundle" for the {@link ResourceBundleStringLookup} since 
1.6.</li>
-     * <li>"script" for the {@link ScriptStringLookup} since 1.5.</li>
-     * <li>"sys" for the {@link SystemPropertyStringLookup}.</li>
-     * <li>"url" for the {@link UrlStringLookup} since 1.5.</li>
-     * <li>"urlDecode" for the {@link UrlDecoderStringLookup} since 1.5.</li>
-     * <li>"urlEncode" for the {@link UrlEncoderStringLookup} since 1.5.</li>
-     * <li>"xml" for the {@link XmlStringLookup} since 1.5.</li>
-     * </ul>
+     * Adds the {@link StringLookupFactory default lookups}.
      *
      * @param stringLookupMap
      *            the map of string lookups.
@@ -92,32 +276,60 @@ public final class StringLookupFactory {
      */
     public void addDefaultStringLookups(final Map<String, StringLookup> 
stringLookupMap) {
         if (stringLookupMap != null) {
-            stringLookupMap.put("sys", SystemPropertyStringLookup.INSTANCE);
-            stringLookupMap.put("env", 
EnvironmentVariableStringLookup.INSTANCE);
-            stringLookupMap.put("java", JavaPlatformStringLookup.INSTANCE);
-            stringLookupMap.put("date", DateStringLookup.INSTANCE);
-            stringLookupMap.put("localhost", LocalHostStringLookup.INSTANCE);
-            stringLookupMap.put("xml", XmlStringLookup.INSTANCE);
-            stringLookupMap.put("properties", PropertiesStringLookup.INSTANCE);
-            stringLookupMap.put("resourceBundle", 
ResourceBundleStringLookup.INSTANCE);
-            stringLookupMap.put("script", ScriptStringLookup.INSTANCE);
-            stringLookupMap.put("file", FileStringLookup.INSTANCE);
-            stringLookupMap.put("url", UrlStringLookup.INSTANCE);
-            stringLookupMap.put("base64", Base64StringLookup.INSTANCE);
-            stringLookupMap.put("urlEncode", UrlEncoderStringLookup.INSTANCE);
-            stringLookupMap.put("urlDecode", UrlDecoderStringLookup.INSTANCE);
-            stringLookupMap.put("const", ConstantStringLookup.INSTANCE);
+            // "base64" is deprecated in favor of KEY_BASE64_DECODER.
+            stringLookupMap.put("base64", Base64DecoderStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_BASE64_DECODER, 
Base64DecoderStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_BASE64_ENCODER, 
Base64EncoderStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_CONST, ConstantStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_DATE, DateStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_ENV, 
EnvironmentVariableStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_FILE, FileStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_JAVA, JavaPlatformStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_LOCALHOST, LocalHostStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_PROPERTIES, 
PropertiesStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_RESOURCE_BUNDLE, 
ResourceBundleStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_SCRIPT, ScriptStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_SYS, SystemPropertyStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_URL, UrlStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_URL_DECODER, 
UrlDecoderStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_URL_ENCODER, 
UrlEncoderStringLookup.INSTANCE);
+            stringLookupMap.put(KEY_XML, XmlStringLookup.INSTANCE);
         }
     }
 
     /**
-     * Returns the DateStringLookup singleton instance to format the current 
date with the format given in the key in a
-     * format compatible with {@link java.text.SimpleDateFormat}.
+     * Returns the Base64StringLookup singleton instance to format the current 
date with the format given in the key in
+     * a format compatible with {@link java.text.SimpleDateFormat}.
+     *
+     * @return the DateStringLookup singleton instance.
+     * @since 1.5
+     */
+    public StringLookup base64DecoderStringLookup() {
+        return Base64DecoderStringLookup.INSTANCE;
+    }
+
+    /**
+     * Returns the Base64StringLookup singleton instance to format the current 
date with the format given in the key in
+     * a format compatible with {@link java.text.SimpleDateFormat}.
+     *
+     * @return the DateStringLookup singleton instance.
+     * @since 1.6
+     */
+    public StringLookup base64EncoderStringLookup() {
+        return Base64EncoderStringLookup.INSTANCE;
+    }
+
+    /**
+     * Returns the Base64StringLookup singleton instance to format the current 
date with the format given in the key in
+     * a format compatible with {@link java.text.SimpleDateFormat}.
      *
      * @return the DateStringLookup singleton instance.
+     * @since 1.5
+     * @deprecated Use {@link #base64DecoderStringLookup()}.
      */
+    @Deprecated
     public StringLookup base64StringLookup() {
-        return Base64StringLookup.INSTANCE;
+        return Base64DecoderStringLookup.INSTANCE;
     }
 
     /**
@@ -167,28 +379,7 @@ public final class StringLookupFactory {
     }
 
     /**
-     * Returns a new InterpolatorStringLookup.
-     * <p>
-     * The following lookups are used by default:
-     * </p>
-     * <ul>
-     * <li>"base64" for the {@link Base64StringLookup} since 1.5.</li>
-     * <li>"const" for the {@link ConstantStringLookup} since 1.5.</li>
-     * <li>"date" for the {@link DateStringLookup}.</li>
-     * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li>
-     * <li>"file" for the {@link FileStringLookup} since 1.5.</li>
-     * <li>"java" for the {@link JavaPlatformStringLookup}.</li>
-     * <li>"localhost" for the {@link LocalHostStringLookup}, see {@link 
#localHostStringLookup()} for key names; since
-     * 1.3.</li>
-     * <li>"properties" for the {@link PropertiesStringLookup} since 1.5.</li>
-     * <li>"resourceBundle" for the {@link ResourceBundleStringLookup} since 
1.6.</li>
-     * <li>"script" for the {@link ScriptStringLookup} since 1.5.</li>
-     * <li>"sys" for the {@link SystemPropertyStringLookup}.</li>
-     * <li>"url" for the {@link UrlStringLookup} since 1.5.</li>
-     * <li>"urlDecode" for the {@link UrlDecoderStringLookup} since 1.5.</li>
-     * <li>"urlEncode" for the {@link UrlEncoderStringLookup} since 1.5.</li>
-     * <li>"xml" for the {@link XmlStringLookup} since 1.5.</li>
-     * </ul>
+     * Returns a new InterpolatorStringLookup using the {@link 
StringLookupFactory default lookups}.
      *
      * @return a new InterpolatorStringLookup.
      */
@@ -197,29 +388,11 @@ public final class StringLookupFactory {
     }
 
     /**
-     * Returns a new InterpolatorStringLookup.
+     * Returns a new InterpolatorStringLookup using the {@link 
StringLookupFactory default lookups}.
      * <p>
      * If {@code addDefaultLookups} is true, the following lookups are used in 
addition to the ones provided in
      * {@code stringLookupMap}:
      * </p>
-     * <ul>
-     * <li>"base64" for the {@link Base64StringLookup} since 1.5.</li>
-     * <li>"const" for the {@link ConstantStringLookup} since 1.5.</li>
-     * <li>"date" for the {@link DateStringLookup}.</li>
-     * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li>
-     * <li>"file" for the {@link FileStringLookup} since 1.5.</li>
-     * <li>"java" for the {@link JavaPlatformStringLookup}.</li>
-     * <li>"localhost" for the {@link LocalHostStringLookup}, see {@link 
#localHostStringLookup()} for key names; since
-     * 1.3.</li>
-     * <li>"properties" for the {@link PropertiesStringLookup} since 1.5.</li>
-     * <li>"resourceBundle" for the {@link ResourceBundleStringLookup} since 
1.6.</li>
-     * <li>"script" for the {@link ScriptStringLookup} since 1.5.</li>
-     * <li>"sys" for the {@link SystemPropertyStringLookup}.</li>
-     * <li>"url" for the {@link UrlStringLookup} since 1.5.</li>
-     * <li>"urlDecode" for the {@link UrlDecoderStringLookup} since 1.5.</li>
-     * <li>"urlEncode" for the {@link UrlEncoderStringLookup} since 1.5.</li>
-     * <li>"xml" for the {@link XmlStringLookup} since 1.5.</li>
-     * </ul>
      *
      * @param stringLookupMap
      *            the map of string lookups.
@@ -236,28 +409,7 @@ public final class StringLookupFactory {
     }
 
     /**
-     * Returns a new InterpolatorStringLookup.
-     * <p>
-     * The following lookups are used by default:
-     * </p>
-     * <ul>
-     * <li>"base64" for the {@link Base64StringLookup} since 1.5.</li>
-     * <li>"const" for the {@link ConstantStringLookup} since 1.5.</li>
-     * <li>"date" for the {@link DateStringLookup}.</li>
-     * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li>
-     * <li>"file" for the {@link FileStringLookup} since 1.5.</li>
-     * <li>"java" for the {@link JavaPlatformStringLookup}.</li>
-     * <li>"localhost" for the {@link LocalHostStringLookup}, see {@link 
#localHostStringLookup()} for key names; since
-     * 1.3.</li>
-     * <li>"properties" for the {@link PropertiesStringLookup} since 1.5.</li>
-     * <li>"resourceBundle" for the {@link ResourceBundleStringLookup} since 
1.6.</li>
-     * <li>"script" for the {@link ScriptStringLookup} since 1.5.</li>
-     * <li>"sys" for the {@link SystemPropertyStringLookup}.</li>
-     * <li>"url" for the {@link UrlStringLookup} since 1.5.</li>
-     * <li>"urlDecode" for the {@link UrlDecoderStringLookup} since 1.5.</li>
-     * <li>"urlEncode" for the {@link UrlEncoderStringLookup} since 1.5.</li>
-     * <li>"xml" for the {@link XmlStringLookup} since 1.5.</li>
-     * </ul>
+     * Returns a new InterpolatorStringLookup using the {@link 
StringLookupFactory default lookups}.
      *
      * @param <V>
      *            the value type the default string lookup's map.
@@ -270,28 +422,7 @@ public final class StringLookupFactory {
     }
 
     /**
-     * Returns a new InterpolatorStringLookup.
-     * <p>
-     * The following lookups are used by default:
-     * </p>
-     * <ul>
-     * <li>"base64" for the {@link Base64StringLookup} since 1.5.</li>
-     * <li>"const" for the {@link ConstantStringLookup} since 1.5.</li>
-     * <li>"date" for the {@link DateStringLookup}.</li>
-     * <li>"env" for the {@link EnvironmentVariableStringLookup}.</li>
-     * <li>"file" for the {@link FileStringLookup} since 1.5.</li>
-     * <li>"java" for the {@link JavaPlatformStringLookup}.</li>
-     * <li>"localhost" for the {@link LocalHostStringLookup}, see {@link 
#localHostStringLookup()} for key names; since
-     * 1.3.</li>
-     * <li>"properties" for the {@link PropertiesStringLookup} since 1.5.</li>
-     * <li>"resourceBundle" for the {@link ResourceBundleStringLookup} since 
1.6.</li>
-     * <li>"script" for the {@link ScriptStringLookup} since 1.5.</li>
-     * <li>"sys" for the {@link SystemPropertyStringLookup}.</li>
-     * <li>"url" for the {@link UrlStringLookup} since 1.5.</li>
-     * <li>"urlDecode" for the {@link UrlDecoderStringLookup} since 1.5.</li>
-     * <li>"urlEncode" for the {@link UrlEncoderStringLookup} since 1.5.</li>
-     * <li>"xml" for the {@link XmlStringLookup} since 1.5.</li>
-     * </ul>
+     * Returns a new InterpolatorStringLookup using the {@link 
StringLookupFactory default lookups}.
      *
      * @param defaultStringLookup
      *            the default string lookup.
@@ -435,7 +566,7 @@ public final class StringLookupFactory {
     /**
      * Returns the UrlDecoderStringLookup singleton instance.
      * <p>
-     *  Decodes URL Strings using the UTF-8 encoding.
+     * Decodes URL Strings using the UTF-8 encoding.
      * </p>
      * <p>
      * For example: "Hello%20World%21" becomes "Hello World!".
@@ -451,7 +582,7 @@ public final class StringLookupFactory {
     /**
      * Returns the UrlDecoderStringLookup singleton instance.
      * <p>
-     *  Decodes URL Strings using the UTF-8 encoding.
+     * Decodes URL Strings using the UTF-8 encoding.
      * </p>
      * <p>
      * For example: "Hello World!" becomes "Hello+World%21".

http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/test/java/org/apache/commons/text/lookup/Base64DecoderStringLookupTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/text/lookup/Base64DecoderStringLookupTest.java
 
b/src/test/java/org/apache/commons/text/lookup/Base64DecoderStringLookupTest.java
new file mode 100644
index 0000000..aa6abbd
--- /dev/null
+++ 
b/src/test/java/org/apache/commons/text/lookup/Base64DecoderStringLookupTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.commons.text.lookup;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link Base64DecoderStringLookup}.
+ */
+public class Base64DecoderStringLookupTest {
+
+    @Test
+    public void test() {
+        Assertions.assertEquals("SGVsbG9Xb3JsZCE=", 
Base64DecoderStringLookup.INSTANCE.lookup("HelloWorld!"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/test/java/org/apache/commons/text/lookup/Base64EncoderStringLookupTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/text/lookup/Base64EncoderStringLookupTest.java
 
b/src/test/java/org/apache/commons/text/lookup/Base64EncoderStringLookupTest.java
new file mode 100644
index 0000000..5eb0866
--- /dev/null
+++ 
b/src/test/java/org/apache/commons/text/lookup/Base64EncoderStringLookupTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.commons.text.lookup;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link Base64EncoderStringLookup}.
+ */
+public class Base64EncoderStringLookupTest {
+
+    @Test
+    public void test() {
+        Assertions.assertEquals("HelloWorld!", 
Base64EncoderStringLookup.INSTANCE.lookup("SGVsbG9Xb3JsZCE="));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/test/java/org/apache/commons/text/lookup/Base64StringLookupTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/text/lookup/Base64StringLookupTest.java 
b/src/test/java/org/apache/commons/text/lookup/Base64StringLookupTest.java
deleted file mode 100644
index 19b61db..0000000
--- a/src/test/java/org/apache/commons/text/lookup/Base64StringLookupTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.commons.text.lookup;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class Base64StringLookupTest {
-
-    @Test
-    public void test() {
-        Assertions.assertEquals("HelloWorld!", 
Base64StringLookup.INSTANCE.lookup("SGVsbG9Xb3JsZCE="));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/d9cda575/src/test/java/org/apache/commons/text/lookup/StringLookupFactoryTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/text/lookup/StringLookupFactoryTest.java 
b/src/test/java/org/apache/commons/text/lookup/StringLookupFactoryTest.java
index caa6ee3..11585e7 100644
--- a/src/test/java/org/apache/commons/text/lookup/StringLookupFactoryTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/StringLookupFactoryTest.java
@@ -30,7 +30,8 @@ public class StringLookupFactoryTest {
     @Test
     public void testSingletons() {
         final StringLookupFactory stringLookupFactory = 
StringLookupFactory.INSTANCE;
-        Assertions.assertEquals(Base64StringLookup.INSTANCE, 
stringLookupFactory.base64StringLookup());
+        Assertions.assertEquals(Base64DecoderStringLookup.INSTANCE, 
stringLookupFactory.base64StringLookup());
+        Assertions.assertEquals(Base64EncoderStringLookup.INSTANCE, 
stringLookupFactory.base64StringLookup());
         Assertions.assertEquals(ConstantStringLookup.INSTANCE, 
stringLookupFactory.constantStringLookup());
         Assertions.assertEquals(DateStringLookup.INSTANCE, 
stringLookupFactory.dateStringLookup());
         Assertions.assertEquals(EnvironmentVariableStringLookup.INSTANCE,

Reply via email to