org.neo4j.graphdb.traversal
Class Evaluators

java.lang.Object
  extended by org.neo4j.graphdb.traversal.Evaluators

public abstract class Evaluators
extends Object

Common Evaluators useful during common traversals.

Author:
Mattias Persson
See Also:
Evaluator, TraversalDescription

Constructor Summary
Evaluators()
           
 
Method Summary
static PathEvaluator all()
           
static PathEvaluator atDepth(int depth)
          Returns an Evaluator which only includes positions at depth and prunes everything deeper than that.
static PathEvaluator endNodeIs(Evaluation evaluationIfMatch, Evaluation evaluationIfNoMatch, Node... possibleEndNodes)
          An Evaluator which will return evaluationIfMatch if Path.endNode() for a given path is any of nodes, else evaluationIfNoMatch.
static PathEvaluator excludeStartPosition()
           
static PathEvaluator fromDepth(int depth)
          Returns an Evaluator which only includes positions from depth and deeper and never prunes anything.
static PathEvaluator includeIfAcceptedByAny(Evaluator... evaluators)
          Whereas adding Evaluators to a TraversalDescription puts those evaluators in AND-mode this can group many evaluators in OR-mode.
static PathEvaluator includeIfAcceptedByAny(PathEvaluator... evaluators)
          Whereas adding Evaluators to a TraversalDescription puts those evaluators in AND-mode this can group many evaluators in OR-mode.
static PathEvaluator includeIfContainsAll(Node... nodes)
          Evaluator which decides to include a Path if all the nodes exist in it.
static PathEvaluator includeWhereEndNodeIs(Node... nodes)
           
static PathEvaluator includeWhereLastRelationshipTypeIs(RelationshipType type, RelationshipType... orAnyOfTheseTypes)
           
static PathEvaluator includingDepths(int minDepth, int maxDepth)
          Returns an Evaluator which only includes positions between depths minDepth and maxDepth.
static PathEvaluator lastRelationshipTypeIs(Evaluation evaluationIfMatch, Evaluation evaluationIfNoMatch, RelationshipType type, RelationshipType... orAnyOfTheseTypes)
          Returns an Evaluator which compares the type of the last relationship in a Path to a given set of relationship types (one or more).If the type of the last relationship in a path is of one of the given types then evaluationIfMatch will be returned, otherwise evaluationIfNoMatch will be returned.
static PathEvaluator pruneWhereEndNodeIs(Node... nodes)
           
static PathEvaluator pruneWhereLastRelationshipTypeIs(RelationshipType type, RelationshipType... orAnyOfTheseTypes)
           
static Evaluator returnWhereEndNodeIs(Node... nodes)
          Deprecated. use includeWhereEndNodeIs(Node...)
static Evaluator returnWhereLastRelationshipTypeIs(RelationshipType type, RelationshipType... orAnyOfTheseTypes)
          Deprecated. use includeWhereLastRelationshipTypeIs(RelationshipType, RelationshipType...)
static PathEvaluator toDepth(int depth)
          Returns an Evaluator which includes positions down to depth and prunes everything deeper than that.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Evaluators

public Evaluators()
Method Detail

all

public static PathEvaluator all()
Returns:
an evaluator which includes everything it encounters and doesn't prune anything.

excludeStartPosition

public static PathEvaluator excludeStartPosition()
Returns:
an evaluator which never prunes and includes everything except the first position, i.e. the the start node.

toDepth

public static PathEvaluator toDepth(int depth)
Returns an Evaluator which includes positions down to depth and prunes everything deeper than that.

Parameters:
depth - the max depth to traverse to.
Returns:
Returns an Evaluator which includes positions down to depth and prunes everything deeper than that.

fromDepth

public static PathEvaluator fromDepth(int depth)
Returns an Evaluator which only includes positions from depth and deeper and never prunes anything.

Parameters:
depth - the depth to start include positions from.
Returns:
Returns an Evaluator which only includes positions from depth and deeper and never prunes anything.

atDepth

public static PathEvaluator atDepth(int depth)
Returns an Evaluator which only includes positions at depth and prunes everything deeper than that.

Parameters:
depth - the depth to start include positions from.
Returns:
Returns an Evaluator which only includes positions at depth and prunes everything deeper than that.

includingDepths

public static PathEvaluator includingDepths(int minDepth,
                                            int maxDepth)
Returns an Evaluator which only includes positions between depths minDepth and maxDepth. It prunes everything deeper than maxDepth.

Parameters:
minDepth - minimum depth a position must have to be included.
maxDepth - maximum depth a position must have to be included.
Returns:
Returns an Evaluator which only includes positions between depths minDepth and maxDepth. It prunes everything deeper than maxDepth.

lastRelationshipTypeIs

public static PathEvaluator lastRelationshipTypeIs(Evaluation evaluationIfMatch,
                                                   Evaluation evaluationIfNoMatch,
                                                   RelationshipType type,
                                                   RelationshipType... orAnyOfTheseTypes)
Returns an Evaluator which compares the type of the last relationship in a Path to a given set of relationship types (one or more).If the type of the last relationship in a path is of one of the given types then evaluationIfMatch will be returned, otherwise evaluationIfNoMatch will be returned.

