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.nodeFilterwith 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,trueif the previous levels are writing the last node.private final booleanWhether 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 voidformat(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.Nodenext(Iterator<? extends TreeTable.Node> it) Returns the next filtered element from the given iterator, ornullif none.protected final StringInvoked byPropertyFormatfor 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, freeTextMethods 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.nodeFilterwith 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,trueif 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 byPropertyFormatwhen needed.- Returns:
- the locale, or
nullif not explicitly defined.
-
toString
Invoked byPropertyFormatfor 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.columnFormatfield, then that format should have been used byPropertyFormat.appendValue(Object)code in order to produce a more uniform formatting.- Overrides:
toStringin 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, ornullif none. The filter applied by this method combinesTreeTableFormat.getNodeFilter()with the filter returned byTreeFormatCustomization.filter().
-