Package com.tangosol.config.expression
Class ValueMacroExpression
java.lang.Object
com.tangosol.config.expression.ValueMacroExpression
- All Implemented Interfaces:
Expression<String>
,ExternalizableLite
,PortableObject
,Serializable
public class ValueMacroExpression
extends Object
implements Expression<String>, ExternalizableLite, PortableObject
A
Note that word referenced below is either a nested macro parameter default or the default value.
ValueMacroExpression
is a string value potentially containing expandable macros.
Resolving the expression performs macro expansion. The macro syntax is ${macro-parameter default-value}. Thus, a value of near-${coherence.client direct} is macro expanded by default to near-direct. If property coherence.client is set to remote, then the value would be expanded to near-remote.
As of Coherence 14.1.2.0.0, the following common shell parameter expansion capabilities have been added.
${macro-parameter ${macro-parameter-default default-value}} Supports nesting of macro parameters to enable the defaulting value to be configured as a macro-parameter.In addition to the default delimiter of a space character, the colon character indicates a modifier for macro expansion.
Note that word referenced below is either a nested macro parameter default or the default value.
${macro-parameter:-word} If macro-parameter is unset or null, the expansion of wordis substituted, otherwise, the value of macro-parameter is substituted. ${macro-parameter:+word} If macro-parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted. ${macro-parameter:offset} ${macro-parameter:offset:length} Note that length and offset are integer values.See
ValueMacroExpression.OffsetLengthSubstringExpansionProcessor.process(String, ParameterResolver, int)
for substring expansion details
and example usages.- Since:
- Coherence 12.2.1
- Author:
- jf 2015.05.18
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Process macro parameter default delimiter expansion.protected static class
A Macro Expansion Processor for a macro not containing any registered delimiters.protected static class
Process:offset
and:length
substring expansion.
protected static class
ValueMacroExpression.SpaceDefaultDelimiterExpansionProcessor
performs DefaultDelimiter expansion processing and disambiguates: -
for offset and length from space for default delimiter. -
Field Summary
Modifier and TypeFieldDescriptionstatic int
Avoid recursive macro expansions that never return.static final String
Prefix indicating the start of a property macro.static final Character
Suffix indicating the close of a property macro.static final String
Delimiter introducing substring expansion of optional :offset and/or :length in a macro parameter. -
Constructor Summary
ConstructorDescriptionDefault constructor needed for serialization.ValueMacroExpression
(String value) Construct aValueMacroExpression
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if this contains a macro.static boolean
containsMacro
(String sValue) Check if string contains a macro.protected static boolean
containsRegisteredDelimiter
(String sMacro) Return true ifsMacro
contains aregistered delimiter
.evaluate
(ParameterResolver resolver) Evaluates theExpression
to produce a value of type T.protected String
processRegisteredMacroExpansions
(String sMacro, ParameterResolver resolver, int cDepth) Process macro expansion ofsMacro
byregistered macro-expansion processors
.void
readExternal
(PofReader reader) Restore the contents of a user type instance by reading its state using the specified PofReader object.void
Restore the contents of this object by loading the object's state from the passed DataInput object.protected String
substitute
(String sValue, ParameterResolver resolver, int cDepth) Return a string value containing no outstanding macro parameters.toString()
void
writeExternal
(PofWriter writer) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.void
writeExternal
(DataOutput out) Save the contents of this object by storing the object's state into the passed DataOutput object.
-
Field Details
-
MAX_MACRO_EXPANSIONS
public static int MAX_MACRO_EXPANSIONSAvoid recursive macro expansions that never return. No need for more than 20 macro expansions on one value. -
PARAMETER_PREFIX
Prefix indicating the start of a property macro.- See Also:
-
PARAMETER_SUFFIX
Suffix indicating the close of a property macro. -
SUBSTRING_OFFSET_LENGTH_EXPANSION
Delimiter introducing substring expansion of optional :offset and/or :length in a macro parameter.- See Also:
-
-
Constructor Details
-
ValueMacroExpression
public ValueMacroExpression()Default constructor needed for serialization. -
ValueMacroExpression
Construct aValueMacroExpression
.- Parameters:
value
- the value that potentially contains a macro expression.
-
-
Method Details
-
evaluate
Evaluates theExpression
to produce a value of type T.- Specified by:
evaluate
in interfaceExpression<String>
- Parameters:
resolver
- theParameterResolver
for resolving any parameters used by theExpression
- Returns:
- The result of evaluating the expression
-
substitute
Return a string value containing no outstanding macro parameters.- Parameters:
sValue
- a value containing 0 or more macro parametersresolver
- amacro parameter resolver
cDepth
- current number of macro parameter resolutions- Returns:
- a string value containing no outstanding macro parameters
-
processRegisteredMacroExpansions
protected String processRegisteredMacroExpansions(String sMacro, ParameterResolver resolver, int cDepth) Process macro expansion ofsMacro
byregistered macro-expansion processors
.- Parameters:
sMacro
- macro parameterresolver
- resolve macro parameter withinsMacro
cDepth
- count of macro parameter expansions- Returns:
- result of macro parameter expansion processing
-
containsMacro
public boolean containsMacro()Check if this contains a macro.- Returns:
- true iff this contains a macro
-
containsMacro
Check if string contains a macro.- Parameters:
sValue
- string potentially containing a macro- Returns:
- true iff the string value contains a macro
-
containsRegisteredDelimiter
Return true ifsMacro
contains aregistered delimiter
.- Parameters:
sMacro
- macro parameter- Returns:
- true if
sMacro
string contains a registered delimiter
-
readExternal
Restore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternal
in interfaceExternalizableLite
- Parameters:
in
- the DataInput stream to read data from in order to restore the state of this object- Throws:
IOException
- if an I/O exception occurs
-
writeExternal
Save the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternal
in interfaceExternalizableLite
- Parameters:
out
- the DataOutput stream to write the state of this object to- Throws:
IOException
- if an I/O exception occurs
-
readExternal
Restore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternal
in interfacePortableObject
- Parameters:
reader
- the PofReader from which to read the object's state- Throws:
IOException
- if an I/O error occurs
-
writeExternal
Save the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternal
in interfacePortableObject
- Parameters:
writer
- the PofWriter to which to write the object's state- Throws:
IOException
- if an I/O error occurs
-
toString
-