fr.umlv.tatoo.runtime.ast
Class NodeVisitor<R,P,D,E extends Throwable>

java.lang.Object
  extended by fr.umlv.tatoo.runtime.ast.NodeVisitor<R,P,D,E>
Type Parameters:
R - return type of the visitor methods.
P - parameter type of the visitor methods.
D - type of the data associated with the node hold by the visitor.
E - type of the exception throws by the visitor, if no exception thrown, E could be typed using a RuntimeException.

public abstract class NodeVisitor<R,P,D,E extends Throwable>
extends Object

Abstract implementation of a visitor on the AST node. This class provide a mechanism to access to the data associated with a node. The methods getData(Node) and setData(node,data) get/set the data of a specified node.

Author:
Remi

Constructor Summary
protected NodeVisitor()
          Creates a visitor with an hashmap to store data associated to each node.
protected NodeVisitor(Map<Node,D> dataMap)
          Creates a visitor that use the argument as map to store data associated with a node.
 
Method Summary
protected  D getData(Node node)
          Returns the data associated to a node.
 Map<Node,D> getDataMap()
          Returns the map that contains the data for each node.
protected  D setData(Node node, D data)
          Set the data associated to a node and returns the old value.
protected  R visit(Node node, P param)
          Defined a visit method called by default if no visit method is overridden.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeVisitor

protected NodeVisitor()
Creates a visitor with an hashmap to store data associated to each node.


NodeVisitor

protected NodeVisitor(Map<Node,D> dataMap)
Creates a visitor that use the argument as map to store data associated with a node.

Parameters:
dataMap -
Method Detail

getDataMap

public Map<Node,D> getDataMap()
Returns the map that contains the data for each node.

Returns:
the map containing couples node, data.

getData

protected D getData(Node node)
Returns the data associated to a node.

Parameters:
node - the node.
Returns:
the data associated to the node.
See Also:
getDataMap()

setData

protected D setData(Node node,
                    D data)
Set the data associated to a node and returns the old value.

Parameters:
node - the node.
data - the new data associated with the node.
Returns:
the old data associated with the node.

visit

protected R visit(Node node,
                  P param)
           throws E extends Throwable,
                  UnsupportedOperationException
Defined a visit method called by default if no visit method is overridden. The current implementation throws an UnsupportedOperationException

Parameters:
node -
param -
Returns:
no returns from that method.
Throws:
E - this exception is never thrown.
UnsupportedOperationException - always
E extends Throwable