dfh.treepath
Class Path<N>

java.lang.Object
  extended by dfh.treepath.Path<N>
Type Parameters:
N -
All Implemented Interfaces:
Serializable

public class Path<N>
extends Object
implements Serializable

A compiled tree path expression.

Author:
David F. Houghton - May 1, 2012
See Also:
Serialized Form

Method Summary
 N first(N n)
          Selects the first node in the tree that matches the path.
 N first(N n, Index<N> i)
          Selects the first node in the tree that matches the path.
 List<N> select(N root)
          Selects nodes in the tree that match the path.
 List<N> select(N n, Index<N> i)
          Selects nodes in the tree that match the path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

select

public List<N> select(N root)
Selects nodes in the tree that match the path. If it is not a relative path and the nodes in the tree do not know their own parents, this match will fail unless the context node given is the root node.

This method is like select(Object, Index) -- in fact, it delegates to this method after constructing an appropriate index. Use this method if you are doing few matches on the tree. Each select in this case will generate a fresh index.

Parameters:
root - a node in the tree; if this is not the root node and the tree's nodes do not know their own parents -- see ParentIndex -- this will be the de-facto root node
Returns:
the nodes matching the path in the order of their discovery

select

public List<N> select(N n,
                      Index<N> i)
Selects nodes in the tree that match the path. If it is not a relative path and the nodes in the tree do not know their own parents, this match will fail unless the context node given is the root node.

This method is like select(Object), but uses a pre-constructed index. Use this method if you are doing many matches on the same tree as it prevents redundant object creation and tree walking.

Parameters:
n - a node in the tree; if this is not the root node and the tree's nodes do not know their own parents -- see ParentIndex -- this will be the de-facto root node
i - an index of the tree
Returns:
the nodes matching the path in the order of their discovery

first

public N first(N n,
               Index<N> i)
Selects the first node in the tree that matches the path. If it is not a relative path and the nodes in the tree do not know their own parents, this match will fail unless the context node given is the root node.

This method is like first(Object), but uses a pre-constructed index. Use this method if you are doing many matches on the same tree as it prevents redundant object creation and tree walking.

Parameters:
n - a node in the tree; if this is not the root node and the tree's nodes do not know their own parents -- see ParentIndex -- this will be the de-facto root node
i - an index of the tree
Returns:
the first node in the collection represented by the path

first

public N first(N n)
Selects the first node in the tree that matches the path. If it is not a relative path and the nodes in the tree do not know their own parents, this match will fail unless the context node given is the root node.

Parameters:
n - a node in the tree; if this is not the root node and the tree's nodes do not know their own parents -- see ParentIndex -- this will be the de-facto root node
Returns:
the first node in the collection represented by the path