Package eu.bandm.tools.format
Class Comment
java.lang.Object
eu.bandm.tools.format.Format
eu.bandm.tools.format.Compound
eu.bandm.tools.format.Comment
- All Implemented Interfaces:
Formattable,Serializable,Cloneable
Arranges all sub-formats decorated as comments.
This format is foreseen for longer and multi-line comments:
All sub-formats are printed as in a "beneath" format.
The space for payload text is smaller than elsewhere,
because every printed line is led in by a selectable prefix.
Additionally a top and a bottom line can be added,
for arrangements as known from the Java api doc format, etc.:
[[
// one sub-format
// the next sub-format
]]
(Shorter comments embedded in a text line must be constructed otherwise.)
This format is special because the line prefices must be inserted
"physically" into the lower level layouts, always
at the start of an output line. Therefore they are handled by the
FormatPrinter directly.
Currently comments cannot be nested.
This is detected not before trying to print them.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringString to lead in all inner lines, and the first line ifprefixis null.String to lead in one additional closing line.Fields inherited from class eu.bandm.tools.format.Format
comma, DEFAULT_WIDTH, dot, empty, indent, INDENT_NOT_SET, LENGTH_PREFIX, space -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedComment(int i, int a, boolean m, boolean g, int ind, String prefix, String linePrefix, String suffix, List<Format> f) The constructor which sets all field values explicitly.protectedA constructor with some field values explicit, some calculated from the subformats.protectedA constructor with some field values explicit, some calculated from the subformats. -
Method Summary
Modifier and TypeMethodDescriptionUnsupported Operation.protected voidOver-ridden by all sub-classes of Format, for performing the print operations.indent(int ind) Returns a clone ofthiswith the new value ofFormat.indent.Creates a new instance of the same class as this instance, or an optimized variant.Methods inherited from class eu.bandm.tools.format.Compound
debugPrefix, eval, getSubsMethods 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
-
Field Details
-
linePrefix
String to lead in all inner lines, and the first line ifprefixis null. -
suffix
String to lead in one additional closing line.
-
-
Constructor Details
-
Comment
protected Comment(@Opt @Opt String prefix, String linePrefix, @Opt @Opt String suffix, List<Format> f) A constructor with some field values explicit, some calculated from the subformats. In contrast to the factory methods, denormalized instances may be constructed.- Parameters:
prefix- the string to lead in the first linelinePrefix- the string to lead in all inner lines, and the first line ifprefixis null.suffix- the string to lead in an additional last line, if not null.f- the commented lines, printed as in an implicit beneath format.
-
Comment
A constructor with some field values explicit, some calculated from the subformats. In contrast to the factory methods, denormalized instances may be constructed.- Parameters:
prefix- the string to lead in the first linelinePrefix- the string to lead in all inner lines, and the first line ifprefixis null.suffix- the string to lead in an additional last line, if not null.f- the commented lines, printed as in an implicit beneath format.- See Also:
-
Comment
protected Comment(int i, int a, boolean m, boolean g, int ind, String prefix, String linePrefix, String suffix, List<Format> f) The constructor which sets all field values explicitly. Consistency of the attributes must be realized by the caller. In contrast to the factory methods, denormalized instances may be constructed.- Parameters:
i- the minimal width of the formata- the maximal width of the formatm- whether the format will print to multiple lines anyhowg- whether the format does not contain any variableind- the indentation value of this formatprefix- the string to lead in the first linelinePrefix- the string to lead in all inner lines, and the first line ifprefixis null.suffix- the string to lead in an additional last line, if not null.f- the commented lines- Throws:
IllegalArgumentException- if ident value not valid, seeFormat.checkValidIndent(int)- See Also:
-
-
Method Details
-
indent
Description copied from class:FormatReturns a clone ofthiswith the new value ofFormat.indent. -
constructor
Unsupported Operation. Comment is a Compound, but it is special as it is not freely compositional. It thus has no corresponding CompoundConstructor.- Specified by:
constructorin classCompound- Returns:
- the reification of the constructor of this instance.
-
mutate
Description copied from class:CompoundCreates a new instance of the same class as this instance, or an optimized variant. which contains as subformats all formats in a modified list. The list is modified arbitrarily in an "imperative" way, i.e. it can be altered or extended or totally cleared.The resulting list is fed into a factory method; therefore optimization applies and the returned type can be the singleton contents or an instance of Empty.
-
doprint
Description copied from class:FormatOver-ridden by all sub-classes of Format, for performing the print operations.
-