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
Nested ClassesModifier and TypeClassDescriptionprotected static classProcess macro parameter default delimiter expansion.protected static classA Macro Expansion Processor for a macro not containing any registered delimiters.protected static classProcess:offsetand:lengthsubstring expansion.protected static classValueMacroExpression.SpaceDefaultDelimiterExpansionProcessorperforms DefaultDelimiter expansion processing and disambiguates: -for offset and length from space for default delimiter. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intAvoid recursive macro expansions that never return.static final StringPrefix indicating the start of a property macro.static final CharacterSuffix indicating the close of a property macro.static final StringDelimiter introducing substring expansion of optional :offset and/or :length in a macro parameter. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor needed for serialization.ValueMacroExpression(String value) Construct aValueMacroExpression. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if this contains a macro.static booleancontainsMacro(String sValue) Check if string contains a macro.protected static booleancontainsRegisteredDelimiter(String sMacro) Return true ifsMacrocontains aregistered delimiter.evaluate(ParameterResolver resolver) Evaluates theExpressionto produce a value of type T.protected StringprocessRegisteredMacroExpansions(String sMacro, ParameterResolver resolver, int cDepth) Process macro expansion ofsMacrobyregistered macro-expansion processors.voidreadExternal(PofReader reader) Restore the contents of a user type instance by reading its state using the specified PofReader object.voidRestore the contents of this object by loading the object's state from the passed DataInput object.protected Stringsubstitute(String sValue, ParameterResolver resolver, int cDepth) Return a string value containing no outstanding macro parameters.toString()voidwriteExternal(PofWriter writer) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.voidwriteExternal(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 theExpressionto produce a value of type T.- Specified by:
evaluatein interfaceExpression<String>- Parameters:
resolver- theParameterResolverfor 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 resolvercDepth- 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 ofsMacrobyregistered macro-expansion processors.- Parameters:
sMacro- macro parameterresolver- resolve macro parameter withinsMacrocDepth- 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 ifsMacrocontains aregistered delimiter.- Parameters:
sMacro- macro parameter- Returns:
- true if
sMacrostring contains a registered delimiter
-
readExternal
Restore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternalin 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:
writeExternalin 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:
readExternalin 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:
writeExternalin interfacePortableObject- Parameters:
writer- the PofWriter to which to write the object's state- Throws:
IOException- if an I/O error occurs
-
toString
-