Package eu.bandm.tools.format
Class Subst
java.lang.Object
eu.bandm.tools.format.Format
eu.bandm.tools.format.Subst
- All Implemented Interfaces:
Formattable,Serializable,Cloneable
Allows to store a context as a scope in a format tree.
Such a
Context maps variable names and numbers to format values.
The evaluation of this scope happens in course of the recursive
descend of the Format.eval(eu.bandm.tools.format.Context, boolean) method.- See Also:
-
Field Summary
Fields inherited from class eu.bandm.tools.format.Format
comma, DEFAULT_WIDTH, dot, empty, indent, INDENT_NOT_SET, LENGTH_PREFIX, space -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondebugPrefix(int n) Deliver the concatenation of the text contents, limited by the given number of characters, approximately.protected voidOver-ridden by all sub-classes of Format, for performing the print operations.Return the result of replacing all variables with the bindings in the given context.final FormatgetBody()Return the format for which this scope is defined.final ContextReturn the definitions which are valid in this scope.final booleanReturn whether the context defined here is intentionally partial.indent(int i) Returns a clone ofthiswith the new value ofFormat.indent.Methods 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
-
Subst
Constructor which sets most object fields explicitly, exceptindentwhich is unset.- Parameters:
body- the format subtree for which this instance sets a scope.context- the variable definitions valid in this scopepartial- whether variables are allowed which are not defined in the local context, but in some higher scope.
-
Subst
Constructor which sets all object fields explicitly.- Parameters:
body- the format subtree for which this instance sets a scope.context- the variable definitions valid in this scopepartial- whether variables are allowed which are not defined in the local context, but in some higher scope.indent- the indentation value for printing of the subtree.- Throws:
IllegalArgumentException- if ident value not valid, seeFormat.checkValidIndent(int)
-
-
Method Details
-
getBody
Return the format for which this scope is defined.- Returns:
- the format for which this scope is defined.
-
getContext
Return the definitions which are valid in this scope.- Returns:
- the definitions which are valid in this scope.
-
getPartial
public final boolean getPartial()Return whether the context defined here is intentionally partial.- Returns:
- whether the context defined here is intentionally partial.
-
indent
Description copied from class:FormatReturns a clone ofthiswith the new value ofFormat.indent. -
doprint
Description copied from class:FormatOver-ridden by all sub-classes of Format, for performing the print operations. -
eval
Return the result of replacing all variables with the bindings in the given context.. First the local context is evaluated against the current context, and then the execution descends with that evaluation result.- 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
- See Also:
-
debugPrefix
Description copied from class:FormatDeliver the concatenation of the text contents, limited by the given number of characters, approximately. Useful for debugging purpose.- Specified by:
debugPrefixin classFormat- Parameters:
n- the maximal number of characters which can be generated per tree node.- Returns:
- the concatenated, unformatted text contents.
-