public class DoubleLinkedPoiCategory extends java.lang.Object implements PoiCategory
Constructor and Description |
---|
DoubleLinkedPoiCategory(java.lang.String title,
PoiCategory parent)
Creates a new category without knowing its position in the final category tree.
|
DoubleLinkedPoiCategory(java.lang.String title,
PoiCategory parent,
int id)
Creates a new category.
|
Modifier and Type | Method and Description |
---|---|
static int |
calculateCategoryIDs(DoubleLinkedPoiCategory rootNode,
int maxValue)
This method calculates a unique ID for all nodes in the tree.
|
java.util.Collection<PoiCategory> |
deepChildren() |
java.util.Collection<PoiCategory> |
getChildren() |
static java.lang.String |
getGraphVizString(DoubleLinkedPoiCategory rootNode)
Generates a GraphViz source representation as a tree having the current node as its root.
|
int |
getID()
Make sure you call
calculateCategoryIDs(DoubleLinkedPoiCategory, int) first. |
PoiCategory |
getParent() |
java.lang.String |
getTitle() |
void |
setParent(PoiCategory parent)
Sets the category's parent category.
|
java.lang.String |
toString() |
public DoubleLinkedPoiCategory(java.lang.String title, PoiCategory parent)
calculateCategoryIDs(DoubleLinkedPoiCategory, int)
to
assign the IDs.title
- The category's unique title.parent
- The category's parent category. For creating a root node, set the parent to null.public DoubleLinkedPoiCategory(java.lang.String title, PoiCategory parent, int id)
PoiCategoryManager
when reading a category configuration from a database or XML file. Otherwise call
DoubleLinkedPoiCategory(String, PoiCategory)
.title
- The category's unique title.parent
- The category's parent category. For creating a root node, set the parent to null.id
- The category's position in the tree determined by left-order-dfs-traversal.public static int calculateCategoryIDs(DoubleLinkedPoiCategory rootNode, int maxValue)
rootNode
- The tree's root node. (Any other node will result in invalid IDs!)maxValue
- Global maximum ID.public java.util.Collection<PoiCategory> deepChildren()
deepChildren
in interface PoiCategory
public java.util.Collection<PoiCategory> getChildren()
getChildren
in interface PoiCategory
public static java.lang.String getGraphVizString(DoubleLinkedPoiCategory rootNode)
rootNode
- The resulting graph's root node. (You can use any sub node to get a sub-graph).public int getID()
calculateCategoryIDs(DoubleLinkedPoiCategory, int)
first.getID
in interface PoiCategory
public PoiCategory getParent()
getParent
in interface PoiCategory
public java.lang.String getTitle()
getTitle
in interface PoiCategory
public void setParent(PoiCategory parent)
setParent
in interface PoiCategory
parent
- The category to be set as parent.public java.lang.String toString()
toString
in class java.lang.Object