Package org.xmlunit.builder
Class JaxbBuilder
- java.lang.Object
-
- org.xmlunit.builder.JaxbBuilder
-
- All Implemented Interfaces:
Input.Builder
public class JaxbBuilder extends java.lang.Object implements Input.Builder
Input.Builder
for Jaxb-Object and creating aJAXBSource
.If no custom
Marshaller
is set bywithMarshaller(Marshaller)
, then the same logic as inJAXB
is used the create a defaultMarshaller
.
-
-
Field Summary
Fields Modifier and Type Field Description private javax.xml.bind.Marshaller
marshaller
private java.lang.Object
object
private boolean
userObjectFactory
-
Constructor Summary
Constructors Modifier Constructor Description protected
JaxbBuilder(java.lang.Object object)
Creates a builder based on the given object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.xml.transform.Source
build()
build the actualSource
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 noXmlRootElement
annotation and is not an instants ofJAXBElement
it must be wrapped by aJAXBElement
.JaxbBuilder
withMarshaller(javax.xml.bind.Marshaller marshaller)
Sets a non-defaultMarshaller
to use when creating theSource
.
-
-
-
Method Detail
-
withMarshaller
public JaxbBuilder withMarshaller(javax.xml.bind.Marshaller marshaller)
Sets a non-defaultMarshaller
to use when creating theSource
.
-
useObjectFactory
public JaxbBuilder useObjectFactory()
If the given Object has noXmlRootElement
annotation and is not an instants ofJAXBElement
it must be wrapped by aJAXBElement
.This method will find the
ObjectFactory
class (normally generated by jaxb) and use the first matching factory-method for the given Object to create theJAXBElement
-Wrapper.If no ObjectFactory and method exists for the given object, the default behavior (same behavior as by
JAXB
) will be used to create theJAXBElement
-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.
-
build
public javax.xml.transform.Source build()
Description copied from interface:Input.Builder
build the actualSource
instance.- Specified by:
build
in interfaceInput.Builder
-
getPreparedJaxbObject
private java.lang.Object getPreparedJaxbObject()
-
createDefaultMarshaller
private void createDefaultMarshaller() throws javax.xml.bind.JAXBException, javax.xml.bind.PropertyException
- Throws:
javax.xml.bind.JAXBException
javax.xml.bind.PropertyException
-
createInferredJAXBElement
private static <T> javax.xml.bind.JAXBElement<T> createInferredJAXBElement(T object)
-
createJAXBElement
private static <T> javax.xml.bind.JAXBElement<T> createJAXBElement(T jaxbObj)
-
createJaxbElementFromObjectFactory
private static <T> javax.xml.bind.JAXBElement<T> createJaxbElementFromObjectFactory(T obj)
-
getObjectFactoryClass
private static <T> java.lang.Class<?> getObjectFactoryClass(T obj) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
inferName
private static java.lang.String inferName(java.lang.Class clazz)
-
-