Package net.ggtools.grand.filters
Class AbstractGraphFilter
- java.lang.Object
-
- net.ggtools.grand.filters.AbstractGraphFilter
-
- All Implemented Interfaces:
GraphFilter,GraphConsumer,GraphProducer
- Direct Known Subclasses:
GraphWalkFilter,IsolatedNodeFilter,MissingNodeFilter,NodeRemoverFilter,PrefixedNodeFilter
public abstract class AbstractGraphFilter extends Object implements GraphFilter
- Author:
- Christophe Labouisse
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractGraphFilter()Creates an anonymous filter.protectedAbstractGraphFilter(String name)Creates a named filter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Collection<Node>getFilteredNodes()Get the nodes from the graph that pass the filter.GraphgetGraph()Method getGraph.protected GraphProducergetGraphProducer()Returns the current graph producer.StringgetName()Method getName.protected GraphgetProducersGraph()Returns the graph from the current producer.voidsetProducer(GraphProducer producer)Method setProducer.
-
-
-
Field Detail
-
name
protected final String name
Field name.
-
-
Constructor Detail
-
AbstractGraphFilter
protected AbstractGraphFilter()
Creates an anonymous filter.
-
AbstractGraphFilter
protected AbstractGraphFilter(String name)
Creates a named filter.- Parameters:
name- String
-
-
Method Detail
-
getGraph
public final Graph getGraph() throws GrandException
Method getGraph.- Specified by:
getGraphin interfaceGraphProducer- Returns:
- Graph
- Throws:
GrandException- if an error occurs in getNodes()/getFilteredNodes()- See Also:
GraphProducer.getGraph()
-
setProducer
public final void setProducer(GraphProducer producer)
Method setProducer.- Specified by:
setProducerin interfaceGraphConsumer- Parameters:
producer- GraphProducer- See Also:
GraphConsumer.setProducer(net.ggtools.grand.graph.GraphProducer)
-
getName
public final String getName()
Method getName.- Specified by:
getNamein interfaceGraphFilter- Returns:
- String
- See Also:
GraphFilter.getName()
-
getFilteredNodes
protected abstract Collection<Node> 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 returnUnsupportedOperationExceptionon 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.
-
-