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
class InterpolatorStringLookup extends AbstractStringLookup
Proxies otherStringLookups using a keys within ${} markers using the format "${StringLookup:Key}".Uses the
default lookups.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static AbstractStringLookupINSTANCEDefines the singleton for this class.-
Fields inherited from class org.apache.commons.text.lookup.AbstractStringLookup
SPLIT_CH, SPLIT_STR
-
-
Constructor Summary
Constructors Constructor Description InterpolatorStringLookup()Creates 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,StringLookup>getStringLookupMap()Gets the lookup map.Stringlookup(String var)Resolves the specified variable.(package private) static StringtoKey(String key)StringtoString()-
Methods inherited from class org.apache.commons.text.lookup.AbstractStringLookup
substringAfter, substringAfter, substringAfterLast, toLookupKey, toLookupKey
-
-
-
-
Field Detail
-
INSTANCE
static final AbstractStringLookup INSTANCE
Defines the singleton for this class.- Since:
- 1.6
-
-
Constructor Detail
-
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
InterpolatorStringLookup(Map<String,V> defaultMap)
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 Detail
-
getStringLookupMap
public Map<String,StringLookup> getStringLookupMap()
Gets the lookup map.- Returns:
- The lookup map.
-
lookup
public String lookup(String var)
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
-
-