| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public abstract class AbstractUnmarshallerImpl extends Object implements Unmarshaller
Partial default Unmarshaller implementation.
This class provides a partial default implementation for the {@link javax.xml.bind.Unmarshaller}interface.
A JAXB Provider has to implement five methods (getUnmarshallerHandler, unmarshal(Node), unmarshal(XMLReader,InputSource), unmarshal(XMLStreamReader), and unmarshal(XMLEventReader).
Field Summary | |
---|---|
protected boolean |
validating
whether or not the unmarshaller will validate |
Constructor Summary | |
---|---|
|
Method Summary | |
---|---|
protected UnmarshalException |
Creates an UnmarshalException from a SAXException. |
XmlAdapter |
getAdapter(Class type) |
AttachmentUnmarshaller |
|
ValidationEventHandler |
Return the current event handler or the default event handler if one hasn't been set. |
Unmarshaller.Listener |
|
Object |
getProperty(String name) Default implementation of the getProperty method always throws PropertyException since there are no required properties. |
Schema |
|
protected XMLReader |
Obtains a configured XMLReader. |
boolean |
Indicates whether or not the Unmarshaller is configured to validate during unmarshal operations. |
void |
setAdapter(Class type, XmlAdapter adapter) |
void |
setAdapter(XmlAdapter adapter) |
void |
|
void |
setEventHandler(ValidationEventHandler handler) Allow an application to register a validation event handler. |
void |
setListener(Unmarshaller.Listener listener) |
void |
setProperty(String name, Object value) Default implementation of the setProperty method always throws PropertyException since there are no required properties. |
void |
|
void |
setValidating(boolean validating) Specifies whether or not the Unmarshaller should validate during unmarshal operations. |
Object |
|
Object |
unmarshal(InputSource source) |
Object |
unmarshal(InputStream is) |
JAXBElement |
|
Object |
|
Object |
|
JAXBElement |
|
Object |
|
Object |
unmarshal(XMLEventReader reader) |
JAXBElement |
unmarshal(XMLEventReader reader, Class expectedType) |
protected abstract Object |
unmarshal(XMLReader reader, InputSource source) Unmarshals an object by using the specified XMLReader and the InputSource. |
Object |
unmarshal(XMLStreamReader reader) |
JAXBElement |
unmarshal(XMLStreamReader reader, Class expectedType) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean validating
Constructor Detail |
---|
public AbstractUnmarshallerImpl()
Method Detail |
---|
protected UnmarshalException createUnmarshalException(SAXException e)
When a provider-implemented ContentHandler wants to throw a JAXBException, it needs to wrap the exception by a SAXException. If the unmarshaller implementation blindly wrap SAXException by JAXBException, such an exception will be a JAXBException wrapped by a SAXException wrapped by another JAXBException. This is silly.
This method checks the nested exception of SAXException and reduce those excessive wrapping.
e
public XmlAdapter getAdapter(Class type)
type
public AttachmentUnmarshaller getAttachmentUnmarshaller()
public ValidationEventHandler getEventHandler() throws JAXBException
JAXBException
- if an error was encountered while getting the
current event handlerpublic Unmarshaller.Listener getListener()
public Object getProperty(String name) throws PropertyException
name
PropertyException
public Schema getSchema()
protected XMLReader getXMLReader() throws JAXBException
JAXBException
public boolean isValidating() throws JAXBException
Note: I named this method isValidating() to stay in-line with JAXP, as opposed to naming it getValidating().
JAXBException
- if an error occurs while retrieving the validating
flagpublic void setAdapter(Class type, XmlAdapter adapter)
type
adapter
public void setAdapter(XmlAdapter adapter)
adapter
public void setAttachmentUnmarshaller(AttachmentUnmarshaller au)
au
public void setEventHandler(ValidationEventHandler handler) throws JAXBException
The validation event handler will be called by the JAXB Provider if any validation errors are encountered during calls to any of the unmarshal methods. If the client application does not register a validation event handler before invoking the unmarshal methods, then all validation events will be silently ignored and may result in unexpected behaviour.
handler
- the validation event handlerJAXBException
- if an error was encountered while setting the
event handlerpublic void setListener(Unmarshaller.Listener listener)
listener
public void setProperty(String name, Object value) throws PropertyException
name
value
PropertyException
public void setSchema(Schema schema)
schema
public void setValidating(boolean validating) throws JAXBException
This method may only be invoked before or after calling one of the unmarshal methods.
validating
- true if the Unmarshaller should validate during
unmarshal, false otherwiseJAXBException
- if an error occurred while enabling or disabling
validation at unmarshal timepublic final Object unmarshal(File f) throws JAXBException
f
JAXBException
public final Object unmarshal(InputSource source) throws JAXBException
source
JAXBException
public final Object unmarshal(InputStream is) throws JAXBException
is
JAXBException
public JAXBElement unmarshal(Node node, Class expectedType) throws JAXBException
node
expectedType
JAXBException
public final Object unmarshal(Reader reader) throws JAXBException
reader
JAXBException
public Object unmarshal(Source source) throws JAXBException
source
JAXBException
public JAXBElement unmarshal(Source source, Class expectedType) throws JAXBException
source
expectedType
JAXBException
public final Object unmarshal(URL url) throws JAXBException
url
JAXBException
public Object unmarshal(XMLEventReader reader) throws JAXBException
reader
JAXBException
public JAXBElement unmarshal(XMLEventReader reader, Class expectedType) throws JAXBException
reader
expectedType
JAXBException
protected abstract Object unmarshal(XMLReader reader, InputSource source) throws JAXBException
reader
source
JAXBException
public Object unmarshal(XMLStreamReader reader) throws JAXBException
reader
JAXBException
public JAXBElement unmarshal(XMLStreamReader reader, Class expectedType) throws JAXBException
reader
expectedType
JAXBException
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |