public class JaxbBuilder extends java.lang.Object implements Input.Builder
Input.Builder for Jaxb-Object and creating a JAXBSource.
If no custom Marshaller is set by withMarshaller(Marshaller), then the same logic as in JAXB
is used the create a default Marshaller.
| Modifier and Type | Field and Description |
|---|---|
private javax.xml.bind.Marshaller |
marshaller |
private java.lang.Object |
object |
private boolean |
userObjectFactory |
| Modifier | Constructor and Description |
|---|---|
protected |
JaxbBuilder(java.lang.Object object)
Creates a builder based on the given object.
|
| Modifier and Type | Method and Description |
|---|---|
javax.xml.transform.Source |
build()
build the actual
Source instance. |
private void |
createDefaultMarshaller() |
private static <T> javax.xml.bind.JAXBElement<T> |
createInferredJAXBElement(T object) |
private static <T> javax.xml.bind.JAXBElement<T> |
createJAXBElement(T jaxbObj) |
private static <T> javax.xml.bind.JAXBElement<T> |
createJaxbElementFromObjectFactory(T obj) |
private static <T> java.lang.Class<?> |
getObjectFactoryClass(T obj) |
private java.lang.Object |
getPreparedJaxbObject() |
private static java.lang.String |
inferName(java.lang.Class clazz) |
JaxbBuilder |
useObjectFactory()
If the given Object has no
XmlRootElement annotation and is not an instants of JAXBElement it
must be wrapped by a JAXBElement. |
JaxbBuilder |
withMarshaller(javax.xml.bind.Marshaller marshaller)
Sets a non-default
Marshaller to use when creating the Source. |
private final java.lang.Object object
private javax.xml.bind.Marshaller marshaller
private boolean userObjectFactory
protected JaxbBuilder(java.lang.Object object)
public JaxbBuilder withMarshaller(javax.xml.bind.Marshaller marshaller)
Marshaller to use when creating the Source.public JaxbBuilder useObjectFactory()
XmlRootElement annotation and is not an instants of JAXBElement it
must be wrapped by a JAXBElement.
This method will find the ObjectFactory class (normally generated by jaxb) and use the first matching
factory-method for the given Object to create the JAXBElement-Wrapper.
If no ObjectFactory and method exists for the given object, the default behavior (same behavior as by
JAXB) will be used to create the JAXBElement-Wrapper for the given Object.
If you don't use the xjc:simple flag to generate your JAXB-Objects, the use of the OjectFactory is most likely
required to generate Schema-Valid XML.
public javax.xml.transform.Source build()
Input.BuilderSource instance.build in interface Input.Builderprivate java.lang.Object getPreparedJaxbObject()
private void createDefaultMarshaller()
throws javax.xml.bind.JAXBException,
javax.xml.bind.PropertyException
javax.xml.bind.JAXBExceptionjavax.xml.bind.PropertyExceptionprivate static <T> javax.xml.bind.JAXBElement<T> createInferredJAXBElement(T object)
private static <T> javax.xml.bind.JAXBElement<T> createJAXBElement(T jaxbObj)
private static <T> javax.xml.bind.JAXBElement<T> createJaxbElementFromObjectFactory(T obj)
private static <T> java.lang.Class<?> getObjectFactoryClass(T obj)
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionprivate static java.lang.String inferName(java.lang.Class clazz)