Package org.restlet.ext.jaxb.internal
Class Unmarshaller<T>
- java.lang.Object
-
- org.restlet.ext.jaxb.internal.Unmarshaller<T>
-
public class Unmarshaller<T> extends java.lang.ObjectThis is a utility class to assist in unmarshaling XML into a new Java content tree. Eachunmarshalmethod 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.ClassLoaderclassLoaderThe JAXB classloader.private java.lang.StringcontextPathThe JAXB context path.private java.lang.ThreadLocal<javax.xml.bind.Unmarshaller>unmarshallerUse 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.ClassLoadergetClassLoader()Returns the JAXB classloader.java.lang.StringgetContextPath()Returns the JAXB context path.private javax.xml.bind.UnmarshallergetUnmarshaller()Returns the JAXB unmarshaller.voidsetEventHandler(javax.xml.bind.ValidationEventHandler handler)Sets the validation handler for this unmarshaller.java.lang.Objectunmarshal(JaxbRepresentation<?> jaxbRep)Unmarshal XML data from the specified Restlet string representation and return the resulting Java content tree.java.lang.Objectunmarshal(JaxbRepresentation<?> jaxbRep, java.io.InputStream stream)Unmarshal XML data from the specified input stream and return the resulting Java content tree.java.lang.Objectunmarshal(JaxbRepresentation<?> jaxbRep, java.io.Reader reader)Unmarshal XML data from the specified reader and return the resulting Java content tree.
-
-
-
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.
-
-
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.JAXBExceptionReturns 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.JAXBExceptionSets 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.
-
-