net.ggtools.grand.filters
Class AbstractGraphFilter

java.lang.Object
  extended by net.ggtools.grand.filters.AbstractGraphFilter
All Implemented Interfaces:
GraphFilter, GraphConsumer, GraphProducer
Direct Known Subclasses:
GraphWalkFilter, IsolatedNodeFilter, MissingNodeFilter, NodeRemoverFilter

public abstract class AbstractGraphFilter
extends java.lang.Object
implements GraphFilter

Author:
Christophe Labouisse

Field Summary
protected  java.lang.String name
           
 
Constructor Summary
AbstractGraphFilter()
          Creates an anonymous filter.
AbstractGraphFilter(java.lang.String name)
          Creates a named filter.
 
Method Summary
protected abstract  java.util.Collection getFilteredNodes()
          Get the nodes from the graph that pass the filter.
 Graph getGraph()
          Ask the producer to create a graph.
protected  GraphProducer getGraphProducer()
          Returns the current graph producer.
 java.lang.String getName()
          Get the filter's name.
protected  Graph getProducersGraph()
          Returns the graph from the current producer.
 void setProducer(GraphProducer producer)
          Set the graph producer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Constructor Detail

AbstractGraphFilter

public AbstractGraphFilter()
Creates an anonymous filter.


AbstractGraphFilter

public AbstractGraphFilter(java.lang.String name)
Creates a named filter.

Parameters:
name -
Method Detail

getGraph

public Graph getGraph()
               throws GrandException
Description copied from interface: GraphProducer
Ask the producer to create a graph. The created graph can be modified by the caller object.

Specified by:
getGraph in interface GraphProducer
Returns:
new graph.
Throws:
GrandException - is an error occurs contructing the graph.

setProducer

public void setProducer(GraphProducer producer)
Description copied from interface: GraphConsumer
Set the graph producer. Such a producer will be called whenever the consumer needs a graph.

Specified by:
setProducer in interface GraphConsumer
Parameters:
producer - the producer to get the graph from.

getName

public java.lang.String getName()
Description copied from interface: GraphFilter
Get the filter's name. Filter naming is just a service for backends and as no impact on the actual filter processing.

Specified by:
getName in interface GraphFilter
Returns:
the filter's name

getFilteredNodes

protected abstract java.util.Collection getFilteredNodes()
                                                  throws GrandException
Get the nodes from the graph that pass the filter. This method should not alter the input graph. The returned collection may be read only and return UnsupportedOperationExceptionon modification methods.

Returns:
a collection of nodes.
Throws:
GrandException - if the filtering cannot be done

getGraphProducer

protected final GraphProducer getGraphProducer()
Returns the current graph producer.

Returns:
graph producer.

getProducersGraph

protected final Graph getProducersGraph()
                                 throws GrandException
Returns the graph from the current producer. This method is intended to prevent calling several time the producer to get a graph.

Returns:
current graph.
Throws:
GrandException - if something goes wrong.


Copyright © 2004-2005 ggTools. All Rights Reserved.