Class UnmarshallerImpl
- java.lang.Object
-
- javax.xml.bind.helpers.AbstractUnmarshallerImpl
-
- com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,javax.xml.bind.Unmarshaller
,javax.xml.bind.ValidationEventHandler
public final class UnmarshallerImpl extends javax.xml.bind.helpers.AbstractUnmarshallerImpl implements javax.xml.bind.ValidationEventHandler, java.io.Closeable
Default Unmarshaller implementation.This class can be extended by the generated code to provide type-safe unmarshall methods.
- Author:
- Kohsuke KAWAGUCHI
-
-
Field Summary
Fields Modifier and Type Field Description protected JAXBContextImpl
context
OwningJAXBContext
UnmarshallingContext
coordinator
static java.lang.String
FACTORY
-
Constructor Summary
Constructors Constructor Description UnmarshallerImpl(JAXBContextImpl context, AssociationMap assoc)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Must be called from same thread which created the UnmarshallerImpl instance.javax.xml.bind.UnmarshalException
createUnmarshalException(org.xml.sax.SAXException e)
XmlVisitor
createUnmarshallerHandler(InfosetScanner scanner, boolean inplace, JaxBeanInfo expectedType)
Creates and configures a new unmarshalling pipe line.protected void
finalize()
<A extends javax.xml.bind.annotation.adapters.XmlAdapter>
AgetAdapter(java.lang.Class<A> type)
javax.xml.bind.attachment.AttachmentUnmarshaller
getAttachmentUnmarshaller()
<T> JaxBeanInfo<T>
getBeanInfo(java.lang.Class<T> clazz)
UnmarshallingContext
getContext()
javax.xml.bind.ValidationEventHandler
getEventHandler()
javax.xml.bind.Unmarshaller.Listener
getListener()
java.lang.Object
getProperty(java.lang.String name)
javax.xml.validation.Schema
getSchema()
javax.xml.bind.UnmarshallerHandler
getUnmarshallerHandler()
protected org.xml.sax.XMLReader
getXMLReader()
Obtains a configured XMLReader.boolean
handleEvent(javax.xml.bind.ValidationEvent event)
Default error handling behavior forUnmarshaller
.boolean
hasEventHandler()
Returns true if an event handler is installed.boolean
isValidating()
Deprecated.since 2.0static boolean
needsInterning(org.xml.sax.XMLReader reader)
<A extends javax.xml.bind.annotation.adapters.XmlAdapter>
voidsetAdapter(java.lang.Class<A> type, A adapter)
void
setAttachmentUnmarshaller(javax.xml.bind.attachment.AttachmentUnmarshaller au)
void
setListener(javax.xml.bind.Unmarshaller.Listener listener)
void
setProperty(java.lang.String name, java.lang.Object value)
void
setSchema(javax.xml.validation.Schema schema)
void
setValidating(boolean validating)
Deprecated.since 2.0java.lang.Object
unmarshal(javax.xml.stream.XMLEventReader reader)
<T> javax.xml.bind.JAXBElement<T>
unmarshal(javax.xml.stream.XMLEventReader reader, java.lang.Class<T> expectedType)
java.lang.Object
unmarshal(javax.xml.stream.XMLStreamReader reader)
<T> javax.xml.bind.JAXBElement<T>
unmarshal(javax.xml.stream.XMLStreamReader reader, java.lang.Class<T> expectedType)
java.lang.Object
unmarshal(javax.xml.transform.sax.SAXSource source)
Deprecated.<T> javax.xml.bind.JAXBElement<T>
unmarshal(javax.xml.transform.Source source, java.lang.Class<T> expectedType)
java.lang.Object
unmarshal(org.w3c.dom.Node node)
<T> javax.xml.bind.JAXBElement<T>
unmarshal(org.w3c.dom.Node node, java.lang.Class<T> expectedType)
protected java.lang.Object
unmarshal(org.xml.sax.XMLReader reader, org.xml.sax.InputSource source)
protected <T> javax.xml.bind.JAXBElement<T>
unmarshal(org.xml.sax.XMLReader reader, org.xml.sax.InputSource source, java.lang.Class<T> expectedType)
java.lang.Object
unmarshal0(java.io.InputStream input, JaxBeanInfo expectedType)
java.lang.Object
unmarshal0(javax.xml.stream.XMLStreamReader reader, JaxBeanInfo expectedType)
java.lang.Object
unmarshal0(javax.xml.transform.Source source, JaxBeanInfo expectedType)
java.lang.Object
unmarshal0(org.w3c.dom.Node node, JaxBeanInfo expectedType)
-
-
-
Field Detail
-
context
protected final JAXBContextImpl context
OwningJAXBContext
-
coordinator
public final UnmarshallingContext coordinator
-
FACTORY
public static final java.lang.String FACTORY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UnmarshallerImpl
public UnmarshallerImpl(JAXBContextImpl context, AssociationMap assoc)
-
-
Method Detail
-
getUnmarshallerHandler
public javax.xml.bind.UnmarshallerHandler getUnmarshallerHandler()
- Specified by:
getUnmarshallerHandler
in interfacejavax.xml.bind.Unmarshaller
-
getXMLReader
protected org.xml.sax.XMLReader getXMLReader() throws javax.xml.bind.JAXBException
Obtains a configured XMLReader. This method is used when the client-specifiedSAXSource
object doesn't have XMLReader.Unmarshaller
is not re-entrant, so we will only use one instance of XMLReader. Overriden in order to fix potential security issue.- Overrides:
getXMLReader
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
createUnmarshallerHandler
public final XmlVisitor createUnmarshallerHandler(InfosetScanner scanner, boolean inplace, JaxBeanInfo expectedType)
Creates and configures a new unmarshalling pipe line. Depending on the setting, we put a validator as a filter.- Returns:
- A component that implements both
UnmarshallerHandler
andValidationEventHandler
. All the parsing errors should be reported to this error handler for the unmarshalling process to work correctly. Also, returned handler expects all the XML names to be interned.
-
needsInterning
public static boolean needsInterning(org.xml.sax.XMLReader reader)
-
unmarshal
protected java.lang.Object unmarshal(org.xml.sax.XMLReader reader, org.xml.sax.InputSource source) throws javax.xml.bind.JAXBException
- Specified by:
unmarshal
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
protected <T> javax.xml.bind.JAXBElement<T> unmarshal(org.xml.sax.XMLReader reader, org.xml.sax.InputSource source, java.lang.Class<T> expectedType) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
public <T> javax.xml.bind.JAXBElement<T> unmarshal(javax.xml.transform.Source source, java.lang.Class<T> expectedType) throws javax.xml.bind.JAXBException
- Specified by:
unmarshal
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
unmarshal
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
unmarshal0
public java.lang.Object unmarshal0(javax.xml.transform.Source source, JaxBeanInfo expectedType) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
getEventHandler
public final javax.xml.bind.ValidationEventHandler getEventHandler()
- Specified by:
getEventHandler
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
getEventHandler
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
hasEventHandler
public final boolean hasEventHandler()
Returns true if an event handler is installed.The default handler ignores any errors, and for that this method returns false.
-
unmarshal
public <T> javax.xml.bind.JAXBElement<T> unmarshal(org.w3c.dom.Node node, java.lang.Class<T> expectedType) throws javax.xml.bind.JAXBException
- Specified by:
unmarshal
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
unmarshal
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
public final java.lang.Object unmarshal(org.w3c.dom.Node node) throws javax.xml.bind.JAXBException
- Specified by:
unmarshal
in interfacejavax.xml.bind.Unmarshaller
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
@Deprecated public final java.lang.Object unmarshal(javax.xml.transform.sax.SAXSource source) throws javax.xml.bind.JAXBException
Deprecated.- Throws:
javax.xml.bind.JAXBException
-
unmarshal0
public final java.lang.Object unmarshal0(org.w3c.dom.Node node, JaxBeanInfo expectedType) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
public java.lang.Object unmarshal(javax.xml.stream.XMLStreamReader reader) throws javax.xml.bind.JAXBException
- Specified by:
unmarshal
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
unmarshal
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
public <T> javax.xml.bind.JAXBElement<T> unmarshal(javax.xml.stream.XMLStreamReader reader, java.lang.Class<T> expectedType) throws javax.xml.bind.JAXBException
- Specified by:
unmarshal
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
unmarshal
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
unmarshal0
public java.lang.Object unmarshal0(javax.xml.stream.XMLStreamReader reader, JaxBeanInfo expectedType) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
public <T> javax.xml.bind.JAXBElement<T> unmarshal(javax.xml.stream.XMLEventReader reader, java.lang.Class<T> expectedType) throws javax.xml.bind.JAXBException
- Specified by:
unmarshal
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
unmarshal
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
public java.lang.Object unmarshal(javax.xml.stream.XMLEventReader reader) throws javax.xml.bind.JAXBException
- Specified by:
unmarshal
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
unmarshal
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.JAXBException
-
unmarshal0
public java.lang.Object unmarshal0(java.io.InputStream input, JaxBeanInfo expectedType) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
getProperty
public java.lang.Object getProperty(java.lang.String name) throws javax.xml.bind.PropertyException
- Specified by:
getProperty
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
getProperty
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.PropertyException
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value) throws javax.xml.bind.PropertyException
- Specified by:
setProperty
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
setProperty
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
- Throws:
javax.xml.bind.PropertyException
-
setSchema
public void setSchema(javax.xml.validation.Schema schema)
- Specified by:
setSchema
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
setSchema
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
getSchema
public javax.xml.validation.Schema getSchema()
- Specified by:
getSchema
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
getSchema
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
getAttachmentUnmarshaller
public javax.xml.bind.attachment.AttachmentUnmarshaller getAttachmentUnmarshaller()
- Specified by:
getAttachmentUnmarshaller
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
getAttachmentUnmarshaller
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
setAttachmentUnmarshaller
public void setAttachmentUnmarshaller(javax.xml.bind.attachment.AttachmentUnmarshaller au)
- Specified by:
setAttachmentUnmarshaller
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
setAttachmentUnmarshaller
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
isValidating
public boolean isValidating()
Deprecated.since 2.0- Specified by:
isValidating
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
isValidating
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
setValidating
public void setValidating(boolean validating)
Deprecated.since 2.0- Specified by:
setValidating
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
setValidating
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
setAdapter
public <A extends javax.xml.bind.annotation.adapters.XmlAdapter> void setAdapter(java.lang.Class<A> type, A adapter)
- Specified by:
setAdapter
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
setAdapter
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
getAdapter
public <A extends javax.xml.bind.annotation.adapters.XmlAdapter> A getAdapter(java.lang.Class<A> type)
- Specified by:
getAdapter
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
getAdapter
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
createUnmarshalException
public javax.xml.bind.UnmarshalException createUnmarshalException(org.xml.sax.SAXException e)
- Overrides:
createUnmarshalException
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
handleEvent
public boolean handleEvent(javax.xml.bind.ValidationEvent event)
Default error handling behavior forUnmarshaller
.- Specified by:
handleEvent
in interfacejavax.xml.bind.ValidationEventHandler
-
getBeanInfo
public <T> JaxBeanInfo<T> getBeanInfo(java.lang.Class<T> clazz) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
getListener
public javax.xml.bind.Unmarshaller.Listener getListener()
- Specified by:
getListener
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
getListener
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
setListener
public void setListener(javax.xml.bind.Unmarshaller.Listener listener)
- Specified by:
setListener
in interfacejavax.xml.bind.Unmarshaller
- Overrides:
setListener
in classjavax.xml.bind.helpers.AbstractUnmarshallerImpl
-
getContext
public UnmarshallingContext getContext()
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
close
public void close() throws java.io.IOException
Must be called from same thread which created the UnmarshallerImpl instance.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-