gishur.graph.core
Class GraphElementCursor

java.lang.Object
  |
  +--gishur.core.CursorAdapter
        |
        +--gishur.graph.core.GraphCursor
              |
              +--gishur.graph.core.GraphElementCursor
All Implemented Interfaces:
Cursor, java.util.Enumeration

public class GraphElementCursor
extends GraphCursor

A GraphCursor, that enumerates the connected GraphElements of a given GraphElement. One may not instantiate this class directly; use the methods Graph.outEdges(gishur.graph.core.Node), Graph.inEdges(gishur.graph.core.Node), Graph.edges()... of the Graph class instead.

Version:
1.0
Author:
Thomas Wolf

Method Summary
 java.lang.Object element()
          Returns the element to which this Cursor points at the moment.
 java.lang.Object getBookmark()
          Returns a bookmark-object.
 Graph graph()
          Returns the Graph, on which the Cursor works.
 GraphElement graphElement()
          Returns the element under the actual position as an GraphElement, if this is possible (i.e. the position is valid and points to an GraphElement.
 void invalidate()
          Sets the Cursor to an invalid position.
 int length()
          Returns the number of elements in the underlying structure of this Cursor.
 void relative(int step)
          Moves the Cursor step positions within the underlying structure.
 void set(GraphElement e)
          Sets the GraphCursor to a new start element.
 void set(java.lang.Object bookmark)
          Sets the cursor to a bookmarked position.
 boolean valid()
          Checks if the Cursor's actual position is valid.
 
Methods inherited from class gishur.graph.core.GraphCursor
addFilter, edge, filter, isEdge, isNode, node, removeFilter, validElement
 
Methods inherited from class gishur.core.CursorAdapter
bottom, hasMoreElements, next, next, nextElement, prev, prev, set, top
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

set

public void set(GraphElement e)
Sets the GraphCursor to a new start element. This method should be overwritten properly. Otherwise a GraphException will be thrown.
Overrides:
set in class GraphCursor
Parameters:
e - the new GraphElement to set the cursor to

graph

public Graph graph()
Returns the Graph, on which the Cursor works.
Overrides:
graph in class GraphCursor
Returns:
the Graph, on which the Cursor works.

graphElement

public GraphElement graphElement()
Returns the element under the actual position as an GraphElement, if this is possible (i.e. the position is valid and points to an GraphElement.
Overrides:
graphElement in class GraphCursor
Returns:
the element on the actual position as an Edge

element

public java.lang.Object element()
Returns the element to which this Cursor points at the moment.
Returns:
the element "under" the Cursor

relative

public void relative(int step)
Moves the Cursor step positions within the underlying structure.
Parameters:
step - the number of elements to move

valid

public boolean valid()
Checks if the Cursor's actual position is valid.
Returns:
true, if the Cursor points to a valid position, and false otherwise

invalidate

public void invalidate()
Sets the Cursor to an invalid position.

length

public int length()
Returns the number of elements in the underlying structure of this Cursor.
Returns:
the number of elements in the underlying structure

getBookmark

public java.lang.Object getBookmark()
Returns a bookmark-object. The returned bookmark-object should not be used by other cursors than this!.
Overrides:
getBookmark in class CursorAdapter
Returns:
a bookmark-object.
See Also:
setBookmark

set

public void set(java.lang.Object bookmark)
Sets the cursor to a bookmarked position. The bookmark-object should be created by this cursor!
Overrides:
set in class CursorAdapter
Parameters:
bookmark - a bookmark-object
See Also:
getBookmark()