Package org.apache.commons.text.lookup
Class InterpolatorStringLookup
java.lang.Object
org.apache.commons.text.lookup.AbstractStringLookup
org.apache.commons.text.lookup.InterpolatorStringLookup
- All Implemented Interfaces:
StringLookup
Proxies other
StringLookup
s using a keys within ${} markers using the format "${StringLookup:Key}".
Uses the default lookups
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringLookup
The default string lookup.(package private) static final AbstractStringLookup
Defines the singleton for this class.private static final char
Constant for the prefix separator.private final Map<String,
StringLookup> The map of String lookups keyed by prefix.Fields inherited from class org.apache.commons.text.lookup.AbstractStringLookup
SPLIT_CH, SPLIT_STR
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance using only lookups that work without initial properties and are stateless.InterpolatorStringLookup
(Map<String, StringLookup> stringLookupMap, StringLookup defaultStringLookup, boolean addDefaultLookups) Creates a fully customized instance.InterpolatorStringLookup
(Map<String, V> defaultMap) Creates an instance using only lookups that work without initial properties and are stateless.InterpolatorStringLookup
(StringLookup defaultStringLookup) Creates an instance with the given lookup. -
Method Summary
Methods inherited from class org.apache.commons.text.lookup.AbstractStringLookup
substringAfter, substringAfter, substringAfterLast, toLookupKey, toLookupKey
-
Field Details
-
INSTANCE
Defines the singleton for this class.- Since:
- 1.6
-
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()Creates 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) Creates 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
Creates 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) Creates an instance with the given lookup.- Parameters:
defaultStringLookup
- the default lookup.
-
-
Method Details
-
toKey
-
getStringLookupMap
Gets the lookup map.- Returns:
- The lookup map.
-
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:
var
- 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
-