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

pack-priv final Class ScriptStringLookup

extends AbstractStringLookup
Class Inheritance
Imports
java.util.Objects, javax.script.ScriptEngine, .ScriptEngineManager, org.apache.commons.text.StringSubstitutor

Executes the script with the given engine name.

Execute the script with the engine name in the format "EngineName:Script".

For example: "javascript:3 + 4".

Using a StringSubstitutor:

StringSubstitutor.createInterpolator().replace("${script:javascript:3 + 4}"));

Public access is through StringLookupFactory.

Since
1.5
See Also
StringLookupFactory

Field Summary

Modifier and TypeField and Description
pack-priv static final ScriptStringLookup
INSTANCE

Defines the singleton for this class.

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

Constructor Summary

AccessConstructor and Description
private
ScriptStringLookup()

No need to build instances for now.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The value returned by the execution.
lookup
(final String
the engine:script to execute, may be null.
key
)

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

Execute the script with the engine name in the format "EngineName:Script".

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

Field Detail

INSTANCEback to summary
pack-priv static final ScriptStringLookup INSTANCE

Defines the singleton for this class.

Constructor Detail

ScriptStringLookupback to summary
private ScriptStringLookup()

No need to build instances for now.

Method Detail

lookupback to summary
public String lookup(final String key)

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

Execute the script with the engine name in the format "EngineName:Script". Extra colons will be ignored.

For example: "javascript:3 + 4".

Parameters
key:String

the engine:script to execute, may be null.

Returns:String

The value returned by the execution.

Annotations
@Override