Parameters:
evaluationIfMatch - the Evaluation to return if the type of the last relationship in the path matches any of the given types.
evaluationIfNoMatch - the Evaluation to return if the type of the last relationship in the path doesn't match any of the given types.
type - the (first) type (of possibly many) to match the last relationship in paths with.
orAnyOfTheseTypes - additional types to match the last relationship in paths with.
Returns:
an Evaluator which compares the type of the last relationship in a Path to a given set of relationship types.

returnWhereLastRelationshipTypeIs

public static Evaluator returnWhereLastRelationshipTypeIs(RelationshipType type,
                                                          RelationshipType... orAnyOfTheseTypes)
Deprecated. use includeWhereLastRelationshipTypeIs(RelationshipType, RelationshipType...)


includeWhereLastRelationshipTypeIs

public static PathEvaluator includeWhereLastRelationshipTypeIs(RelationshipType type,
                                                               RelationshipType... orAnyOfTheseTypes)
Parameters:
type - the (first) type (of possibly many) to match the last relationship in paths with.
orAnyOfTheseTypes - types to match the last relationship in paths with. If any matches it's considered a match.
Returns:
an Evaluator which compares the type of the last relationship in a Path to a given set of relationship types.
See Also:
Uses {@link Evaluation#INCLUDE_AND_CONTINUE} for {@code evaluationIfMatch} and {@link Evaluation#EXCLUDE_AND_CONTINUE} for {@code evaluationIfNoMatch}.

pruneWhereLastRelationshipTypeIs

public static PathEvaluator pruneWhereLastRelationshipTypeIs(RelationshipType type,
                                                             RelationshipType... orAnyOfTheseTypes)
Parameters:
type - the (first) type (of possibly many) to match the last relationship in paths with.
orAnyOfTheseTypes - types to match the last relationship in paths with. If any matches it's considered a match.
Returns:
an Evaluator which compares the type of the last relationship in a Path to a given set of relationship types.
See Also:
Uses {@link Evaluation#INCLUDE_AND_PRUNE} for {@code evaluationIfMatch} and {@link Evaluation#INCLUDE_AND_CONTINUE} for {@code evaluationIfNoMatch}.

endNodeIs

public static PathEvaluator endNodeIs(Evaluation evaluationIfMatch,
                                      Evaluation evaluationIfNoMatch,
                                      Node... possibleEndNodes)
An Evaluator which will return evaluationIfMatch if Path.endNode() for a given path is any of nodes, else evaluationIfNoMatch.

Parameters:
evaluationIfMatch - the Evaluation to return if the Path.endNode() is any of the nodes in nodes.
evaluationIfNoMatch - the Evaluation to return if the Path.endNode() doesn't match any of the nodes in nodes.
possibleEndNodes - a set of nodes to match to end nodes in paths.
Returns:
an Evaluator which will return evaluationIfMatch if Path.endNode() for a given path is any of nodes, else evaluationIfNoMatch.

returnWhereEndNodeIs

public static Evaluator returnWhereEndNodeIs(Node... nodes)
Deprecated. use includeWhereEndNodeIs(Node...)


includeWhereEndNodeIs

public static PathEvaluator includeWhereEndNodeIs(Node... nodes)
Parameters:
nodes - end nodes for paths to be included in the result.
See Also:
this#endNodeIs(Evaluation, Evaluation, Node...), uses {@link Evaluation#INCLUDE_AND_CONTINUE} for {@code evaluationIfMatch} and {@link Evaluation#EXCLUDE_AND_CONTINUE} for {@code evaluationIfNoMatch}.

pruneWhereEndNodeIs

public static PathEvaluator pruneWhereEndNodeIs(Node... nodes)

includeIfContainsAll

public static PathEvaluator includeIfContainsAll(Node... nodes)
Evaluator which decides to include a Path if all the nodes exist in it.

Parameters:
nodes - Nodes that must exist in a Path for it to be included.
Returns:
Evaluation.INCLUDE_AND_CONTINUE if all nodes exist in a given Path, otherwise Evaluation.EXCLUDE_AND_CONTINUE.

includeIfAcceptedByAny

public static PathEvaluator includeIfAcceptedByAny(PathEvaluator... evaluators)
Whereas adding Evaluators to a TraversalDescription puts those evaluators in AND-mode this can group many evaluators in OR-mode.

Parameters:
evaluators - represented as one evaluators. If any of the evaluators decides to include a path it will be included.
Returns:
an Evaluator which decides to include a path if any of the supplied evaluators wants to include it.

includeIfAcceptedByAny

public static PathEvaluator includeIfAcceptedByAny(Evaluator... evaluators)
Whereas adding Evaluators to a TraversalDescription puts those evaluators in AND-mode this can group many evaluators in OR-mode.

Parameters:
evaluators - represented as one evaluators. If any of the evaluators decides to include a path it will be included.
Returns:
an Evaluator which decides to include a path if any of the supplied evaluators wants to include it.


Copyright © 2002-2013 The Neo4j Graph Database Project. All Rights Reserved.