|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.onemind.commons.java.pattern.DynamicVisitor
An abstract implementation of visitor that is extensible for handling different kind of object nodes by simple adding more methods. The subclass need to set up for handlers of node type in the constructor.
Nested Class Summary | |
protected class |
DynamicVisitor.MethodNodeHandler
A handler use reflection to invoke given method for visiting |
static interface |
DynamicVisitor.NodeHandler
The handler |
Constructor Summary | |
DynamicVisitor()
Constructor |
Method Summary | |
protected void |
addMethodNodeHandler(java.lang.Class type,
java.lang.String methodName)
Add MethodNodeHandler using the given method name throws RuntimeException if the method cannot be found. |
protected void |
addNodeHandler(java.lang.Class type,
DynamicVisitor.NodeHandler handler)
Add node handler |
protected abstract void |
initNodeHandlers()
Initialize the node handlers |
java.lang.Object |
visit(java.lang.Object obj,
java.lang.Object[] args)
The object |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DynamicVisitor()
Method Detail |
protected abstract void initNodeHandlers()
protected void addNodeHandler(java.lang.Class type, DynamicVisitor.NodeHandler handler)
type
- the typehandler
- the handlerprotected void addMethodNodeHandler(java.lang.Class type, java.lang.String methodName)
type
- the typemethodName
- the method namepublic java.lang.Object visit(java.lang.Object obj, java.lang.Object[] args) throws java.lang.Exception
obj
- the objectargs
- the arguments
java.lang.Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |