|
GXPARSE hosted by | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ca.gorman.xml.parse.util.NamespacePackageMapper<T>
public class NamespacePackageMapper<T extends Parser>
In Development
Maps each of one or more XML namespaces to a Java package and maps XML
elements in each namespace to elment handlers
in the
corresponding package.
Each namespace is specified by a
NamespaceEntry
that
has the namespace identifier, the corresponding Java package, and
information on how to map the names of each element in the namespace to the
class name of corresponding element handler
. Each
element handler class must have a public constructor that takes no
parameters.
Warning
PackageNamespaceElementMapper
uses Java reflection to identify
and load element handlers at runtime. Generic type parameters cannot be
checked at run time. A handler that is not an ElementListener
will throw a ClassCastException
from the
doElement
method when it is
invoked by the doElement
method. A handler that is an
ElementListener
, but is not the correct generic type, will be
invoked as if it were a valid handler, and will cause an exception that has
a much less obvious connection to the actual problem.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface ca.gorman.xml.parse.NamespaceMapper |
---|
NamespaceMapper.NamespaceMapException |
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 | |
---|---|
NamespacePackageMapper(ElementListener<T> defaultElementHandler,
Iterable<NamespaceMapper<T>> mappers)
Construct an element mapper to invoke element handlers in the Java package that corresponds to the element namespace, specifying a default element handler for elements outside any of the namespaces. |
|
NamespacePackageMapper(ElementListener<T> defaultElementHandler,
Map<String,ElementMapper<T>> namespaceMap)
Construct an element mapper to invoke element handlers in the Java package that corresponds to the element namespace, specifying a default element handler for elements outside any of the namespaces. |
Method Summary | |
---|---|
void |
doElement(T parser,
CurrentElement element)
Receive a request to handle a element that is
being parsed, and invoke the appropriate element handler for that
element. |
Iterator<String> |
iterator()
Return an iterator for the namespace URIs that are mapped by the NamespaceMapper . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NamespacePackageMapper(ElementListener<T> defaultElementHandler, Map<String,ElementMapper<T>> namespaceMap)
Construct an element mapper to invoke element handlers in the Java package that corresponds to the element namespace, specifying a default element handler for elements outside any of the namespaces.
defaultElementHandler
- the element handler to be invoked when no
handler is found.namespaceMap
- a Map
of namespaces and their
corresponding ElementMapper
s that invoke the
element handlers on elements in each namespace.
NullPointerException
- if any parameter is null
NullPointerException
- if any key or value in
namespaceMap
is null
NamespaceMapException
- if the
namespaceMap
maps the same namespace name to two
ElementMapper
s that are not equal to
each other.public NamespacePackageMapper(ElementListener<T> defaultElementHandler, Iterable<NamespaceMapper<T>> mappers)
Construct an element mapper to invoke element handlers in the Java package that corresponds to the element namespace, specifying a default element handler for elements outside any of the namespaces.
defaultElementHandler
- the element handler to be invoked when no
handler is found.mappers
- an Iterable
that can iterate over the
NamespaceMapper
s that invoke the element handlers
on elements in each namespace.
NullPointerException
- if any parameter is null
NullPointerException
- if mappers
returns a null
Iterator
or the Iterator
returns a
null NamespaceMapper
NullPointerException
- if any NamespaceMapper
returns
a null iterator
NullPointerException
- if an
iterator
from any
NamespaceMapper
returns a null namespace name.
NamespaceMapException
- if the
mapperIterator
produces two different
NamespaceMapper
s that identify
themselves as mappers for the same namespace 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 element handler for that
element.
The element handler will be equivalent to an
ElementListener
.
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
- when the exception has been thrown from a
Listener
method.
IOException
- when an input or output error occurspublic Iterator<String> iterator()
NamespaceMapper
Return an iterator for the namespace URIs that are mapped by the
NamespaceMapper
.
iterator
in interface NamespaceMapper<T extends Parser>
iterator
in interface Iterable<String>
|
GXPARSE download | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |