Class InterpolatorStringLookup
java.lang.Object
org.apache.commons.text.lookup.AbstractStringLookup
org.apache.commons.text.lookup.InterpolatorStringLookup
- All Implemented Interfaces:
Function<String,String>, UnaryOperator<String>, StringLookup
Proxies other
StringLookups using a keys within ${} markers using the format "${StringLookup:Key}".
Uses the default lookups.
Public access is through StringLookupFactory.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringLookupThe default string lookup.(package private) static final AbstractStringLookupDefines the singleton for this class.private static final charConstant for the prefix separator.private final Map<String, StringLookup> The map of String lookups keyed by prefix.Fields inherited from class AbstractStringLookup
SPLIT_CH, SPLIT_STR -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Constructs an instance using only lookups that work without initial properties and are stateless.(package private)InterpolatorStringLookup(Map<String, StringLookup> stringLookupMap, StringLookup defaultStringLookup, boolean addDefaultLookups) Constructs a fully customized instance.(package private)<V>InterpolatorStringLookup(Map<String, V> defaultMap) Constructs an instance using only lookups that work without initial properties and are stateless.(package private)InterpolatorStringLookup(StringLookup defaultStringLookup) Constructs an instance with the given lookup. -
Method Summary
Modifier and TypeMethodDescriptionGets the lookup map.Resolves the specified variable.toString()Methods inherited from class AbstractStringLookup
substringAfter, substringAfter, substringAfterLast, toLookupKey, toLookupKeyMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface StringLookup
apply
-
Field Details
-
INSTANCE
-
PREFIX_SEPARATOR
private static final char PREFIX_SEPARATORConstant for the prefix separator.- See Also:
-
defaultStringLookup
The default string lookup. -
stringLookupMap
The map of String lookups keyed by prefix.
-
-
Constructor Details
-
InterpolatorStringLookup
InterpolatorStringLookup()Constructs an instance using only lookups that work without initial properties and are stateless.Uses the
default lookups. -
InterpolatorStringLookup
InterpolatorStringLookup(Map<String, StringLookup> stringLookupMap, StringLookup defaultStringLookup, boolean addDefaultLookups) Constructs a fully customized instance.- Parameters:
stringLookupMap- the map of string lookups.defaultStringLookup- the default string lookup.addDefaultLookups- whether the default lookups should be used.
-
InterpolatorStringLookup
Constructs an instance using only lookups that work without initial properties and are stateless.Uses the
default lookups.- Type Parameters:
V- the map's value type.- Parameters:
defaultMap- the default map for string lookups.
-
InterpolatorStringLookup
InterpolatorStringLookup(StringLookup defaultStringLookup) Constructs an instance with the given lookup.- Parameters:
defaultStringLookup- the default lookup.
-
-
Method Details
-
getStringLookupMap
-
lookup
Resolves the specified variable. This implementation will try to extract a variable prefix from the given variable name (the first colon (':') is used as prefix separator). It then passes the name of the variable with the prefix stripped to the lookup object registered for this prefix. If no prefix can be found or if the associated lookup object cannot resolve this variable, the default lookup object will be used.- Parameters:
key- the name of the variable whose value is to be looked up.- Returns:
- The value of this variable or null if it cannot be resolved.
-
toString
-