01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: * (C) 2002, Refractions Reserach Inc.
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation;
10: * version 2.1 of the License.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: */
17: package org.geotools.graph.traverse.basic;
18:
19: import org.geotools.graph.structure.GraphVisitor;
20: import org.geotools.graph.structure.Graphable;
21: import org.geotools.graph.traverse.GraphTraversal;
22: import org.geotools.graph.traverse.GraphWalker;
23:
24: /**
25: * A simple implementation of GraphWalker that decorates a GraphVisitor.
26: *
27: * @author Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
28: *
29: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/graph/src/main/java/org/geotools/graph/traverse/basic/SimpleGraphWalker.java $
30: */
31: public class SimpleGraphWalker implements GraphWalker {
32:
33: /** Underlying visitor */
34: private GraphVisitor m_visitor;
35:
36: /**
37: * Creates a GraphWalker from a preexising GraphVisitor.
38: *
39: * @param visitor The visitor to decorate
40: */
41: public SimpleGraphWalker(GraphVisitor visitor) {
42: m_visitor = visitor;
43: }
44:
45: /**
46: * Returns the underlying visitor.
47: *
48: * @return The visitor being decorated by the walker.
49: */
50: public GraphVisitor getVistor() {
51: return (m_visitor);
52: }
53:
54: /**
55: * Sets the underlying visitor.
56: *
57: * @param visitor The visitor to be decorated by the walker.
58: */
59: public void setVisitor(GraphVisitor visitor) {
60: m_visitor = visitor;
61: }
62:
63: /**
64: * Defers to the underlying visitor.
65: *
66: * @see GraphWalker#visit(Graphable, GraphTraversal)
67: */
68: public int visit(Graphable element, GraphTraversal traversal) {
69: return (m_visitor.visit(element));
70: }
71:
72: /**
73: * Does nothing.
74: *
75: * @see GraphWalker#finish()
76: */
77: public void finish() {
78: }
79: }
|