Class Unmarshaller<T>


  • public class Unmarshaller<T>
    extends java.lang.Object
    This is a utility class to assist in unmarshaling XML into a new Java content tree. Each unmarshal method takes a different source for the XML. This class caches information to improve unmarshaling performance across calls using the same schema (package).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.ClassLoader classLoader
      The JAXB classloader.
      private java.lang.String contextPath
      The JAXB context path.
      private java.lang.ThreadLocal<javax.xml.bind.Unmarshaller> unmarshaller
      Use thread identity to preserve safety of access to unmarshallers.
    • Constructor Summary

      Constructors 
      Constructor Description
      Unmarshaller​(java.lang.String contextPath, java.lang.ClassLoader classloader)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.ClassLoader getClassLoader()
      Returns the JAXB classloader.
      java.lang.String getContextPath()
      Returns the JAXB context path.
      private javax.xml.bind.Unmarshaller getUnmarshaller()
      Returns the JAXB unmarshaller.
      void setEventHandler​(javax.xml.bind.ValidationEventHandler handler)
      Sets the validation handler for this unmarshaller.
      java.lang.Object unmarshal​(JaxbRepresentation<?> jaxbRep)
      Unmarshal XML data from the specified Restlet string representation and return the resulting Java content tree.
      java.lang.Object unmarshal​(JaxbRepresentation<?> jaxbRep, java.io.InputStream stream)
      Unmarshal XML data from the specified input stream and return the resulting Java content tree.
      java.lang.Object unmarshal​(JaxbRepresentation<?> jaxbRep, java.io.Reader reader)
      Unmarshal XML data from the specified reader and return the resulting Java content tree.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • classLoader

        private final java.lang.ClassLoader classLoader
        The JAXB classloader.
      • contextPath

        private final java.lang.String contextPath
        The JAXB context path.
      • unmarshaller

        private final java.lang.ThreadLocal<javax.xml.bind.Unmarshaller> unmarshaller
        Use thread identity to preserve safety of access to unmarshallers.
    • Constructor Detail

      • Unmarshaller

        public Unmarshaller​(java.lang.String contextPath,
                            java.lang.ClassLoader classloader)
        Constructor.
        Parameters:
        contextPath - The JAXB context path.
        classloader - The JAXB classloader.
    • Method Detail

      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Returns the JAXB classloader.
        Returns:
        The JAXB classloader.
      • getContextPath

        public java.lang.String getContextPath()
        Returns the JAXB context path.
        Returns:
        The JAXB context path.
      • getUnmarshaller

        private javax.xml.bind.Unmarshaller getUnmarshaller()
                                                     throws javax.xml.bind.JAXBException
        Returns the JAXB unmarshaller.
        Returns:
        The JAXB unmarshaller.
        Throws:
        javax.xml.bind.JAXBException
      • setEventHandler

        public void setEventHandler​(javax.xml.bind.ValidationEventHandler handler)
                             throws javax.xml.bind.JAXBException
        Sets the validation handler for this unmarshaller.
        Parameters:
        handler - A validation handler.
        Throws:
        javax.xml.bind.JAXBException - If an error was encountered while setting the event handler.
      • unmarshal

        public java.lang.Object unmarshal​(JaxbRepresentation<?> jaxbRep)
                                   throws javax.xml.bind.JAXBException,
                                          java.io.IOException
        Unmarshal XML data from the specified Restlet string representation and return the resulting Java content tree.
        Parameters:
        jaxbRep - The source JAXB representation.
        Returns:
        The newly created root object of the Java content tree.
        Throws:
        javax.xml.bind.JAXBException - If any unexpected problem occurs during unmarshaling.
        java.io.IOException - If an error occurs accessing the string representation.
      • unmarshal

        public java.lang.Object unmarshal​(JaxbRepresentation<?> jaxbRep,
                                          java.io.InputStream stream)
                                   throws javax.xml.bind.JAXBException
        Unmarshal XML data from the specified input stream and return the resulting Java content tree.
        Parameters:
        stream - The source input stream.
        Returns:
        The newly created root object of the Java content tree.
        Throws:
        javax.xml.bind.JAXBException - If any unexpected problem occurs during unmarshaling.
        java.io.IOException - If an error occurs accessing the string representation.
      • unmarshal

        public java.lang.Object unmarshal​(JaxbRepresentation<?> jaxbRep,
                                          java.io.Reader reader)
                                   throws javax.xml.bind.JAXBException
        Unmarshal XML data from the specified reader and return the resulting Java content tree.
        Parameters:
        reader - The source reader.
        Returns:
        The newly created root object of the Java content tree.
        Throws:
        javax.xml.bind.JAXBException - If any unexpected problem occurs during unmarshaling.
        java.io.IOException - If an error occurs accessing the string representation.