Class UnmarshallerImpl

java.lang.Object
javax.xml.bind.helpers.AbstractUnmarshallerImpl
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl
All Implemented Interfaces:
Closeable, AutoCloseable, javax.xml.bind.Unmarshaller, javax.xml.bind.ValidationEventHandler

public final class UnmarshallerImpl extends javax.xml.bind.helpers.AbstractUnmarshallerImpl implements javax.xml.bind.ValidationEventHandler, Closeable
Default Unmarshaller implementation.

This class can be extended by the generated code to provide type-safe unmarshall methods.

Author:
Kohsuke KAWAGUCHI
  • Field Details

  • Constructor Details

  • Method Details

    • getUnmarshallerHandler

      public javax.xml.bind.UnmarshallerHandler getUnmarshallerHandler()
      Specified by:
      getUnmarshallerHandler in interface javax.xml.bind.Unmarshaller
    • getXMLReader

      protected XMLReader getXMLReader() throws javax.xml.bind.JAXBException
      Obtains a configured XMLReader. This method is used when the client-specified SAXSource 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 class javax.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 and ValidationEventHandler. 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 javax.xml.bind.JAXBException
      Specified by:
      unmarshal in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal

      protected <T> javax.xml.bind.JAXBElement<T> unmarshal(XMLReader reader, InputSource source, Class<T> expectedType) throws javax.xml.bind.JAXBException
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal

      public <T> javax.xml.bind.JAXBElement<T> unmarshal(Source source, Class<T> expectedType) throws javax.xml.bind.JAXBException
      Specified by:
      unmarshal in interface javax.xml.bind.Unmarshaller
      Overrides:
      unmarshal in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal0

      public Object unmarshal0(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 interface javax.xml.bind.Unmarshaller
      Overrides:
      getEventHandler in class javax.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(Node node, Class<T> expectedType) throws javax.xml.bind.JAXBException
      Specified by:
      unmarshal in interface javax.xml.bind.Unmarshaller
      Overrides:
      unmarshal in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal

      public final Object unmarshal(Node node) throws javax.xml.bind.JAXBException
      Specified by:
      unmarshal in interface javax.xml.bind.Unmarshaller
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal

      @Deprecated public final Object unmarshal(SAXSource source) throws javax.xml.bind.JAXBException
      Deprecated.
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal0

      public final Object unmarshal0(Node node, JaxBeanInfo expectedType) throws javax.xml.bind.JAXBException
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal

      public Object unmarshal(XMLStreamReader reader) throws javax.xml.bind.JAXBException
      Specified by:
      unmarshal in interface javax.xml.bind.Unmarshaller
      Overrides:
      unmarshal in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal

      public <T> javax.xml.bind.JAXBElement<T> unmarshal(XMLStreamReader reader, Class<T> expectedType) throws javax.xml.bind.JAXBException
      Specified by:
      unmarshal in interface javax.xml.bind.Unmarshaller
      Overrides:
      unmarshal in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal0

      public Object unmarshal0(XMLStreamReader reader, JaxBeanInfo expectedType) throws javax.xml.bind.JAXBException
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal

      public <T> javax.xml.bind.JAXBElement<T> unmarshal(XMLEventReader reader, Class<T> expectedType) throws javax.xml.bind.JAXBException
      Specified by:
      unmarshal in interface javax.xml.bind.Unmarshaller
      Overrides:
      unmarshal in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal

      public Object unmarshal(XMLEventReader reader) throws javax.xml.bind.JAXBException
      Specified by:
      unmarshal in interface javax.xml.bind.Unmarshaller
      Overrides:
      unmarshal in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
      Throws:
      javax.xml.bind.JAXBException
    • unmarshal0

      public Object unmarshal0(InputStream input, JaxBeanInfo expectedType) throws javax.xml.bind.JAXBException
      Throws:
      javax.xml.bind.JAXBException
    • getProperty

      public Object getProperty(String name) throws javax.xml.bind.PropertyException
      Specified by:
      getProperty in interface javax.xml.bind.Unmarshaller
      Overrides:
      getProperty in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
      Throws:
      javax.xml.bind.PropertyException
    • setProperty

      public void setProperty(String name, Object value) throws javax.xml.bind.PropertyException
      Specified by:
      setProperty in interface javax.xml.bind.Unmarshaller
      Overrides:
      setProperty in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
      Throws:
      javax.xml.bind.PropertyException
    • setSchema

      public void setSchema(Schema schema)
      Specified by:
      setSchema in interface javax.xml.bind.Unmarshaller
      Overrides:
      setSchema in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • getSchema

      public Schema getSchema()
      Specified by:
      getSchema in interface javax.xml.bind.Unmarshaller
      Overrides:
      getSchema in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • getAttachmentUnmarshaller

      public javax.xml.bind.attachment.AttachmentUnmarshaller getAttachmentUnmarshaller()
      Specified by:
      getAttachmentUnmarshaller in interface javax.xml.bind.Unmarshaller
      Overrides:
      getAttachmentUnmarshaller in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • setAttachmentUnmarshaller

      public void setAttachmentUnmarshaller(javax.xml.bind.attachment.AttachmentUnmarshaller au)
      Specified by:
      setAttachmentUnmarshaller in interface javax.xml.bind.Unmarshaller
      Overrides:
      setAttachmentUnmarshaller in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • isValidating

      public boolean isValidating()
      Deprecated.
      since 2.0
      Specified by:
      isValidating in interface javax.xml.bind.Unmarshaller
      Overrides:
      isValidating in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • setValidating

      public void setValidating(boolean validating)
      Deprecated.
      since 2.0
      Specified by:
      setValidating in interface javax.xml.bind.Unmarshaller
      Overrides:
      setValidating in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • setAdapter

      public <A extends javax.xml.bind.annotation.adapters.XmlAdapter> void setAdapter(Class<A> type, A adapter)
      Specified by:
      setAdapter in interface javax.xml.bind.Unmarshaller
      Overrides:
      setAdapter in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • getAdapter

      public <A extends javax.xml.bind.annotation.adapters.XmlAdapter> A getAdapter(Class<A> type)
      Specified by:
      getAdapter in interface javax.xml.bind.Unmarshaller
      Overrides:
      getAdapter in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • createUnmarshalException

      public javax.xml.bind.UnmarshalException createUnmarshalException(SAXException e)
      Overrides:
      createUnmarshalException in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • handleEvent

      public boolean handleEvent(javax.xml.bind.ValidationEvent event)
      Default error handling behavior for Unmarshaller.
      Specified by:
      handleEvent in interface javax.xml.bind.ValidationEventHandler
    • getBeanInfo

      public <T> JaxBeanInfo<T> getBeanInfo(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 interface javax.xml.bind.Unmarshaller
      Overrides:
      getListener in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • setListener

      public void setListener(javax.xml.bind.Unmarshaller.Listener listener)
      Specified by:
      setListener in interface javax.xml.bind.Unmarshaller
      Overrides:
      setListener in class javax.xml.bind.helpers.AbstractUnmarshallerImpl
    • getContext

      public UnmarshallingContext getContext()
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • close

      public void close() throws IOException
      Must be called from same thread which created the UnmarshallerImpl instance.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException