The "classic" look up is mapStringLookup(Map).
The methods for variable interpolation (A.K.A. variable substitution) are:
interpolatorStringLookup().interpolatorStringLookup(Map).interpolatorStringLookup(StringLookup).interpolatorStringLookup(Map, StringLookup, boolean).
Unless explicitly requested otherwise, a set of default lookups are included for convenience with these variable interpolation methods. These defaults are
listed in the table below. However, the exact lookups included can be configured through the use of the org.apache.commons.text.lookup.StringLookupFactory.defaultStringLookups system
property. If present, this system property will be parsed as a comma-separated list of lookup names, with the names being those defined by the
DefaultStringLookup enum. For example, setting this system property to "BASE64_ENCODER,ENVIRONMENT" will only include the
BASE64_ENCODER and ENVIRONMENT lookups. Setting the property to the empty
string will cause no defaults to be configured. Note that not all lookups defined here and in DefaultStringLookup are included by default.
Specifically, lookups that can execute code (e.g., SCRIPT) and those that can result in contact with remote servers (e.g.,
URL and DNS) are not included by default. The current set of default lookups can be accessed
directly with addDefaultStringLookups(Map).
| Key | Interface | Factory Method | Since |
|---|---|---|---|
| base64Decoder | StringLookup |
base64DecoderStringLookup() |
1.6 |
| base64Encoder | StringLookup |
base64EncoderStringLookup() |
1.6 |
| const | StringLookup |
constantStringLookup() |
1.5 |
| date | StringLookup |
dateStringLookup() |
1.5 |
| env | StringLookup |
environmentVariableStringLookup() |
1.3 |
| file | StringLookup |
fileStringLookup(Path. |
1.5 |
| java | StringLookup |
javaPlatformStringLookup() |
1.5 |
| localhost | StringLookup |
localHostStringLookup() |
1.3 |
| loobackAddress | StringLookup |
loopbackAddressStringLookup() |
1.13.0 |
| properties | StringLookup |
propertiesStringLookup(Path. |
1.5 |
| resourceBundle | StringLookup |
resourceBundleStringLookup() |
1.6 |
| sys | StringLookup |
systemPropertyStringLookup() |
1.3 |
| urlDecoder | StringLookup |
urlDecoderStringLookup() |
1.5 |
| urlEncoder | StringLookup |
urlEncoderStringLookup() |
1.5 |
| xml | StringLookup |
xmlStringLookup(Map, Path. |
1.5 |
| xmlDecoder | StringLookup |
xmlDecoderStringLookup() |
1.11.0 |
| xmlEncoder | StringLookup |
xmlEncoderStringLookup() |
1.11.0 |
| Key | Interface | Factory Method | Since |
|---|---|---|---|
| dns | StringLookup |
dnsStringLookup() |
1.8 |
| url | StringLookup |
urlStringLookup() |
1.5 |
| script | StringLookup |
scriptStringLookup() |
1.5 |
This class also provides functional lookups used as building blocks for other lookups.
| Interface | Factory Method | Since |
|---|---|---|
BiStringLookup |
biFunctionStringLookup(BiFunction) |
1.9 |
StringLookup |
functionStringLookup(Function) |
1.9 |
| Modifier and Type | Class and Description |
|---|---|
| public static class | StringLookupFactory.
Builds instance of |
| pack-priv static class | StringLookupFactory.
Internal class used to construct the default |
| Modifier and Type | Field and Description |
|---|---|
| public static final String | DEFAULT_STRING_LOOKUPS_PROPERTY
Name of the system property used to determine the string lookups added by the |
| private final Path[] | fences
Fences. |
| public static final StringLookupFactory | INSTANCE
Defines the singleton for this class. |
| pack-priv static final FunctionStringLookup | INSTANCE_BASE64_DECODER
Decodes Base64 Strings. |
| pack-priv static final FunctionStringLookup | INSTANCE_BASE64_ENCODER
Encodes Base64 Strings. |
| pack-priv static final FunctionStringLookup | INSTANCE_ENVIRONMENT_VARIABLES
Looks up keys from environment variables. |
| pack-priv static final FunctionStringLookup | INSTANCE_NULL
Defines the FunctionStringLookup singleton that always returns null. |
| pack-priv static final FunctionStringLookup | INSTANCE_SYSTEM_PROPERTIES
Defines the FunctionStringLookup singleton for looking up system properties. |
| public static final String | KEY_BASE64_DECODER
Default lookup key for interpolation base64Decoder. |
| public static final String | KEY_BASE64_ENCODER
Default lookup key for interpolation base64Encoder. |
| public static final String | KEY_CONST
Default lookup key for interpolation const. |
| public static final String | KEY_DATE
Default lookup key for interpolation date. |
| public static final String | KEY_DNS
Default lookup key for interpolation dns. |
| public static final String | KEY_ENV
Default lookup key for interpolation env. |
| public static final String | KEY_FILE
Default lookup key for interpolation file. |
| public static final String | KEY_JAVA
Default lookup key for interpolation java. |
| public static final String | KEY_LOCALHOST
Default lookup key for interpolation localhost. |
| public static final String | KEY_LOOPBACK_ADDRESS
Default lookup key for interpolation loobackAddress. |
| public static final String | KEY_PROPERTIES
Default lookup key for interpolation properties. |
| public static final String | KEY_RESOURCE_BUNDLE
Default lookup key for interpolation resourceBundle. |
| public static final String | KEY_SCRIPT
Default lookup key for interpolation script. |
| public static final String | KEY_SYS
Default lookup key for interpolation sys. |
| public static final String | KEY_URL
Default lookup key for interpolation url. |
| public static final String | KEY_URL_DECODER
Default lookup key for interpolation urlDecoder. |
| public static final String | KEY_URL_ENCODER
Default lookup key for interpolation urlEncoder. |
| public static final String | KEY_XML
Default lookup key for interpolation xml. |
| public static final String | KEY_XML_DECODER
Default lookup key for interpolation xmlDecoder. |
| public static final String | KEY_XML_ENCODER
Default lookup key for interpolation xmlEncoder. |
| Access | Constructor and Description |
|---|---|
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | addDefaultStringLookups(final Map<String, StringLookup>
the map of string lookups to edit. stringLookupMap)Adds the default string lookups for this class to |
| public StringLookup | Returns: The Base64DecoderStringLookup singleton instance.Returns the Base64DecoderStringLookup singleton instance to decode Base64 strings. |
| public StringLookup | Returns: The Base64EncoderStringLookup singleton instance.Returns the Base64EncoderStringLookup singleton instance to encode strings to Base64. |
| public StringLookup | Returns: The Base64DecoderStringLookup singleton instance.
Deprecated
Use
base64DecoderStringLookup().
Returns the Base64DecoderStringLookup singleton instance to decode Base64 strings. |
| public < the function return type. R, the function's second parameter type. U> BiStringLookup | Returns: a new MapStringLookup.the function. biFunction)Returns a new function-based lookup where the request for a lookup is answered by applying the function with a lookup key. |
| public static StringLookupFactory. | |
| public static void | |
| public StringLookup | Returns: The ConstantStringLookup singleton instance.Returns the ConstantStringLookup singleton instance to look up the value of a fully-qualified static final value. |
| public StringLookup | Returns: The DateStringLookup singleton instance.Returns the DateStringLookup singleton instance to format the current date with the format given in the key in a format compatible with
|
| public StringLookup | Returns: the DnsStringLookup singleton instance.Returns the DnsStringLookup singleton instance where the lookup key is one of:
|
| public StringLookup | Returns: The EnvironmentVariableStringLookup singleton instance.Returns the EnvironmentVariableStringLookup singleton instance where the lookup key is an environment variable name. |
| public StringLookup | |
| public StringLookup | Returns: a file StringLookup instance.The fences guarding Path resolution. fences)Returns a fenced file StringLookup instance. |
| public < the function return type. R> StringLookup | Returns: a new MapStringLookup.the function. function)Returns a new function-based lookup where the request for a lookup is answered by applying the function with a lookup key. |
| public StringLookup | Returns: the defaultInterpolatorStringLookup.Returns a |
| public StringLookup | Returns: a new InterpolatorStringLookup.the map of string lookups. stringLookupMap, final StringLookup the default string lookup; this lookup is used when a variable cannot be resolved using the lookups in defaultStringLookup, final boolean stringLookupMap
or the configured default lookups (if enabled)whether to use default lookups as described above. addDefaultLookups)Returns a new InterpolatorStringLookup. |
| public < the value type the default string lookup's map. V> StringLookup | Returns: a new InterpolatorStringLookup.the default map for string lookups. map)Returns a new InterpolatorStringLookup using the given key-value pairs and the configured |
| public StringLookup | Returns: a new InterpolatorStringLookup.the default string lookup. defaultStringLookup)Returns a new InterpolatorStringLookup using the given lookup and the configured |
| public StringLookup | Returns: The JavaPlatformStringLookup singleton instance.Returns the JavaPlatformStringLookup singleton instance. |
| public StringLookup | Returns: The InetAddressStringLookup singleton instance.Returns the InetAddressStringLookup instance where the lookup key for
|
| public StringLookup | Returns: The InetAddressStringLookup singleton instance.Returns the InetAddressStringLookup instance where the lookup key for
|
| public < the map value type. V> StringLookup | Returns: a new MapStringLookup.the map. map)Returns a new map-based lookup where the request for a lookup is answered with the value for that key. |
| public StringLookup | Returns: The NullStringLookup singleton instance.Returns the NullStringLookup singleton instance which always returns null. |
| public StringLookup | Returns: a Properties StringLookup instance.Returns a Properties StringLookup instance. |
| public StringLookup | Returns: a Properties StringLookup instance.The fences guarding Path resolution. fences)Returns a fenced Properties StringLookup instance. |
| public StringLookup | Returns: The ResourceBundleStringLookup singleton instance.Returns the ResourceBundleStringLookup singleton instance. |
| public StringLookup | Returns: a ResourceBundleStringLookup instance for the given bundle name.Only lookup in this bundle. bundleName)Returns a ResourceBundleStringLookup instance for the given bundle name. |
| public StringLookup | Returns: The ScriptStringLookup singleton instance.Returns the ScriptStringLookup singleton instance. |
| public StringLookup | Returns: The SystemPropertyStringLookup singleton instance.Returns the SystemPropertyStringLookup singleton instance where the lookup key is a system property name. |
| pack-priv static String | |
| pack-priv static < the class of the map keys K, the class of the map values V> Map | |
| public StringLookup | Returns: The UrlStringLookup singleton instance.Returns the UrlDecoderStringLookup singleton instance. |
| public StringLookup | Returns: The UrlStringLookup singleton instance.Returns the UrlDecoderStringLookup singleton instance. |
| public StringLookup | Returns: The UrlStringLookup singleton instance.Returns the UrlStringLookup singleton instance. |
| public StringLookup | Returns: The XmlDecoderStringLookup singleton instance.Returns the XmlDecoderStringLookup singleton instance. |
| public StringLookup | Returns: The XmlEncoderStringLookup singleton instance.Returns the XmlEncoderStringLookup singleton instance. |
| public StringLookup | |
| public StringLookup | Returns: An XML StringLookup instance.DocumentBuilderFactory and XPathFactory features to set. factoryFeatures)Returns an XML StringLookup instance. |
| public StringLookup | Returns: An XML StringLookup instance.DocumentBuilderFactory and XPathFactory features to set. factoryFeatures, final Path... The fences guarding Path resolution. fences)Returns a fenced XML StringLookup instance. |