EclipseLink 2.3.2, build 'v20111125-r10461' API Reference

org.eclipse.persistence.jaxb
Class JAXBHelper

java.lang.Object
  extended by org.eclipse.persistence.jaxb.JAXBHelper

public class JAXBHelper
extends java.lang.Object

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
JAXBHelper()
           
 
Method Summary
static JAXBBinder getBinder(Binder 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
unwrap(Binder jaxbBinder, java.lang.Class<T> clazz)
          Unwraps a given Binder resulting in an EclipseLink JAXBBinder, or the EclipseLink JAXBBinder's underlying XMLBinder.
static
<T> T
unwrap(JAXBContext jaxbContext, java.lang.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, java.lang.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, java.lang.Class<T> clazz)
          Unwraps a given Unmarshaller resulting in an EclipseLink JAXBUnmarshaller, or the EclipseLink JAXBUnmarshaller's underlying XMLUnmarshaller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAXBHelper

public JAXBHelper()
Method Detail

getJAXBContext

public static JAXBContext getJAXBContext(JAXBContext jaxbContext)
                                  throws java.lang.IllegalArgumentException
Return the EclipseLink implementation of JAXBContext. The given JAXBContext is assumed to be an instance of JAXBContext. If not, an exception will be thrown.

Parameters:
jaxbContext -
Returns:
Throws:
java.lang.IllegalArgumentException

getUnmarshaller

public static JAXBUnmarshaller getUnmarshaller(Unmarshaller jaxbUnmarshaller)
                                        throws java.lang.IllegalArgumentException
Return the EclipseLink implementation of Unmarshaller. The given Unmarshaller is assumed to be an instance of JAXBUnmarshaller. If not, an exception will be thrown.

Parameters:
jaxbUnmarshaller -
Returns:
Throws:
java.lang.IllegalArgumentException

getMarshaller

public static JAXBMarshaller getMarshaller(Marshaller jaxbMarshaller)
                                    throws java.lang.IllegalArgumentException
Return the EclipseLink implementation of Marshaller. The given Marshaller is assumed to be an instance of JAXBMarshaller. If not, an exception will be thrown.

Parameters:
jaxbMarshaller -
Returns:
Throws:
java.lang.IllegalArgumentException

getBinder

public static JAXBBinder getBinder(Binder jaxbBinder)
                            throws java.lang.IllegalArgumentException
Return the EclipseLink implementation of Binder. The given Binder is assumed to be an instance of JAXBBinder. If not, an exception will be thrown.

Parameters:
jaxbBinder -
Returns:
Throws:
java.lang.IllegalArgumentException

unwrap

public static <T> T unwrap(JAXBContext jaxbContext,
                           java.lang.Class<T> clazz)
                throws java.lang.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:
java.lang.IllegalArgumentException
See Also:
JAXBContext, XMLContext

unwrap

public static <T> T unwrap(Unmarshaller jaxbUnmarshaller,
                           java.lang.Class<T> clazz)
                throws java.lang.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:
java.lang.IllegalArgumentException
See Also:
JAXBUnmarshaller, XMLUnmarshaller

unwrap

public static <T> T unwrap(Marshaller jaxbMarshaller,
                           java.lang.Class<T> clazz)
                throws java.lang.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:
java.lang.IllegalArgumentException
See Also:
JAXBMarshaller, XMLMarshaller

unwrap

public static <T> T unwrap(Binder jaxbBinder,
                           java.lang.Class<T> clazz)
                throws java.lang.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:
java.lang.IllegalArgumentException
See Also:
JAXBBinder, XMLBinder

EclipseLink 2.3.2, build 'v20111125-r10461' API Reference