org.neo4j.api.core
Interface ReturnableEvaluator


public interface ReturnableEvaluator

A client hook for evaluating whether a specific node should be returned from a traverser. When a traverser is created the client parameterizes it with an instance of a ReturnableEvaluator. The traverser then invokes the isReturnableNode() operation just before returning a specific node, allowing the client to either approve or disapprove of returning that node.

When implementing a ReturnableEvaluator, the client investigates the information encapsulated in a TraversalPosition to decide whether a node is returnable. For example, here's a snippet detailing a ReturnableEvaluator that will only return 5 nodes:

 ReturnableEvaluator returnEvaluator = new ReturnableEvaluator()
 {
     public boolean isReturnableNode( TraversalPosition position )
     {
         // Return nodes until we've reached 5 nodes or end of graph
         return position.returnedNodesCount() < 5;
     }
 };
 


Field Summary
static ReturnableEvaluator ALL
          A returnable evaluator that returns all nodes encountered.
static ReturnableEvaluator ALL_BUT_START_NODE
          A returnable evaluator that returns all nodes except start node.
 
Method Summary
 boolean isReturnableNode(TraversalPosition currentPos)
          Method invoked by traverser to see if current position is a returnable node.
 

Field Detail

ALL

static final ReturnableEvaluator ALL
A returnable evaluator that returns all nodes encountered.


ALL_BUT_START_NODE

static final ReturnableEvaluator ALL_BUT_START_NODE
A returnable evaluator that returns all nodes except start node.

Method Detail

isReturnableNode

boolean isReturnableNode(TraversalPosition currentPos)
Method invoked by traverser to see if current position is a returnable node.

Parameters:
currentPos - The traversal position
Returns:
True if current position is a returnable node


Copyright © 2009 Neo4j. All Rights Reserved.