public abstract class ParameterizedMacro extends MacroExpander
The general syntax of a parameterized macro is:
${macroname:param1=value;param2=value;...}
Each supported parameter is represented by an instance of Parameter
.
Implementations of this class should return a collection of supported
parameters in the getSupportedParameters()
method.
An implementation of ParameterizedMacro has access to the values
of all parameters in the MacroExpander.expand(Context)
method via the protected
getValue( Parameter )
method.
Constructor and Description |
---|
ParameterizedMacro() |
Modifier and Type | Method and Description |
---|---|
Parameter |
findParameter(java.lang.String name)
Find a parameter from its name.
|
abstract java.util.Collection<Parameter> |
getSupportedParameters()
Gets the parameters supported by this macro.
|
protected java.lang.String |
getValue(Parameter parameter)
Gets the value of a parameter.
|
void |
setValue(Parameter parameter,
java.lang.String value)
Sets the value of a parameter.
|
java.lang.String |
toMacroString()
Gets the text of this macro exactly as it appears
in an unexpanded string.
|
expand, getIcon, getLongLabel, getMacro, getSampleExpansion, getShortLabel, getToolTipText, isAvailableForType, isAvailableForType, isDirectoryMacro, toString
public final void setValue(Parameter parameter, java.lang.String value)
parameter
- one of the parameters supported by this macro.value
- the value of the specified parameter.protected final java.lang.String getValue(Parameter parameter)
parameter
- the parameter.public java.lang.String toMacroString()
This implementation returns a full string, including all parameter values.
toMacroString
in class MacroExpander
public Parameter findParameter(java.lang.String name)
This implementation iterates each Parameter in getSupportedParameters()
until it finds a matching parameter. Subclasses may wish to override this
for performance reasons.
name
- the name of a parameter.public abstract java.util.Collection<Parameter> getSupportedParameters()