|
JAXB v0.21 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--javax.xml.bind.Dispatcher
A dispatcher is used to map element names to class names, and to initiate the unmarshalling process.
A dispatcher contains two maps, an element-name map and a class map. The element-name map maps element names to marshallable-object classes; the class map maps marshallable-object classes to user-defined subclasses.
New mappings may be registered in each map. Each map may also be frozen in order to guard against unwanted concurrent modification. The unmarshalling process always freezes both maps of the dispatcher that it uses.
MarshallableObject,
Unmarshaller,
Validator,
XMLScanner| Constructor Summary | |
Dispatcher()
Constructs a new, empty dispatcher. |
|
| Method Summary | |
void |
freezeClassMap()
Freezes this dispatcher's class map. |
void |
freezeElementNameMap()
Freezes this dispatcher's element-name map. |
Class |
lookup(Class mobClass)
Applies the class map to the given marshallable-object class. |
Class |
lookup(String elementName)
Determines the class to be used when unmarshalling the given element name. |
void |
register(Class mobClass,
Class userClass)
Registers the given user class so that it will be used in place of the given schema-derived marshallable-object class during unmarshalling. |
void |
register(String elementName,
Class elementClass)
Registers the given element name so that it will be unmarshalled into an instance of the given element class. |
RootElement |
unmarshal(InputStream in)
Unmarshals and validates a content tree from the given input stream. |
RootElement |
unmarshal(XMLScanner xs)
Unmarshals and validates a content tree using the given scanner. |
RootElement |
unmarshal(XMLScanner xs,
Class rootClass)
Unmarshals and validates a content tree using the given scanner and root element class. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Dispatcher()
| Method Detail |
public void freezeClassMap()
IllegalStateException being thrown.public void freezeElementNameMap()
IllegalStateException
being thrown.public Class lookup(Class mobClass)
public Class lookup(String elementName)
throws UnrecognizedElementNameException
elementName - The non-colonized element name being looked up;
must not be the empty stringUnrecognizedElementNameException - If no class for the given element name can be found
public void register(Class mobClass,
Class userClass)
This method is provided primarily so that user subclasses of schema-derived element classes may be defined and used.
mobClass - A schema-derived subclass of MarshallableObject for
which no class mapping has yet been defineduserClass - The user-defined subclass of mobClass, for which no
class mapping has been defined, to be used in place of that
class during unmarshallingIllegalStateException - If this dispatcher's class map is frozen
public void register(String elementName,
Class elementClass)
elementName - The non-colonized element name being registered;
must not be the empty stringelementClass - The class to be used to unmarshal elements with the given name;
must extend MarshallableObject and implement the Element interfaceElementNameRegisteredException - If the element name has already been registeredIllegalStateException - If this dispatcher's element-name map is frozen
public RootElement unmarshal(InputStream in)
throws UnmarshalException
unmarshal(XMLScanner.open(java.io.InputStream)(in))
in - The input stream from which data will be unmarshalledScanIOException - If an I/O error occursScanException - If the input document is not well-formedValidationException - If the input document violates the constraints
expressed in the source schema, or some other
validation error is detected
public RootElement unmarshal(XMLScanner xs)
throws UnmarshalException
lookup method, and then invokes the unmarshal(XMLScanner, Class) method, passing the scanner and the
class.xs - The scanner from which data will be unmarshalledInvalidContentException - If the scanner is not currently positioned at a start tag,
or if some other invalid content is later encounteredUnrecognizedElementNameException - If the element name in the current start tag is not registered,
or if some other unrecognized element name is encounteredInvalidAttributeException - If an attribute that is not permitted for the current element
is scannedScanIOException - If an I/O error occursScanException - If the input document is not well-formedValidationException - If the input document violates the constraints
expressed in the source schema, or some other
validation error is detected
public RootElement unmarshal(XMLScanner xs,
Class rootClass)
throws UnmarshalException
Unmarshaller with this dispatcher
and the given scanner. It then uses the unmarshaller to unmarshal an
instance of the given class and validate the resulting content tree.
This method closes the given scanner when it terminates, whether
normally or by throwing an exception.xs - The scanner from which data will be unmarshalledrootClass - The root marshallable-object class to be instantiatedInvalidContentException - If the scanner is not currently positioned at a start tag,
or if some other invalid content is later encounteredUnrecognizedElementNameException - If the element name in the current start tag is not the element
name handled by the given class, or if some other unrecognized
element name is later encounteredInvalidAttributeException - If an attribute that is not permitted for the current element
is scannedScanIOException - If an I/O error occursScanException - If the input document is not well-formedValidationException - If the input document violates the constraints
expressed in the source schema, or some other
validation error is detected
|
JAXB v0.21 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Copyright © 2001 by Sun Microsystems, Inc., 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.