|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.iotabits.revisitor.BasicReflectiveVisitor
This class an abstract class that implements the Visitor pattern via reflection. The visit method will look for a public method in the class that matches most closely the types of the arguments passed to it.
Subclasses will need to override the implementation of the 'body' methods that handle visiting when no other methods are found. By default, the body methods (named defaultVisit(...)) throw a ReflectiveDispatchException. Subclasses should implement "visit(arg)" methods for the types of objects that are going to be encountered.
Field Summary | |
static java.lang.String |
VISIT_METHOD_NAME
|
Constructor Summary | |
BasicReflectiveVisitor()
|
Method Summary | |
protected void |
callAccept(java.lang.Object visiting)
Override this if you want the revisitor to control traversal. |
protected void |
defaultVisit(java.lang.Object visiting)
Override this to provide different default behavior for the default visit method. |
void |
dispatchToVisit(java.lang.Object visiting)
Find a public method that most closely matches the given types and call it. |
protected java.lang.reflect.Method |
findMethod(java.lang.Object visiting)
Look through the class and find a method that matches the classes of the parameters. |
void |
visit(java.lang.Object visiting)
This implements the default visit method, simply calling defaultVisit(Object):void. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String VISIT_METHOD_NAME
Constructor Detail |
public BasicReflectiveVisitor()
Method Detail |
protected java.lang.reflect.Method findMethod(java.lang.Object visiting) throws java.lang.NoSuchMethodException
java.lang.NoSuchMethodException
protected void callAccept(java.lang.Object visiting) throws java.lang.Exception
visiting
-
java.lang.Exception
protected void defaultVisit(java.lang.Object visiting) throws java.lang.Exception
visiting
-
java.lang.Exception
public final void dispatchToVisit(java.lang.Object visiting) throws java.lang.Exception
dispatchToVisit
in interface iReflectiveVisitor
visiting
-
java.lang.Exception
- The visit method threw an exception.public final void visit(java.lang.Object visiting) throws java.lang.Exception
visit
in interface iReflectiveVisitor
visiting
- The object being visited.
java.lang.Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |