org.mmbase.bridge.util
Class GrowingTreeList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by org.mmbase.bridge.util.AbstractSequentialBridgeList<Node>
                  extended by org.mmbase.bridge.util.TreeList
                      extended by org.mmbase.bridge.util.GrowingTreeList
All Implemented Interfaces:
Iterable<Node>, Collection<Node>, List<Node>, BridgeList<Node>, NodeList

public class GrowingTreeList
extends TreeList

This version of TreeList is automaticly growing with the same 'branch' every time when that is possible. For that it needs a kind of template query for every branch, which is defined by the constructor.

Since:
MMBase-1.7
Version:
$Id: GrowingTreeList.java 41991 2010-04-20 16:48:55Z michiel $
Author:
Michiel Meeuwissen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mmbase.bridge.util.TreeList
TreeList.Branch, TreeList.TreeItr
 
Field Summary
protected  Constraint cleanConstraint
           
protected  Constraint cleanLeafConstraint
           
protected  NodeQuery leafElementTemplate
           
protected  int maxNumberOfSteps
           
protected  NodeQuery pathElementTemplate
           
 
Fields inherited from class org.mmbase.bridge.util.TreeList
branches, cloud, foundEnd, leafConstraintOffset, max, numberOfSteps, REAL_NODES, topQuery
 
Fields inherited from class java.util.AbstractList
modCount
 
Fields inherited from interface org.mmbase.bridge.NodeList
NODESTEP_PROPERTY, QUERY_PROPERTY
 
Constructor Summary
GrowingTreeList(NodeQuery q, int maxDepth)
          This may be used in combination with Queries.addPath(tree.getTemplate(), (String) path.getValue(this), (String) searchDirs.getValue(this)); So you add a template constisting of a bunch of elements.
GrowingTreeList(NodeQuery q, int maxDepth, NodeManager nodeManager, String role, String searchDir)
           
GrowingTreeList(TreeList tl, int maxDepth)
           
 
Method Summary
protected  void addPathElement()
          Grows the branches of the tree, with the leave.
protected  NodeList getLeafList(int queryNumber)
          Executes one query as a 'leaf' query.
 NodeQuery getLeafTemplate()
          The leave template is the 'last' template.
protected  NodeList getList(int queryNumber)
          Executes one query if that did not happen yet, and stores the result in the 'results' List
 NodeQuery getTemplate()
          Returns the Query which is used as a template for the leaves to 'grow' the query.
static void main(String[] args)
           
 void setMaxDepth(int maxDepth)
          As long as the tree is not 'started' yet, max depth can still be changed.
 int size()
           
 
Methods inherited from class org.mmbase.bridge.util.TreeList
doTest, getCloud, getLeafQuery, getMax, getNode, getQuery, getRealNode, grow, listIterator, nodeIterator, setLeafConstraint, setMax, sizeCheck, subList, subNodeList, toString, treeIterator, treeIterator
 
Methods inherited from class org.mmbase.bridge.util.AbstractSequentialBridgeList
getProperties, getProperty, setProperty, sort, sort
 
Methods inherited from class java.util.AbstractSequentialList
add, addAll, get, iterator, remove, set
 
Methods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.bridge.BridgeList
getProperties, getProperty, setProperty, sort, sort
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, remove, remove, removeAll, retainAll, set, toArray, toArray
 

Field Detail

cleanConstraint

protected Constraint cleanConstraint

pathElementTemplate

protected NodeQuery pathElementTemplate

cleanLeafConstraint

protected Constraint cleanLeafConstraint

leafElementTemplate

protected NodeQuery leafElementTemplate

maxNumberOfSteps

protected int maxNumberOfSteps
Constructor Detail

GrowingTreeList

public GrowingTreeList(NodeQuery q,
                       int maxDepth,
                       NodeManager nodeManager,
                       String role,
                       String searchDir)
Parameters:
q - The 'base' query defining the minimal depth of the tree elements. The trunk of the tree.
maxDepth - You must supply a maximal depth of the nodes, because MMBase is basicly a network rather then a tree, so tree representations could be infinitely deep.
nodeManager - Destination Nodemanager in the tree
role - Role of the relations in the tree
searchDir - Direction of the relations in the tree
Since:
MMBase-1.7.1

GrowingTreeList

public GrowingTreeList(NodeQuery q,
                       int maxDepth)
This may be used in combination with Queries.addPath(tree.getTemplate(), (String) path.getValue(this), (String) searchDirs.getValue(this)); So you add a template constisting of a bunch of elements.


GrowingTreeList

public GrowingTreeList(TreeList tl,
                       int maxDepth)
Method Detail

setMaxDepth

public void setMaxDepth(int maxDepth)
As long as the tree is not 'started' yet, max depth can still be changed.

Parameters:
maxDepth - max number of Steps
Since:
MMBase-1.7.1

getTemplate

public NodeQuery getTemplate()
Returns the Query which is used as a template for the leaves to 'grow' the query. You can change it, add sort-orders and add constraints before the tree is 'started'. All but the first step of this query are added. This query itself is never executed, though marked used, to avoid changes on it after the list has started.

Returns:
Query which is used as a template
Since:
MMBase-1.7.1

getLeafTemplate

public NodeQuery getLeafTemplate()
The leave template is the 'last' template. This is the same as getTemplate, only, the constraints set on this, are only used if the template is used 'on the end'. It boils down to the fact that constraints set on the query don't change the tree itself, but only constraint the 'leaves', so it makes for a kind of tree-search.

Since:
MMBase-1.8

size

public int size()
Specified by:
size in interface Collection<Node>
Specified by:
size in interface List<Node>
Overrides:
size in class TreeList

getList

protected NodeList getList(int queryNumber)
Description copied from class: TreeList
Executes one query if that did not happen yet, and stores the result in the 'results' List

Overrides:
getList in class TreeList
Returns:
NodeList or null if queryNumber too big

getLeafList

protected NodeList getLeafList(int queryNumber)
Description copied from class: TreeList
Executes one query as a 'leaf' query.

Overrides:
getLeafList in class TreeList

addPathElement

protected void addPathElement()
Grows the branches of the tree, with the leave.


main

public static void main(String[] args)


MMBase 2.0-SNAPSHOT - null