Class UnmarshallerImpl
- java.lang.Object
-
- javax.xml.bind.helpers.AbstractUnmarshallerImpl
-
- com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Unmarshaller
,ValidationEventHandler
public final class UnmarshallerImpl extends AbstractUnmarshallerImpl implements ValidationEventHandler, Closeable
Default Unmarshaller implementation.This class can be extended by the generated code to provide type-safe unmarshall methods.
- Author:
- Kohsuke KAWAGUCHI
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.xml.bind.Unmarshaller
Unmarshaller.Listener
-
-
Field Summary
Fields Modifier and Type Field Description protected JAXBContextImpl
context
OwningJAXBContext
UnmarshallingContext
coordinator
static String
FACTORY
-
Fields inherited from class javax.xml.bind.helpers.AbstractUnmarshallerImpl
validating
-
-
Constructor Summary
Constructors Constructor Description UnmarshallerImpl(JAXBContextImpl context, AssociationMap assoc)
-
Method Summary
-
Methods inherited from class javax.xml.bind.helpers.AbstractUnmarshallerImpl
setAdapter, setEventHandler, unmarshal, unmarshal, unmarshal, unmarshal, unmarshal, unmarshal
-
-
-
-
Field Detail
-
context
protected final JAXBContextImpl context
OwningJAXBContext
-
coordinator
public final UnmarshallingContext coordinator
-
FACTORY
public static final String FACTORY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UnmarshallerImpl
public UnmarshallerImpl(JAXBContextImpl context, AssociationMap assoc)
-
-
Method Detail
-
getUnmarshallerHandler
public UnmarshallerHandler getUnmarshallerHandler()
- Specified by:
getUnmarshallerHandler
in interfaceUnmarshaller
-
getXMLReader
protected XMLReader getXMLReader() throws 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 classAbstractUnmarshallerImpl
- Throws:
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(XMLReader reader)
-
unmarshal
protected Object unmarshal(XMLReader reader, InputSource source) throws JAXBException
- Specified by:
unmarshal
in classAbstractUnmarshallerImpl
- Throws:
JAXBException
-
unmarshal
protected <T> JAXBElement<T> unmarshal(XMLReader reader, InputSource source, Class<T> expectedType) throws JAXBException
- Throws:
JAXBException
-
unmarshal
public <T> JAXBElement<T> unmarshal(Source source, Class<T> expectedType) throws JAXBException
- Specified by:
unmarshal
in interfaceUnmarshaller
- Overrides:
unmarshal
in classAbstractUnmarshallerImpl
- Throws:
JAXBException
-
unmarshal0
public Object unmarshal0(Source source, JaxBeanInfo expectedType) throws JAXBException
- Throws:
JAXBException
-
getEventHandler
public final ValidationEventHandler getEventHandler()
- Specified by:
getEventHandler
in interfaceUnmarshaller
- Overrides:
getEventHandler
in classAbstractUnmarshallerImpl
-
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> JAXBElement<T> unmarshal(Node node, Class<T> expectedType) throws JAXBException
- Specified by:
unmarshal
in interfaceUnmarshaller
- Overrides:
unmarshal
in classAbstractUnmarshallerImpl
- Throws:
JAXBException
-
unmarshal
public final Object unmarshal(Node node) throws JAXBException
- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
@Deprecated public final Object unmarshal(SAXSource source) throws JAXBException
Deprecated.- Throws:
JAXBException
-
unmarshal0
public final Object unmarshal0(Node node, JaxBeanInfo expectedType) throws JAXBException
- Throws:
JAXBException
-
unmarshal
public Object unmarshal(XMLStreamReader reader) throws JAXBException
- Specified by:
unmarshal
in interfaceUnmarshaller
- Overrides:
unmarshal
in classAbstractUnmarshallerImpl
- Throws:
JAXBException
-
unmarshal
public <T> JAXBElement<T> unmarshal(XMLStreamReader reader, Class<T> expectedType) throws JAXBException
- Specified by:
unmarshal
in interfaceUnmarshaller
- Overrides:
unmarshal
in classAbstractUnmarshallerImpl
- Throws:
JAXBException
-
unmarshal0
public Object unmarshal0(XMLStreamReader reader, JaxBeanInfo expectedType) throws JAXBException
- Throws:
JAXBException
-
unmarshal
public <T> JAXBElement<T> unmarshal(XMLEventReader reader, Class<T> expectedType) throws JAXBException
- Specified by:
unmarshal
in interfaceUnmarshaller
- Overrides:
unmarshal
in classAbstractUnmarshallerImpl
- Throws:
JAXBException
-
unmarshal
public Object unmarshal(XMLEventReader reader) throws JAXBException
- Specified by:
unmarshal
in interfaceUnmarshaller
- Overrides:
unmarshal
in classAbstractUnmarshallerImpl
- Throws:
JAXBException
-
unmarshal0
public Object unmarshal0(InputStream input, JaxBeanInfo expectedType) throws JAXBException
- Throws:
JAXBException
-
getProperty
public Object getProperty(String name) throws PropertyException
- Specified by:
getProperty
in interfaceUnmarshaller
- Overrides:
getProperty
in classAbstractUnmarshallerImpl
- Throws:
PropertyException
-
setProperty
public void setProperty(String name, Object value) throws PropertyException
- Specified by:
setProperty
in interfaceUnmarshaller
- Overrides:
setProperty
in classAbstractUnmarshallerImpl
- Throws:
PropertyException
-
setSchema
public void setSchema(Schema schema)
- Specified by:
setSchema
in interfaceUnmarshaller
- Overrides:
setSchema
in classAbstractUnmarshallerImpl
-
getSchema
public Schema getSchema()
- Specified by:
getSchema
in interfaceUnmarshaller
- Overrides:
getSchema
in classAbstractUnmarshallerImpl
-
getAttachmentUnmarshaller
public AttachmentUnmarshaller getAttachmentUnmarshaller()
- Specified by:
getAttachmentUnmarshaller
in interfaceUnmarshaller
- Overrides:
getAttachmentUnmarshaller
in classAbstractUnmarshallerImpl
-
setAttachmentUnmarshaller
public void setAttachmentUnmarshaller(AttachmentUnmarshaller au)
- Specified by:
setAttachmentUnmarshaller
in interfaceUnmarshaller
- Overrides:
setAttachmentUnmarshaller
in classAbstractUnmarshallerImpl
-
isValidating
public boolean isValidating()
Deprecated.since 2.0- Specified by:
isValidating
in interfaceUnmarshaller
- Overrides:
isValidating
in classAbstractUnmarshallerImpl
-
setValidating
public void setValidating(boolean validating)
Deprecated.since 2.0- Specified by:
setValidating
in interfaceUnmarshaller
- Overrides:
setValidating
in classAbstractUnmarshallerImpl
-
setAdapter
public <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter)
- Specified by:
setAdapter
in interfaceUnmarshaller
- Overrides:
setAdapter
in classAbstractUnmarshallerImpl
-
getAdapter
public <A extends XmlAdapter> A getAdapter(Class<A> type)
- Specified by:
getAdapter
in interfaceUnmarshaller
- Overrides:
getAdapter
in classAbstractUnmarshallerImpl
-
createUnmarshalException
public UnmarshalException createUnmarshalException(SAXException e)
- Overrides:
createUnmarshalException
in classAbstractUnmarshallerImpl
-
handleEvent
public boolean handleEvent(ValidationEvent event)
Default error handling behavior forUnmarshaller
.- Specified by:
handleEvent
in interfaceValidationEventHandler
-
getBeanInfo
public <T> JaxBeanInfo<T> getBeanInfo(Class<T> clazz) throws JAXBException
- Throws:
JAXBException
-
getListener
public Unmarshaller.Listener getListener()
- Specified by:
getListener
in interfaceUnmarshaller
- Overrides:
getListener
in classAbstractUnmarshallerImpl
-
setListener
public void setListener(Unmarshaller.Listener listener)
- Specified by:
setListener
in interfaceUnmarshaller
- Overrides:
setListener
in classAbstractUnmarshallerImpl
-
getContext
public UnmarshallingContext getContext()
-
finalize
protected void finalize() throws Throwable
-
close
public void close() throws IOException
Must be called from same thread which created the UnmarshallerImpl instance.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-