facets.util.datatree
Class Nodes
java.lang.Object
facets.util.datatree.Nodes
public final class Nodes
- extends java.lang.Object
Utilities for manipulating and querying trees of TypedNode
s and its subclasses.
Field Summary |
static java.lang.String |
NO_NULL
|
Constructor Summary |
Nodes()
|
Method Summary |
static TypedNode[] |
ancestry(TypedNode node)
|
static void |
appendChild(DataNode node,
TypedNode child)
|
static void |
appendValue(DataNode node,
java.lang.Object value)
|
static TypedNode |
child(TypedNode node,
java.lang.String type)
|
static TypedNode |
child(TypedNode node,
java.lang.String[] types)
|
static TypedNode |
child(TypedNode node,
java.lang.String[] types,
java.lang.String title)
|
static TypedNode |
child(TypedNode node,
java.lang.String type,
java.lang.String title)
|
static TypedNode[] |
children(TypedNode node,
java.lang.String... types)
|
static java.lang.String |
childTypeText(TypedNode node,
java.lang.String type)
|
static void |
decode(DataNode node)
|
static TypedNode[] |
descendants(TypedNode node)
|
static TypedNode[] |
descendantsTyped(TypedNode node,
java.lang.String... types)
|
static TypedNode |
descendantTitled(TypedNode node,
java.lang.String title)
|
static TypedNode |
descendantTyped(TypedNode node,
java.lang.String type)
|
static java.lang.String |
encode(DataNode node,
int breakAt)
|
static java.lang.String |
getSingleString(DataNode node)
|
static ValueNode |
guaranteedChild(DataNode parent,
java.lang.String type,
java.lang.String title)
|
static ValueNode |
guaranteedDescendant(DataNode node,
java.lang.String... typePath)
|
static ValueNode |
guaranteedValueChild(DataNode parent,
java.lang.String type)
|
static boolean |
hasMixedContents(TypedNode node)
|
static boolean |
isKeyPair(java.lang.String text)
|
static java.lang.String |
keySafe(java.lang.String text)
|
static ValueNode |
mergeContents(ValueNode node,
java.lang.Object... mergeContents)
Merges new with existing node contents. |
static TypedNode |
newTestTree(java.lang.String rootType,
int broad,
double shrinkBy)
|
static java.lang.String |
newValuesTitle(DataNode node)
|
static void |
pack(DataNode node)
|
static void |
setChild(DataNode parent,
TypedNode child)
|
static void |
setSingleString(DataNode node,
java.lang.String str)
|
static java.lang.String[] |
splitPair(java.lang.String text)
|
static java.lang.String |
treeInfo(DataNode tree,
boolean chars)
|
static java.lang.String |
treeString(DataNode root)
Returns stringifications of the tree root and its descendants'
type , title and values
in contents order. |
static void |
unpack(DataNode node)
|
static java.lang.String |
valuesAsLine(TypedNode node,
int limit)
|
static java.lang.String |
valuesFirstLine(TypedNode node)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NO_NULL
public static final java.lang.String NO_NULL
- See Also:
- Constant Field Values
Nodes
public Nodes()
encode
public static java.lang.String encode(DataNode node,
int breakAt)
decode
public static void decode(DataNode node)
keySafe
public static java.lang.String keySafe(java.lang.String text)
isKeyPair
public static boolean isKeyPair(java.lang.String text)
splitPair
public static java.lang.String[] splitPair(java.lang.String text)
getSingleString
public static java.lang.String getSingleString(DataNode node)
setSingleString
public static void setSingleString(DataNode node,
java.lang.String str)
treeString
public static java.lang.String treeString(DataNode root)
- Returns stringifications of the tree root and its descendants'
type
, title
and values
in contents order.
childTypeText
public static java.lang.String childTypeText(TypedNode node,
java.lang.String type)
child
public static TypedNode child(TypedNode node,
java.lang.String type)
child
public static TypedNode child(TypedNode node,
java.lang.String type,
java.lang.String title)
child
public static TypedNode child(TypedNode node,
java.lang.String[] types)
child
public static TypedNode child(TypedNode node,
java.lang.String[] types,
java.lang.String title)
children
public static TypedNode[] children(TypedNode node,
java.lang.String... types)
descendantTyped
public static TypedNode descendantTyped(TypedNode node,
java.lang.String type)
descendantTitled
public static TypedNode descendantTitled(TypedNode node,
java.lang.String title)
descendantsTyped
public static TypedNode[] descendantsTyped(TypedNode node,
java.lang.String... types)
descendants
public static TypedNode[] descendants(TypedNode node)
guaranteedValueChild
public static ValueNode guaranteedValueChild(DataNode parent,
java.lang.String type)
guaranteedChild
public static ValueNode guaranteedChild(DataNode parent,
java.lang.String type,
java.lang.String title)
guaranteedDescendant
public static ValueNode guaranteedDescendant(DataNode node,
java.lang.String... typePath)
setChild
public static void setChild(DataNode parent,
TypedNode child)
appendChild
public static void appendChild(DataNode node,
TypedNode child)
appendValue
public static void appendValue(DataNode node,
java.lang.Object value)
ancestry
public static TypedNode[] ancestry(TypedNode node)
mergeContents
public static ValueNode mergeContents(ValueNode node,
java.lang.Object... mergeContents)
- Merges new with existing node contents.
mergeContents
will overwrite any values with the same keys
- Parameters:
node
- contains any existing contentsmergeContents
- may include further ValueNode
s which will be
merged with any of the same type, name and path
- Returns:
node
passed with merged contents
valuesFirstLine
public static java.lang.String valuesFirstLine(TypedNode node)
valuesAsLine
public static java.lang.String valuesAsLine(TypedNode node,
int limit)
newValuesTitle
public static java.lang.String newValuesTitle(DataNode node)
pack
public static void pack(DataNode node)
unpack
public static void unpack(DataNode node)
newTestTree
public static TypedNode newTestTree(java.lang.String rootType,
int broad,
double shrinkBy)
- Returns:
- a tree sized by the parameters; for
broad
<=0 a minimal tree
treeInfo
public static java.lang.String treeInfo(DataNode tree,
boolean chars)
hasMixedContents
public static boolean hasMixedContents(TypedNode node)