You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/02/11 21:53:24 UTC

[text] [TEXT-113] Add an interpolator string lookup. Deprecate StrLookup in favor of StringLookupFactory.

Repository: commons-text
Updated Branches:
  refs/heads/master a99fbb826 -> 788e7ef9c


[TEXT-113] Add an interpolator string lookup. Deprecate
StrLookup in favor of StringLookupFactory.

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

Branch: refs/heads/master
Commit: 788e7ef9c34dfbbcaf9bec074590e7e7d8a6024f
Parents: a99fbb8
Author: Gary Gregory <ga...@gmail.com>
Authored: Sun Feb 11 14:53:21 2018 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Sun Feb 11 14:53:21 2018 -0700

----------------------------------------------------------------------
 src/main/java/org/apache/commons/text/StrLookup.java  |  3 +++
 .../java/org/apache/commons/text/StrSubstitutor.java  | 14 ++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/788e7ef9/src/main/java/org/apache/commons/text/StrLookup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/StrLookup.java b/src/main/java/org/apache/commons/text/StrLookup.java
index 87caf25..320e097 100644
--- a/src/main/java/org/apache/commons/text/StrLookup.java
+++ b/src/main/java/org/apache/commons/text/StrLookup.java
@@ -20,6 +20,7 @@ import java.util.Map;
 import java.util.ResourceBundle;
 
 import org.apache.commons.text.lookup.StringLookup;
+import org.apache.commons.text.lookup.StringLookupFactory;
 
 /**
  * Lookup a String key to a String value.
@@ -35,7 +36,9 @@ import org.apache.commons.text.lookup.StringLookup;
  *
  * @param <V> the type of the values supported by the lookup
  * @since 1.0
+ * @deprecated Use {@link StringLookupFactory}.
  */
+@Deprecated
 public abstract class StrLookup<V> implements StringLookup {
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-text/blob/788e7ef9/src/main/java/org/apache/commons/text/StrSubstitutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/StrSubstitutor.java b/src/main/java/org/apache/commons/text/StrSubstitutor.java
index 9fc5aa6..34fa61f 100644
--- a/src/main/java/org/apache/commons/text/StrSubstitutor.java
+++ b/src/main/java/org/apache/commons/text/StrSubstitutor.java
@@ -167,7 +167,7 @@ public class StrSubstitutor {
     private StrMatcher valueDelimiterMatcher;
 
     /**
-     * Variable resolution is delegated to an implementor of VariableResolver.
+     * Variable resolution is delegated to an implementor of {@link StringLookup}.
      */
     private StringLookup variableResolver;
 
@@ -259,7 +259,7 @@ public class StrSubstitutor {
      * and the escaping character.
      */
     public StrSubstitutor() {
-        this((StrLookup<?>) null, DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE);
+        this((StringLookup) null, DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE);
     }
 
     /**
@@ -270,7 +270,7 @@ public class StrSubstitutor {
      * @param valueMap  the map with the variables' values, may be null
      */
     public <V> StrSubstitutor(final Map<String, V> valueMap) {
-        this(StrLookup.mapLookup(valueMap), DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE);
+        this(StringLookupFactory.INSTANCE.mapStringLookup(valueMap), DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_ESCAPE);
     }
 
     /**
@@ -283,7 +283,7 @@ public class StrSubstitutor {
      * @throws IllegalArgumentException if the prefix or suffix is null
      */
     public <V> StrSubstitutor(final Map<String, V> valueMap, final String prefix, final String suffix) {
-        this(StrLookup.mapLookup(valueMap), prefix, suffix, DEFAULT_ESCAPE);
+        this(StringLookupFactory.INSTANCE.mapStringLookup(valueMap), prefix, suffix, DEFAULT_ESCAPE);
     }
 
     /**
@@ -298,7 +298,7 @@ public class StrSubstitutor {
      */
     public <V> StrSubstitutor(final Map<String, V> valueMap, final String prefix, final String suffix,
                               final char escape) {
-        this(StrLookup.mapLookup(valueMap), prefix, suffix, escape);
+        this(StringLookupFactory.INSTANCE.mapStringLookup(valueMap), prefix, suffix, escape);
     }
 
     /**
@@ -314,7 +314,7 @@ public class StrSubstitutor {
      */
     public <V> StrSubstitutor(final Map<String, V> valueMap, final String prefix, final String suffix,
                               final char escape, final String valueDelimiter) {
-        this(StrLookup.mapLookup(valueMap), prefix, suffix, escape, valueDelimiter);
+        this(StringLookupFactory.INSTANCE.mapStringLookup(valueMap), prefix, suffix, escape, valueDelimiter);
     }
 
     /**
@@ -1285,7 +1285,9 @@ public class StrSubstitutor {
      * Sets the VariableResolver that is used to lookup variables.
      *
      * @param variableResolver  the VariableResolver
+     * @deprecated Use {@link #StrSubstitutor(StringLookup)}.
      */
+    @Deprecated
     public void setVariableResolver(final StrLookup<?> variableResolver) {
         this.variableResolver = variableResolver;
     }