java.lang.Object
org.eclipse.persistence.jaxb.JAXBHelper
This class provides a mechanism to obtain the EclipseLink implementation of various JAXB runtime
classes based on a given JAXB class/interface. This is useful for accessing extended EclipseLink
features. Using this helper class will alleviate the need for consumers of EclipseLink JAXB to
perform casts where their code makes use of the standard JAXB API. In addition, a given JAXB
class/interface can be unwrapped based on a user-specified class. This will allow access - in
certain cases - to a given JAXB implementation class' underlying class(es). For example, a
Marshaller could be unwrapped resulting in an EclipseLink JAXBMarshaller, or its underlying
XMLMarshaller.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic JAXBBinder
Return the EclipseLink implementation of Binder.static JAXBContext
getJAXBContext
(JAXBContext jaxbContext) Return the EclipseLink implementation of JAXBContext.static JAXBMarshaller
getMarshaller
(Marshaller jaxbMarshaller) Return the EclipseLink implementation of Marshaller.static JAXBUnmarshaller
getUnmarshaller
(Unmarshaller jaxbUnmarshaller) Return the EclipseLink implementation of Unmarshaller.static <T> T
Unwraps a given Binder resulting in an EclipseLink JAXBBinder, or the EclipseLink JAXBBinder's underlying XMLBinder.static <T> T
unwrap
(JAXBContext jaxbContext, Class<T> clazz) Unwraps a given JAXBContext resulting in an EclipseLink JAXBContext, or the EclipseLink JAXBContext's underlying XMLContext.static <T> T
unwrap
(Marshaller jaxbMarshaller, Class<T> clazz) Unwraps a given Marshaller resulting in an EclipseLink JAXBMarshaller, or the EclipseLink JAXBMarshaller's underlying XMLMarshaller.static <T> T
unwrap
(Unmarshaller jaxbUnmarshaller, Class<T> clazz) Unwraps a given Unmarshaller resulting in an EclipseLink JAXBUnmarshaller, or the EclipseLink JAXBUnmarshaller's underlying XMLUnmarshaller.
-
Constructor Details
-
JAXBHelper
public JAXBHelper()
-
-
Method Details
-
getJAXBContext
Return the EclipseLink implementation of JAXBContext. The given JAXBContext is assumed to be an instance ofJAXBContext
. If not, an exception will be thrown.- Throws:
IllegalArgumentException
-
getUnmarshaller
public static JAXBUnmarshaller getUnmarshaller(Unmarshaller jaxbUnmarshaller) throws IllegalArgumentException Return the EclipseLink implementation of Unmarshaller. The given Unmarshaller is assumed to be an instance ofJAXBUnmarshaller
. If not, an exception will be thrown.- Throws:
IllegalArgumentException
-
getMarshaller
public static JAXBMarshaller getMarshaller(Marshaller jaxbMarshaller) throws IllegalArgumentException Return the EclipseLink implementation of Marshaller. The given Marshaller is assumed to be an instance ofJAXBMarshaller
. If not, an exception will be thrown.- Throws:
IllegalArgumentException
-
getBinder
Return the EclipseLink implementation of Binder. The given Binder is assumed to be an instance ofJAXBBinder
. If not, an exception will be thrown.- Throws:
IllegalArgumentException
-
unwrap
Unwraps a given JAXBContext resulting in an EclipseLink JAXBContext, or the EclipseLink JAXBContext's underlying XMLContext. Assumes that the given JAXBContext is an instance of EclipseLink JAXBContext, and clazz is one of org.eclipse.persistence.jaxb.JAXBContext or org.eclipse.persistence.oxm.XMLContext.- Throws:
IllegalArgumentException
- See Also:
-
unwrap
public static <T> T unwrap(Unmarshaller jaxbUnmarshaller, Class<T> clazz) throws IllegalArgumentException Unwraps a given Unmarshaller resulting in an EclipseLink JAXBUnmarshaller, or the EclipseLink JAXBUnmarshaller's underlying XMLUnmarshaller. Assumes that the given Unmarshaller is an instance of EclipseLink JAXBUnmarshaller, and clazz is one of org.eclipse.persistence.jaxb.JAXBUnmarshaller or org.eclipse.persistence.oxm.XMLUnmarshaller.- Throws:
IllegalArgumentException
- See Also:
-
unwrap
public static <T> T unwrap(Marshaller jaxbMarshaller, Class<T> clazz) throws IllegalArgumentException Unwraps a given Marshaller resulting in an EclipseLink JAXBMarshaller, or the EclipseLink JAXBMarshaller's underlying XMLMarshaller. Assumes that the given Marshaller is an instance of EclipseLink JAXBMarshaller, and clazz is one of org.eclipse.persistence.jaxb.JAXBMarshaller or org.eclipse.persistence.oxm.XMLMarshaller.- Throws:
IllegalArgumentException
- See Also:
-
unwrap
Unwraps a given Binder resulting in an EclipseLink JAXBBinder, or the EclipseLink JAXBBinder's underlying XMLBinder. Assumes that the given Binder is an instance of EclipseLink JAXBBinderr, and clazz is one of org.eclipse.persistence.jaxb.JAXBinder or org.eclipse.persistence.oxm.XMLBinder.- Throws:
IllegalArgumentException
- See Also:
-