Package org.eclipse.persistence.jaxb
Class JAXBHelper
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
getBinder
(jakarta.xml.bind.Binder jaxbBinder) Return the EclipseLink implementation of Binder.static JAXBContext
getJAXBContext
(jakarta.xml.bind.JAXBContext jaxbContext) Return the EclipseLink implementation of JAXBContext.static JAXBMarshaller
getMarshaller
(jakarta.xml.bind.Marshaller jaxbMarshaller) Return the EclipseLink implementation of Marshaller.static JAXBUnmarshaller
getUnmarshaller
(jakarta.xml.bind.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
Unwraps a given JAXBContext resulting in an EclipseLink JAXBContext, or the EclipseLink JAXBContext's underlying XMLContext.static <T> T
Unwraps a given Marshaller resulting in an EclipseLink JAXBMarshaller, or the EclipseLink JAXBMarshaller's underlying XMLMarshaller.static <T> T
Unwraps a given Unmarshaller resulting in an EclipseLink JAXBUnmarshaller, or the EclipseLink JAXBUnmarshaller's underlying XMLUnmarshaller.
-
Constructor Details
-
JAXBHelper
public JAXBHelper()
-
-
Method Details
-
getJAXBContext
public static JAXBContext getJAXBContext(jakarta.xml.bind.JAXBContext jaxbContext) throws IllegalArgumentException Return the EclipseLink implementation of JAXBContext. The given JAXBContext is assumed to be an instance ofJAXBContext
. If not, an exception will be thrown.- Parameters:
jaxbContext
-- Returns:
- Throws:
IllegalArgumentException
-
getUnmarshaller
public static JAXBUnmarshaller getUnmarshaller(jakarta.xml.bind.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.- Parameters:
jaxbUnmarshaller
-- Returns:
- Throws:
IllegalArgumentException
-
getMarshaller
public static JAXBMarshaller getMarshaller(jakarta.xml.bind.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.- Parameters:
jaxbMarshaller
-- Returns:
- Throws:
IllegalArgumentException
-
getBinder
public static JAXBBinder getBinder(jakarta.xml.bind.Binder jaxbBinder) throws IllegalArgumentException Return the EclipseLink implementation of Binder. The given Binder is assumed to be an instance ofJAXBBinder
. If not, an exception will be thrown.- Parameters:
jaxbBinder
-- Returns:
- Throws:
IllegalArgumentException
-
unwrap
public static <T> T unwrap(jakarta.xml.bind.JAXBContext jaxbContext, Class<T> clazz) throws IllegalArgumentException 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.- Type Parameters:
T
-- Parameters:
jaxbContext
-clazz
-- Returns:
- Throws:
IllegalArgumentException
- See Also:
-
unwrap
public static <T> T unwrap(jakarta.xml.bind.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.- Type Parameters:
T
-- Parameters:
jaxbUnmarshaller
-clazz
-- Returns:
- Throws:
IllegalArgumentException
- See Also:
-
unwrap
public static <T> T unwrap(jakarta.xml.bind.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.- Type Parameters:
T
-- Parameters:
jaxbMarshaller
-clazz
-- Returns:
- Throws:
IllegalArgumentException
- See Also:
-
unwrap
public static <T> T unwrap(jakarta.xml.bind.Binder jaxbBinder, Class<T> clazz) throws IllegalArgumentException 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.- Type Parameters:
T
-- Parameters:
jaxbBinder
-clazz
-- Returns:
- Throws:
IllegalArgumentException
- See Also:
-