|
GXPARSE hosted by |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.gorman.xml.parse.util.SimpleElementMapper<T>
public class SimpleElementMapper<T extends Parser>
Maps element names to Java method names and invokes the appropriate element method for each element.
This class gets the name of an XML element and transforms that name to a Java identitifier by:
$' character by the string
"$$
"
- checking each each of the other characters to see if they are allowed
in a Java identifier, and replacing the non-identifier characters by
the characters
$xxxx
where xxxx
is the
four-digit lower-case hexadecimal Unicode number of the character.
- prepending a specified prefix (which can be the empty String).
If a method can be found with the constructed name, and the method takes
a single parameter of type CurrentElement
, that
method is invoked on the element. Otherwise, a specified default method is
invoked on the element.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface ca.gorman.xml.parse.ElementMapper |
---|
ElementMapper.InvalidHandlerException, ElementMapper.NotFoundException |
Field Summary |
---|
Fields inherited from interface ca.gorman.xml.parse.ElementMapper |
---|
ESCAPE_CENT, ESCAPE_CURRENCY, ESCAPE_DOLLAR, ESCAPE_POUND, ESCAPE_YEN |
Constructor Summary | |
---|---|
SimpleElementMapper(String methodNamePrefix,
Object defaultClassInstance,
String defaultMethodName)
Construct an element mapper to access public element methods in a defaultClassInstance . |
Method Summary | |
---|---|
void |
doElement(T parser,
CurrentElement element)
Receive a request to handle a element that is
being parsed, and invoke the appropriate public element method
for that element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleElementMapper(String methodNamePrefix, Object defaultClassInstance, String defaultMethodName) throws NoSuchMethodException, IllegalAccessException
Construct an element mapper to access public element methods in
a defaultClassInstance
. When an element name cannot be
mapped to the name of a public element method in the
defaultClassInstance
, public method
defaultMethodName
will invoked on the element.
Warning: Element method names must be public and non-static. Static methods will cause an exception. Private and protected methods will be treated as if they do not exist.
Note:The constructor makes a check to ensure that a non-empty
methodNamePrefix
is not used as a prefix in any static or
non-public method.
methodNamePrefix
- String, which can be empty, used as the prefix
to the name of every public element method except the
public default methoddefaultClassInstance
- the class instance that contains the
default element method and all other element methods.defaultMethodName
- the name of the public default element
method
IllegalAccessException
- if the default method is static or if
methodNamePrefix
is a non-empty prefix and the
name of any static or non-public method in
defaultClassInstance
begins with the
methodNamePrefix
NoSuchMethodException
- when the named default method does not
exist in the default class instance, or exists but is not
public
NullPointerException
- if any parameter is null
IllegalArgumentException
- if methodNamePrefix
is
not empty and is also invalid as a Java identifier.Method Detail |
---|
public void doElement(T parser, CurrentElement element) throws ListenerException, IOException
Receive a request to handle a element
that is
being parsed, and invoke the appropriate public element method
for that element.
Warning: Element method names must be public and non-static. Static methods will cause an exception. Private and protected methods will be treated as if they do not exist, and the default element method will be invoked instead of any private or protected method
doElement
in interface ElementListener<T extends Parser>
doElement
in interface ElementMapper<T extends Parser>
parser
- The Parser
that invoked this methodelement
- CurrentElement
instance with a
content handler
to parse the centent of the element.
ListenerException
- if the element method throws
ListenerException
IOException
- if the element method throws
IOException
ListenerRuntimeException
- with IllegalAccessException
as the cause if the element method is
static
RuntimeException
- if the element method throws
RuntimeException
NullPointerException
- if element
is null
|
GXPARSE download | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |