TraversalPosition (Neo 1.0-b6 API)
Keywords: org.neo4j.api.core.TraversalPosition interface

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.neo4j.api.core
Interface TraversalPosition

    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.
`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

### currentNode

    Node currentNode()

  Return the current node.

  Returns:
    The current node

### previousNode

    Node previousNode()

  Returns the previous node, may be null.

  Returns:
    The previous node

### lastRelationshipTraversed

    Relationship lastRelationshipTraversed()

  Return the last relationship traversed, may be null.

  Returns:
    The last relationship traversed

### depth

    int depth()

  Returns the current traversal depth.

  Returns:
    The current traversal depth

### returnedNodesCount

    int returnedNodesCount()

  Returns the number of nodes returned by traverser so far.

  Returns:
    The number of returned nodes.

### notStartNode

    boolean notStartNode()

  Returns `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 );
       }

  Returns:
    `true` if the traversal is not currently positioned on the start node, `false` if it is

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 Neo4j. All Rights Reserved.