Top Description Fields Constructors Methods
org.apache.commons.text.lookup

pack-priv final Class InterpolatorStringLookup

extends AbstractStringLookup
Class Inheritance
Imports
java.util.Collections, .Map, .Map.Entry, java.util.stream.Collectors

Proxies other StringLookups using a keys within ${} markers using the format "${StringLookup:Key}".

Uses the default lookups.

Public access is through StringLookupFactory.

See Also
StringLookupFactory

Field Summary

Modifier and TypeField and Description
private final StringLookup
defaultStringLookup

The default string lookup.

pack-priv static final AbstractStringLookup
INSTANCE

Defines the singleton for this class.

private static final char
PREFIX_SEPARATOR

Constant for the prefix separator.

private final Map<String, StringLookup>
stringLookupMap

The map of String lookups keyed by prefix.

Inherited from org.apache.commons.text.lookup.AbstractStringLookup:
SPLIT_CHSPLIT_STR

Constructor Summary

AccessConstructor and Description
pack-priv
InterpolatorStringLookup()

Constructs an instance using only lookups that work without initial properties and are stateless.

pack-priv
InterpolatorStringLookup(final Map<String, StringLookup>
the map of string lookups.
stringLookupMap
,
final StringLookup
the default string lookup.
defaultStringLookup
,
final boolean
whether the default lookups should be used.
addDefaultLookups
)

Constructs a fully customized instance.

pack-priv <
the map's value type.
V
>
InterpolatorStringLookup(final Map<String, V>
the default map for string lookups.
defaultMap
)

Constructs an instance using only lookups that work without initial properties and are stateless.

pack-priv
InterpolatorStringLookup(final StringLookup
the default lookup.
defaultStringLookup
)

Constructs an instance with the given lookup.

Method Summary

Modifier and TypeMethod and Description
public Map<String, StringLookup>

Returns:

The lookup map.
getStringLookupMap
()

Gets the lookup map.

public String

Returns:

The value of this variable or null if it cannot be resolved.
lookup
(String
the name of the variable whose value is to be looked up.
key
)

Implements org.apache.commons.text.lookup.StringLookup.lookup.

Resolves the specified variable.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.apache.commons.text.lookup.AbstractStringLookup:
substringAftersubstringAftersubstringAfterLasttoLookupKeytoLookupKey

Field Detail

defaultStringLookupback to summary
private final StringLookup defaultStringLookup

The default string lookup.

INSTANCEback to summary
pack-priv static final AbstractStringLookup INSTANCE

Defines the singleton for this class.

Since
1.6
PREFIX_SEPARATORback to summary
private static final char PREFIX_SEPARATOR

Constant for the prefix separator.

stringLookupMapback to summary
private final Map<String, StringLookup> stringLookupMap

The map of String lookups keyed by prefix.

Constructor Detail

InterpolatorStringLookupback to summary
pack-priv InterpolatorStringLookup()

Constructs an instance using only lookups that work without initial properties and are stateless.

Uses the default lookups.

InterpolatorStringLookupback to summary
pack-priv InterpolatorStringLookup(final Map<String, StringLookup> stringLookupMap, final StringLookup defaultStringLookup, final boolean addDefaultLookups)

Constructs a fully customized instance.

Parameters
stringLookupMap:Map<String, StringLookup>

the map of string lookups.

defaultStringLookup:StringLookup

the default string lookup.

addDefaultLookups:boolean

whether the default lookups should be used.

InterpolatorStringLookupback to summary
pack-priv <V> InterpolatorStringLookup(final Map<String, V> defaultMap)

Constructs an instance using only lookups that work without initial properties and are stateless.

Uses the default lookups.

Parameters
<V>
the map's value type.
defaultMap:Map<String, V>

the default map for string lookups.

InterpolatorStringLookupback to summary
pack-priv InterpolatorStringLookup(final StringLookup defaultStringLookup)

Constructs an instance with the given lookup.

Parameters
defaultStringLookup:StringLookup

the default lookup.

Method Detail

getStringLookupMapback to summary
public Map<String, StringLookup> getStringLookupMap()

Gets the lookup map.

Returns:Map<String, StringLookup>

The lookup map.

lookupback to summary
public String lookup(String key)

Implements org.apache.commons.text.lookup.StringLookup.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:String

the name of the variable whose value is to be looked up.

Returns:String

The value of this variable or null if it cannot be resolved.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override