Package org.apache.sis.util.collection
Class TreeTableFormat.Writer
java.lang.Object
org.apache.sis.io.Appender
org.apache.sis.io.LineAppender
org.apache.sis.internal.util.PropertyFormat
org.apache.sis.util.collection.TreeTableFormat.Writer
- All Implemented Interfaces:
Flushable
,Appendable
,Localized
- Enclosing class:
TreeTableFormat
Creates string representation of the node values. Tabulations are replaced by spaces,
and line feeds are replaced by the Pilcrow character. This is necessary in order to
avoid conflict with the characters expected by
TableAppender
.
Instances of TreeTableFormat.Writer
are created temporarily before to begin the formatting
of a node, and discarded when the formatting is finished.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TableColumn<?>[]
The columns to write.private final Predicate
<TreeTable.Node> Combination ofTreeTableFormat.nodeFilter
with other filter that may be specified by the tree table to format.private final Format[]
The format to use for each column.private boolean[]
For each indentation level,true
if the previous levels are writing the last node.private final boolean
Whether to allows multi-lines cells instead of using Pilcrow character.private final Set
<TreeTable.Node> The node that have already been formatted.private final Object[]
The node values to format.Fields inherited from class org.apache.sis.internal.util.PropertyFormat
columnFormat
-
Constructor Summary
ConstructorsConstructorDescriptionWriter
(Appendable out, TreeTable tree, TableColumn<?>[] columns, Set<TreeTable.Node> recursivityGuard) Creates a new instance which will write to the given appendable. -
Method Summary
Modifier and TypeMethodDescription(package private) final void
format
(TreeTable.Node node, int level) Appends the string representation of the given node and all its children.Returns the locale to use for formatting property value.private TreeTable.Node
next
(Iterator<? extends TreeTable.Node> it) Returns the next filtered element from the given iterator, ornull
if none.protected final String
Invoked byPropertyFormat
for formatting a value which has not been recognized as one of the types to be handled in a special way.Methods inherited from class org.apache.sis.internal.util.PropertyFormat
appendValue, freeText
Methods inherited from class org.apache.sis.io.LineAppender
append, append, clear, flush, getLineSeparator, getMaximalLineLength, getTabulationWidth, isTabulationExpanded, onLineBegin, setLineSeparator, setMaximalLineLength, setTabulationExpanded, setTabulationWidth
-
Field Details
-
filter
Combination ofTreeTableFormat.nodeFilter
with other filter that may be specified by the tree table to format. TheTreeTable
-specific filter is specified byTreeFormatCustomization
. -
columns
The columns to write. -
formats
The format to use for each column. -
values
The node values to format. -
isLast
private boolean[] isLastFor each indentation level,true
if the previous levels are writing the last node. This array will growth as needed. -
multiLineCells
private final boolean multiLineCellsWhether to allows multi-lines cells instead of using Pilcrow character. This is currently supported only if the number of columns is less than 2. -
recursivityGuard
The node that have already been formatted. We use this map as a safety against infinite recursivity.
-
-
Constructor Details
-
Writer
Writer(Appendable out, TreeTable tree, TableColumn<?>[] columns, Set<TreeTable.Node> recursivityGuard) Creates a new instance which will write to the given appendable.- Parameters:
out
- where to format the tree.tree
- the tree table to format.columns
- the columns of the tree table to format.recursivityGuard
- an initially empty set.
-
-
Method Details
-
getLocale
Returns the locale to use for formatting property value. This method is invoked byPropertyFormat
when needed.- Returns:
- the locale, or
null
if not explicitly defined.
-
toString
Invoked byPropertyFormat
for formatting a value which has not been recognized as one of the types to be handled in a special way. In particular numbers and dates should be handled here. This method checks for a value-by-value format and should be invoked only in last resort. If a column-wide format was specified by thePropertyFormat.columnFormat
field, then that format should have been used byPropertyFormat.appendValue(Object)
code in order to produce a more uniform formatting.- Overrides:
toString
in classPropertyFormat
- Parameters:
value
- the value to format (nevernull
).- Returns:
- the formatted value.
-
format
Appends the string representation of the given node and all its children. This method invokes itself recursively.- Parameters:
node
- the node to format.level
- indentation level. The first level is 0.- Throws:
IOException
-
next
Returns the next filtered element from the given iterator, ornull
if none. The filter applied by this method combinesTreeTableFormat.getNodeFilter()
with the filter returned byTreeFormatCustomization.filter()
.
-