edu.neu.ccs.demeter.dj
Class Visitor

java.lang.Object
  |
  +--edu.neu.ccs.demeter.dj.Visitor

public abstract class Visitor
extends Object


Constructor Summary
Visitor()
           
 
Method Summary
 void after(Object obj, Class cl)
          This method is called when a traversal has finished traversing obj in the object graph with cl as the token.
 void after(Object source, Class sourceClass, EdgeI edge, Object target, Class targetClass)
          This method is called when a traversal has finished traversing an edge in the object graph from source to target corresponding to the class graph edge edge from sourceClass to targetClass.
 void before(Object obj, Class cl)
          This method is called when a traversal is about to traverse obj in the object graph with cl as the token.
 void before(Object source, Class sourceClass, EdgeI edge, Object target, Class targetClass)
          This method is called when a traversal is about to traverse an edge in the object graph from source to target corresponding to the class graph edge edge from sourceClass to targetClass.
 void finish()
          This method is called when a traversal ends, after all nodes have been visited.
 Method getMethod(String name, Class[] paramTypes)
          Return the method on this class named name with parameter types paramTypes, or null if there is no such method.
 Object getReturnValue()
          This method is called on the first visitor (i.e. v[0]) after finish() has been called on all visitors in a traversal, and its return value is returned as the return value of the traversal.
protected  Method getUnmemoizedMethod(String name, Class[] paramTypes)
          Return the method on this class named name with parameter types paramTypes, or null if there is no such method.
 void invokeMethod(String name, Object[] args, Class[] paramTypes)
          Invoke the method on this class named name with parameter types paramTypes, passing args as the arguments.
 void invokeMethod(String name, Object obj, Class cl)
          Invoke the method on this class named name with one parameter of type cl, passing obj as the argument.
 void invokeMethods(String name, Object source, Class sourceClass, EdgeI edge, Object target, Class targetClass)
          Invoke the methods on this class whose names start with name and whose signatures correspond to the class graph edge edge, passing source and target (and the edge label, if it's a construction edge) as arguments.
 void start()
          This method is called when a traversal begins, before any nodes are visited.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Visitor

public Visitor()
Method Detail

start

public void start()
This method is called when a traversal begins, before any nodes are visited. The default behavior is to do nothing.


finish

public void finish()
This method is called when a traversal ends, after all nodes have been visited. The default behavior is to do nothing.


getReturnValue

public Object getReturnValue()
This method is called on the first visitor (i.e. v[0]) after finish() has been called on all visitors in a traversal, and its return value is returned as the return value of the traversal. The default behavior is to do return null.


before

public void before(Object obj,
                   Class cl)
This method is called when a traversal is about to traverse obj in the object graph with cl as the token. Note that the same object might be passed to this method multiple times, once per class in its inheritance hierarchy. The default behavior is to call invokeMethod("before", obj, cl).


after

public void after(Object obj,
                  Class cl)
This method is called when a traversal has finished traversing obj in the object graph with cl as the token. Note that the same object might be passed to this method multiple times, once per class in its inheritance hierarchy. The default behavior is to call invokeMethod("after", obj, cl).


before

public void before(Object source,
                   Class sourceClass,
                   EdgeI edge,
                   Object target,
                   Class targetClass)
This method is called when a traversal is about to traverse an edge in the object graph from source to target corresponding to the class graph edge edge from sourceClass to targetClass. The default behavior is to call invokeMethods("before", source, sourceClass, edge, target, targetClass).


after

public void after(Object source,
                  Class sourceClass,
                  EdgeI edge,
                  Object target,
                  Class targetClass)
This method is called when a traversal has finished traversing an edge in the object graph from source to target corresponding to the class graph edge edge from sourceClass to targetClass. The default behavior is to call invokeMethods("before", source, sourceClass, edge, target, targetClass).


invokeMethods

public void invokeMethods(String name,
                          Object source,
                          Class sourceClass,
                          EdgeI edge,
                          Object target,
                          Class targetClass)
Invoke the methods on this class whose names start with name and whose signatures correspond to the class graph edge edge, passing source and target (and the edge label, if it's a construction edge) as arguments.

For a construction edge, the following signatures are matched, in order:

  1. n_l(S, T)
  2. n_l(S, Object)
  3. n_l(Object, T)
  4. n_l(Object, Object)
  5. n(S, String, T)
  6. n(S, String, Object)
  7. n(Object, String, T)
  8. n(Object, String, Object)
where n is the value of name, S is the source type of the edge, l is the label of the edge, and T is the target type of the edge. For example, if an edge ->Employee,salary,Currency is traversed, then first the visitor method before_salary(Employee,Currency) is invoked, if it exists, followed by before_salary(Employee,Object), etc.


invokeMethod

public void invokeMethod(String name,
                         Object obj,
                         Class cl)
Invoke the method on this class named name with one parameter of type cl, passing obj as the argument.


invokeMethod

public void invokeMethod(String name,
                         Object[] args,
                         Class[] paramTypes)
Invoke the method on this class named name with parameter types paramTypes, passing args as the arguments.


getMethod

public Method getMethod(String name,
                        Class[] paramTypes)
Return the method on this class named name with parameter types paramTypes, or null if there is no such method.


getUnmemoizedMethod

protected Method getUnmemoizedMethod(String name,
                                     Class[] paramTypes)
Return the method on this class named name with parameter types paramTypes, or null if there is no such method.