Package org.opencms.util
Class CmsPathTree<P,V>
- java.lang.Object
-
- org.opencms.util.CmsPathTree<P,V>
-
- Type Parameters:
P
- the type of path componentsV
- the element type stored in the tree
public class CmsPathTree<P,V> extends java.lang.Object
Tree used to represent file system like data structures.A tree consists of a (possibly empty) value and a map from child names to subtrees.
-
-
Constructor Summary
Constructors Constructor Description CmsPathTree()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
collectEntries(java.util.Collection<V> target)
Collect all descendant values in the given collection.CmsPathTree<P,V>
findNode(java.util.List<P> path)
Finds the node for the given path, and returns it or null if node was found.CmsPathTree<P,V>
getChild(P pathPart)
Gets the child for the given path component.java.util.List<V>
getChildValues()
Returns the values for the direct children of this node.java.util.List<V>
getChildValues(java.util.List<P> path)
Gets the child values for the given path.java.util.List<V>
getDescendantValues(java.util.List<P> path)
Gets the descendant values.V
getValue()
Gets the value for this node (may be null).V
getValue(java.util.List<P> path)
Gets the value for the sub-path given, starting from this node.void
setValue(java.util.List<P> path, V value)
Sets the value for the sub-path given, starting from this node.void
setValue(V value)
Sets the value for this node.
-
-
-
Constructor Detail
-
CmsPathTree
public CmsPathTree()
-
-
Method Detail
-
collectEntries
public void collectEntries(java.util.Collection<V> target)
Collect all descendant values in the given collection.- Parameters:
target
- the collection in which to store the descendant values
-
findNode
public CmsPathTree<P,V> findNode(java.util.List<P> path)
Finds the node for the given path, and returns it or null if node was found.- Parameters:
path
- the path- Returns:
- the node for the path
-
getChild
public CmsPathTree<P,V> getChild(P pathPart)
Gets the child for the given path component.- Parameters:
pathPart
- the path component- Returns:
- the child for the given path component (may be null)
-
getChildValues
public java.util.List<V> getChildValues()
Returns the values for the direct children of this node.- Returns:
- the values for the direct children
-
getChildValues
public java.util.List<V> getChildValues(java.util.List<P> path)
Gets the child values for the given path.- Parameters:
path
- the path- Returns:
- the child values
-
getDescendantValues
public java.util.List<V> getDescendantValues(java.util.List<P> path)
Gets the descendant values.- Parameters:
path
- the path- Returns:
- the descendant values
-
getValue
public V getValue(java.util.List<P> path)
Gets the value for the sub-path given, starting from this node.- Parameters:
path
- the path- Returns:
- the value for the node
-
setValue
public void setValue(java.util.List<P> path, V value)
Sets the value for the sub-path given, starting from this node.- Parameters:
path
- the pathvalue
- the value to set
-
-