gishur.graph.core
Class GraphCursor

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

public abstract class GraphCursor
extends CursorAdapter

The basic Cursor class to traverse arbitrary Graphs. The class inherits the abstract methods of CursorAdapter and does not define them, so it is abstract. But there is further Graph-specific functionality defined, like direct access to Edges and Nodes of the underlying Graph and for the use of Filters to define special parts of sets of elements of the underlying Graph as valid positions.

Version:
1.1
Author:
Thomas Wolf & Christoph Sachse

Constructor Summary
GraphCursor()
           
 
Method Summary
 void addFilter(Filter f)
          Adds a Filter to the Filter-pipeline so that the move of the Cursor will furthermore happen on only these elments which are not filtered out by f and the other registered Filters.
 Edge edge()
          Returns the element under the actual position as an Edge, if this is possible (i.e. the position is valid and points to an Edge.
 Filter filter()
          Returns the first Filter in the Filter pipeline of this GraphCursor.
abstract  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.
 boolean isEdge()
          Checks if the cursor points to an Edge at the moment.
 boolean isNode()
          Checks if the cursor points to a Node at the moment.
 Node node()
          Returns the element under the actual position as a Node, if this is possible (i.e. the position is valid and points to a Node.
 void removeFilter(Filter f)
          Removes f from the Filter pipeline of this GraphCursor.
 void set(GraphElement e)
          Sets the GraphCursor to a new start element.
protected  boolean validElement(java.lang.Object obj)
          Returns true, if the given Object is not filtered-out by the Filter-pipeline.
 
Methods inherited from class gishur.core.CursorAdapter
bottom, getBookmark, hasMoreElements, next, next, nextElement, prev, prev, set, set, top
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gishur.core.Cursor
element, invalidate, length, relative, valid
 

Constructor Detail

GraphCursor

public GraphCursor()
Method Detail

graph

public abstract Graph graph()
Returns the Graph, on which the Cursor works.
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.
Returns:
the element on the actual position as an GraphElement

edge

public Edge edge()
Returns the element under the actual position as an Edge, if this is possible (i.e. the position is valid and points to an Edge.
Returns:
the element on the actual position as an Edge

node

public Node node()
Returns the element under the actual position as a Node, if this is possible (i.e. the position is valid and points to a Node.
Returns:
the element on the actual position as a Node

isEdge

public boolean isEdge()
Checks if the cursor points to an Edge at the moment.
Returns:
true if the cursor is set to an Edge, false otherwise

isNode

public boolean isNode()
Checks if the cursor points to a Node at the moment.
Returns:
true if the cursor is set to a Node, false otherwise

addFilter

public void addFilter(Filter f)
Adds a Filter to the Filter-pipeline so that the move of the Cursor will furthermore happen on only these elments which are not filtered out by f and the other registered Filters. If f==null nothing happens and the method returns.
Parameters:
f - the new Filter to add to the pipeline

removeFilter

public void removeFilter(Filter f)
Removes f from the Filter pipeline of this GraphCursor. If f==null or f is not part of the Filter pipe, the method returns effectiveless.
Parameters:
f - the Filter to remove

filter

public Filter filter()
Returns the first Filter in the Filter pipeline of this GraphCursor.
Returns:
the first Filter in the pipe

validElement

protected final boolean validElement(java.lang.Object obj)
Returns true, if the given Object is not filtered-out by the Filter-pipeline. This method is for internal use, in order to build GraphCursors, that use the supported filter-pipeline.
Parameters:
obj - the Object to be tested
Returns:
true, if the given Object is not filtered-out

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.
Parameters:
e - the new GraphElement to set the cursor to