net.sf.swan.xml.input.reflect
Class ReflectAdapter
java.lang.Object
|
+--net.sf.swan.xml.input.event.ContextAdapter
|
+--net.sf.swan.xml.input.reflect.ReflectAdapter
- All Implemented Interfaces:
- ContextListener
- Direct Known Subclasses:
- BeanAdapter
- public class ReflectAdapter
- extends ContextAdapter
Component that uses reflection to match up element events with
Java methods. Components may subclass this adapter, or this
class may be used directly to "wrap" other components and expose
their methods. Matching methods must have the same name as
the element's local name, and must have an appropriate signature
to receive the types of events of interest (one parameter of type
StartElementEvent
,
EndElementEvent
,
TextEvent
, or
ProcessingInstructionEvent
).
For example, if a subclass of this (or a component passed to
its constructor) has a method like the following:
public void form(StartElementEvent event);
it will be passed any start events for any elements with
the local name of "form". Whereas a method like the following:
public void title(TextEvent event);
would be passed the text content for any element with the
local name of "title". Note that the component would not need methods
for the start and end element events in order to receive the text event.
The component may simply implement methods for just those events of interest.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ReflectAdapter
public ReflectAdapter(java.lang.Object component)
ReflectAdapter
protected ReflectAdapter()
startElement
public void startElement(StartElementEvent event)
throws EventContextException
- Overrides:
startElement
in class ContextAdapter
endElement
public void endElement(EndElementEvent event)
throws EventContextException
- Overrides:
endElement
in class ContextAdapter
text
public void text(TextEvent event)
throws EventContextException
- Overrides:
text
in class ContextAdapter
processingInstruction
public void processingInstruction(ProcessingInstructionEvent event)
throws EventContextException
- Overrides:
processingInstruction
in class ContextAdapter