public abstract class TreeFormatter extends Object
Modifier and Type | Field and Description |
---|---|
static TreeFormatter |
DOT
A tree formatter for .dot string representations.
|
static TreeFormatter |
LISP
Formats a given tree to a lisp string representation.
|
static TreeFormatter |
PARENTHESES
Formats a given tree to a parentheses string representation.
|
static TreeFormatter |
TREE
Formats a given tree to a tree string representation.
|
Modifier | Constructor and Description |
---|---|
protected |
TreeFormatter() |
Modifier and Type | Method and Description |
---|---|
static TreeFormatter |
dot(String treeName)
A tree formatter for .dot string representations.
|
String |
format(Tree<?,?> tree)
Formats the given
tree to its string representation. |
abstract <V> String |
format(Tree<V,?> tree,
Function<? super V,String> mapper)
Formats the given
tree to its string representation. |
public static final TreeFormatter TREE
mul ├── div │ ├── cos │ │ └── 1.0 │ └── cos │ └── π └── sin └── mul ├── 1.0 └── z
public static final TreeFormatter PARENTHESES
mul(div(cos(1.0),cos(π)),sin(mul(1.0,z)))
public static final TreeFormatter LISP
(mul (div (cos 1.0) (cos π)) (sin (mul 1.0 z)))
public static final TreeFormatter DOT
mul(div(cos(1.0),cos(π)),sin(mul(1.0,z)))is rendered into this dot string
digraph Tree { node_001 [label="div"]; node_002 [label="cos"]; node_003 [label="1.0"]; node_004 [label="cos"]; node_000 [label="mul"]; node_009 [label="z"]; node_005 [label="π"]; node_006 [label="sin"]; node_007 [label="mul"]; node_008 [label="1.0"]; node_000 -> node_001; node_001 -> node_002; node_002 -> node_003; node_001 -> node_004; node_004 -> node_005; node_000 -> node_006; node_006 -> node_007; node_007 -> node_008; node_007 -> node_009; }This dot string can be rendered into the following graph:
protected TreeFormatter()
public abstract <V> String format(Tree<V,?> tree, Function<? super V,String> mapper)
tree
to its string representation. The given
mapper
is used for converting the node type V
to a string
value.V
- the tree node typetree
- the input tree to formatmapper
- the tree node value mappertree
NullPointerException
- if one of the arguments is null
public String format(Tree<?,?> tree)
tree
to its string representation.tree
- the input tree to formattree
NullPointerException
- if the tree
is null
public static TreeFormatter dot(String treeName)
mul(div(cos(1.0),cos(π)),sin(mul(1.0,z)))is rendered into this dot string
digraph Tree { node_001 [label="div"]; node_002 [label="cos"]; node_003 [label="1.0"]; node_004 [label="cos"]; node_000 [label="mul"]; node_009 [label="z"]; node_005 [label="π"]; node_006 [label="sin"]; node_007 [label="mul"]; node_008 [label="1.0"]; node_000 -> node_001; node_001 -> node_002; node_002 -> node_003; node_001 -> node_004; node_004 -> node_005; node_000 -> node_006; node_006 -> node_007; node_007 -> node_008; node_007 -> node_009; }This dot string can be rendered into the following graph:
treeName
- the name of the digraphNullPointerException
- if the given tree name is null
© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)