|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TraversalDescription
Represents a description of a traversal. This interface describes the rules and behavior of a traversal. A traversal description is immutable and each method which adds or modifies the behavior returns a new instances that includes the new modification, leaving the instance which returns the new instance intact. For instance,
TraversalDescription td = new TraversalDescriptionImpl(); td.depthFirst();is not going to modify td. you will need to reassign td, like
td = td.depthFirst();
When all the rules and behaviors have been described the traversal is started
by using traverse(Node)
where a starting node is supplied. The
Traverser
that is returned is then used to step through the graph,
and return the positions that matches the rules.
Method Summary | |
---|---|
TraversalDescription |
breadthFirst()
A convenience method for order(BranchOrderingPolicy)
where a "preorder breadth first" selector is used. |
TraversalDescription |
depthFirst()
A convenience method for order(BranchOrderingPolicy)
where a "preorder depth first" selector is used. |
TraversalDescription |
evaluator(Evaluator evaluator)
NOTE: Replaces filter(Predicate) and
prune(PruneEvaluator) . |
TraversalDescription |
expand(RelationshipExpander expander)
Sets the RelationshipExpander as the expander of relationships,
discarding all previous calls to
relationships(RelationshipType) and
relationships(RelationshipType, Direction) . |
TraversalDescription |
filter(Predicate<Path> filter)
Deprecated. because of the introduction of Evaluator . Use
evaluator(Evaluator) instead which combines
filter(Predicate) and prune(PruneEvaluator) . The supplied
Predicate will be wrapped by an Evaluator internally. |
TraversalDescription |
order(BranchOrderingPolicy selector)
Sets the BranchOrderingPolicy to use. |
TraversalDescription |
prune(PruneEvaluator pruning)
Deprecated. because of the introduction of Evaluator . Use
evaluator(Evaluator) instead which combines
filter(Predicate) and prune(PruneEvaluator) . The supplied
PruneEvaluator will be wrapped by an Evaluator internally. |
TraversalDescription |
relationships(RelationshipType type)
Adds type to the list of relationship types to traverse. |
TraversalDescription |
relationships(RelationshipType type,
Direction direction)
Adds type to the list of relationship types to traverse in
the given direction . |
Traverser |
traverse(Node startNode)
Traverse from startNode based on all the rules and behavior
in this description. |
TraversalDescription |
uniqueness(UniquenessFactory uniqueness)
Sets the UniquenessFactory for creating the
UniquenessFilter to use. |
TraversalDescription |
uniqueness(UniquenessFactory uniqueness,
Object parameter)
Sets the UniquenessFactory for creating the
UniquenessFilter to use. |
Method Detail |
---|
TraversalDescription uniqueness(UniquenessFactory uniqueness)
UniquenessFactory
for creating the
UniquenessFilter
to use.
uniqueness
- the UniquenessFactory
the creator
of the desired UniquenessFilter
to use.
TraversalDescription uniqueness(UniquenessFactory uniqueness, Object parameter)
UniquenessFactory
for creating the
UniquenessFilter
to use. It also accepts an extra parameter
which is mandatory for certain uniqueness's, f.ex
Uniqueness.NODE_RECENT
.
uniqueness
- the UniquenessFactory
the creator
of the desired UniquenessFilter
to use.
TraversalDescription prune(PruneEvaluator pruning)
Evaluator
. Use
evaluator(Evaluator)
instead which combines
filter(Predicate)
and prune(PruneEvaluator)
. The supplied
PruneEvaluator
will be wrapped by an Evaluator
internally.
pruning
to the list of PruneEvaluator
s which
are used to prune the traversal. The semantics for many prune evaluators
is that if any one of the added prune evaluators returns true
it's considered OK to prune there.
pruning
- the PruneEvaluator
to add to the list of prune
evaluators to use.
TraversalDescription filter(Predicate<Path> filter)
Evaluator
. Use
evaluator(Evaluator)
instead which combines
filter(Predicate)
and prune(PruneEvaluator)
. The supplied
Predicate
will be wrapped by an Evaluator
internally.
filter
to the list of filters to use, i.e. a filter to
decide which positions are OK to return or not.
Each position is represented by a Path
from the start node of the
traversal to the current node. The current node is the
Path.endNode()
of the path. Each Path
must be accepted
by all added filter for it to be returned from the traverser. For adding
a filter which returns paths accepted by any filters, see
Traversal.returnAcceptedByAny(Predicate...)
for convenience.
filter
- the Predicate
to add to the list of filters.
TraversalDescription evaluator(Evaluator evaluator)
filter(Predicate)
and
prune(PruneEvaluator)
.
Adds evaluator
to the list of evaluators which will control the
behaviour of the traversal. Each Evaluator
can decide whether or
not to include a position in the traverser result, i.e. return it from
the Traverser
iterator and also whether to continue down that
path or to prune, so that the traverser won't continue further down that
path.
Multiple Evaluator
s can be added. For a path to be included in
the result, all evaluators must agree to include it, i.e. returning
either Evaluation.INCLUDE_AND_CONTINUE
or
Evaluation.INCLUDE_AND_PRUNE
. For making the traversal continue
down that path all evaluators must agree to continue from that path, i.e.
returning either Evaluation.INCLUDE_AND_CONTINUE
or
Evaluation.EXCLUDE_AND_CONTINUE
.
evaluator
-
TraversalDescription order(BranchOrderingPolicy selector)
BranchOrderingPolicy
to use. A BranchSelector
is the basic decisions in the traversal of "where to go next".
Examples of default implementations are "breadth first" and
"depth first", which can be set with convenience methods
breadthFirst()
and depthFirst()
.
selector
- the factory which creates the BranchSelector
to use with the traversal.
TraversalDescription depthFirst()
order(BranchOrderingPolicy)
where a "preorder depth first" selector is used. Positions which are
deeper than the current position will be returned before positions on
the same depth. See http://en.wikipedia.org/wiki/Depth-first_search
TraversalDescription breadthFirst()
order(BranchOrderingPolicy)
where a "preorder breadth first" selector is used. All positions with
the same depth will be returned before advancing to the next depth.
See http://en.wikipedia.org/wiki/Breadth-first_search
TraversalDescription relationships(RelationshipType type)
type
to the list of relationship types to traverse.
There's no priority or order in which types to traverse.
type
- the RelationshipType
to add to the list of types
to traverse.
TraversalDescription relationships(RelationshipType type, Direction direction)
type
to the list of relationship types to traverse in
the given direction
. There's no priority or order in which
types to traverse.
type
- the RelationshipType
to add to the list of types
to traverse.direction
- the Direction
to traverse this type of
relationship in.
TraversalDescription expand(RelationshipExpander expander)
RelationshipExpander
as the expander of relationships,
discarding all previous calls to
relationships(RelationshipType)
and
relationships(RelationshipType, Direction)
.
expander
- the RelationshipExpander
to use.
Traverser traverse(Node startNode)
startNode
based on all the rules and behavior
in this description. A Traverser
is returned which is
used to step through the graph and getting results back. The traversal
is not guaranteed to start before the Traverser is used.
startNode
- the Node
to start the traversal from.
Traverser
used to step through the graph and to get
results from.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |