Package eu.bandm.tools.format
Class BoundVariable
java.lang.Object
eu.bandm.tools.format.Format
eu.bandm.tools.format.Variable
eu.bandm.tools.format.BoundVariable
- All Implemented Interfaces:
Formattable,Serializable,Cloneable
Variable identified by an index number, resolved by un-named arguments
by counting their positions.
- See Also:
-
Field Summary
Fields inherited from class eu.bandm.tools.format.Variable
DEFAULT_PREFIXFields inherited from class eu.bandm.tools.format.Format
comma, DEFAULT_WIDTH, dot, empty, indent, INDENT_NOT_SET, LENGTH_PREFIX, space -
Constructor Summary
ConstructorsConstructorDescriptionBoundVariable(int index) Sets the numeric identifier.BoundVariable(String prefix, int index) Sets the numeric identifier.BoundVariable(String prefix, int index, int indent) Sets the numeric name and the indentation value. -
Method Summary
Methods inherited from class eu.bandm.tools.format.Variable
bottom, debugPrefix, doprint, getName, getPrefix, indentMethods inherited from class eu.bandm.tools.format.Format
annotated, append, append, apply, apply, apply, apply, applyPartial, applyTo, applyTo, beneath, beneath, beside, beside, block, block, checkValidIndent, comment, comment, comment, comment, format, getIndent, ground, indentIsSet, isAlwaysMultiline, isSpace, line, line, literal, markup, markupLeft, markupRight, maxOfMins, maxWidth, minWidth, of, printFormat, printFormat, printNonFormat, prior, prior, properties, server, showLn, space, subst, subst, subst, tabular, tabular, toObjString, toString, toString, variable, variable
-
Constructor Details
-
BoundVariable
public BoundVariable(int index) Sets the numeric identifier. The prefix for parsing and display deraults toVariable.DEFAULT_PREFIX.- Parameters:
index- the numeric identifier of this variable.
-
BoundVariable
Sets the numeric identifier.- Parameters:
prefix- used for parsing and display, must not be empty.index- the numeric identifier of this variable.- Throws:
IllegalArgumentException- if prefix is empty.
-
BoundVariable
Sets the numeric name and the indentation value. Indentation must be equal toFormat.INDENT_NOT_SET.- Parameters:
prefix- used for parsing and display, must not be empty.index- the numeric identifier of this variable.indent- must be equal toFormat.INDENT_NOT_SET.- Throws:
IllegalArgumentException- if indent in not equal toFormat.INDENT_NOT_SET.IllegalArgumentException- if prefix is empty.IllegalArgumentException- if index is negative- See Also:
-
-
Method Details
-
getIndex
public int getIndex()Return the position of the argument to be replaced by this variable.- Returns:
- the position of the argument to be replaced by this variable.
-
eval
Return the Format value bound to positionindexof this variable in the given context. If the index is higher than the defined range of arguemnts: ifpartial==truethe index is adjusted by subtracting the number of arguments in the context. Otherwise an exception is thrown by returningVariable.bottom().- Overrides:
evalin classFormat- Parameters:
c- defines the replacement for variables by name and number.partial- decides when a Variable not defined in the context is found: if true the Variable stays aunaltered; if false an IllegalArgumentException is thrown.- Returns:
- a format with all or some variables replaced
-