public interface TreeFactory
TreeFactory
acts as a factory for creating objects of
class Tree
, or some descendant class.
Methods implementing this interface may assume that the List
of children passed to them is a list that actually contains trees, but
this can't be enforced in Java without polymorphic types.
The methods with a String argument do not guarantee
that the tree label() will be a String -- the TreeFactory may
convert it into some other type.Modifier and Type | Method and Description |
---|---|
Tree |
newLeaf(Label label)
Create a new tree leaf node, with the given label.
|
Tree |
newLeaf(java.lang.String word)
Create a new tree leaf node, where the label is formed from
the
String passed in. |
Tree |
newTreeNode(Label label,
java.util.List<Tree> children)
Create a new tree non-leaf node, with the given label.
|
Tree |
newTreeNode(java.lang.String parent,
java.util.List<Tree> children)
Create a new tree non-leaf node, where the label is formed from
the
String passed in. |
Tree newLeaf(java.lang.String word)
String
passed in.word
- The word that will go into the tree label.Tree newTreeNode(java.lang.String parent, java.util.List<Tree> children)
String
passed in.parent
- The string that will go into the parent tree label.children
- The list of daughters of this tree. The children
may be a (possibly empty) List
of children or
null
Tree newLeaf(Label label)
label
- The label for the leaf nodeTree newTreeNode(Label label, java.util.List<Tree> children)
label
- The label for the parent tree node.children
- The list of daughters of this tree. The children
may be a (possibly empty) List
of children or
null