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
AValueMacroExpressionis 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.SeeValueMacroExpression.OffsetLengthSubstringExpansionProcessor.process(String, ParameterResolver, int)for substring expansion details and example usages.- Since:
 - Coherence 12.2.1
 - Author:
 - jf 2015.05.18
 - See Also:
 - Serialized Form
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classValueMacroExpression.DefaultDelimiterExpansionProcessorProcess macro parameter default delimiter expansion.protected static classValueMacroExpression.MacroExpansionProcessorA Macro Expansion Processor for a macro not containing any registered delimiters.protected static classValueMacroExpression.OffsetLengthSubstringExpansionProcessorProcess:offsetand:lengthsubstring expansion.protected static classValueMacroExpression.SpaceDefaultDelimiterExpansionProcessorValueMacroExpression.SpaceDefaultDelimiterExpansionProcessorperforms DefaultDelimiter expansion processing and disambiguates: -for offset and length from space for default delimiter. 
- 
Field Summary
Fields Modifier and Type Field Description static intMAX_MACRO_EXPANSIONSAvoid recursive macro expansions that never return.static StringPARAMETER_PREFIXPrefix indicating the start of a property macro.static CharacterPARAMETER_SUFFIXSuffix indicating the close of a property macro.static StringSUBSTRING_OFFSET_LENGTH_EXPANSIONDelimiter introducing substring expansion of optional :offset and/or :length in a macro parameter. 
- 
Constructor Summary
Constructors Constructor Description ValueMacroExpression()Default constructor needed for serialization.ValueMacroExpression(String value)Construct aValueMacroExpression. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsMacro()Check 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.Stringevaluate(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.voidreadExternal(DataInput in)Restore 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.StringtoString()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 Detail
- 
MAX_MACRO_EXPANSIONS
public static int MAX_MACRO_EXPANSIONS
Avoid recursive macro expansions that never return. No need for more than 20 macro expansions on one value. 
- 
PARAMETER_PREFIX
public static final String PARAMETER_PREFIX
Prefix indicating the start of a property macro.- See Also:
 - Constant Field Values
 
 
- 
PARAMETER_SUFFIX
public static final Character PARAMETER_SUFFIX
Suffix indicating the close of a property macro. 
- 
SUBSTRING_OFFSET_LENGTH_EXPANSION
public static final String SUBSTRING_OFFSET_LENGTH_EXPANSION
Delimiter introducing substring expansion of optional :offset and/or :length in a macro parameter.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
ValueMacroExpression
public ValueMacroExpression()
Default constructor needed for serialization. 
- 
ValueMacroExpression
public ValueMacroExpression(String value)
Construct aValueMacroExpression.- Parameters:
 value- the value that potentially contains a macro expression.
 
 - 
 
- 
Method Detail
- 
evaluate
public String evaluate(ParameterResolver resolver)
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
protected String substitute(String sValue, ParameterResolver resolver, int cDepth)
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
public static boolean containsMacro(String sValue)
Check if string contains a macro.- Parameters:
 sValue- string potentially containing a macro- Returns:
 - true iff the string value contains a macro
 
 
- 
containsRegisteredDelimiter
protected static boolean containsRegisteredDelimiter(String sMacro)
Return true ifsMacrocontains aregistered delimiter.- Parameters:
 sMacro- macro parameter- Returns:
 - true if 
sMacrostring contains a registered delimiter 
 
- 
readExternal
public void readExternal(DataInput in) throws IOException
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 occursNotActiveException- if the object is not in its initial state, and therefore cannot be deserialized into
 
- 
writeExternal
public void writeExternal(DataOutput out) throws IOException
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
public void readExternal(PofReader reader) throws IOException
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
public void writeExternal(PofWriter writer) throws IOException
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
 
 - 
 
 -