|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TraversalPosition
Encapsulates information about the current traversal position.
Method Summary | |
---|---|
Node |
currentNode()
Return the current node. |
int |
depth()
Returns the current traversal depth. |
boolean |
isStartNode()
Returns true if the current position is the start node,
false otherwise. |
Relationship |
lastRelationshipTraversed()
Return the last relationship traversed, may be null. |
boolean |
notStartNode()
Returns true if the current position is anywhere except on
the start node, false if it is on the start node. |
Node |
previousNode()
Returns the previous node, may be null. |
int |
returnedNodesCount()
Returns the number of nodes returned by traverser so far. |
Method Detail |
---|
Node currentNode()
Node previousNode()
Relationship lastRelationshipTraversed()
int depth()
int returnedNodesCount()
boolean notStartNode()
true
if the current position is anywhere except on
the start node, false
if it is on the start node. This is
useful because code in the
evaluators
usually have to treat the edge
case of the start node separately and using this method makes that code a
lot cleaner. For example, old code would be:
public boolean isReturnableNode( TraversalPosition currentPos )
{
if ( currentPos.lastRelationshipTraversed() == null )
{
return false;
}
else
{
return currentPos.lastRelationshipTraversed().isType(
MyRelationshipTypes.SOME_REL );
}
}
But using notStartNode()
:
public boolean isReturnableNode( TraversalPosition currentPos )
{
return currentPos.notStartNode()
&& currentPos.lastRelationshipTraversed().isType(
MyRelationshipTypes.SOME_REL );
}
true
if the traversal is not currently positioned
on the start node, false
if it isboolean isStartNode()
true
if the current position is the start node,
false
otherwise. This is useful because code in
the
evaluators
usually
have to treat the edge case of the start node separately and using this
method makes that code a lot cleaner. For example, old code would be:
public boolean isReturnableNode( TraversalPosition currentPos )
{
if ( currentPos.lastRelationshipTraversed() == null )
{
return false;
}
else
{
return currentPos.lastRelationshipTraversed().isType(
MyRelationshipTypes.SOME_REL );
}
}
But using notStartNode()
:
public boolean isReturnableNode( TraversalPosition currentPos )
{
return !currentPos.isStartNode()
&& currentPos.lastRelationshipTraversed().isType(
MyRelationshipTypes.SOME_REL );
}
true
if the traversal is on the start node,
false
otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |