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.Builderfor Jaxb-Object and creating aJAXBSource.If no custom
Marshalleris set bywithMarshaller(Marshaller), then the same logic as inJAXBis used the create a defaultMarshaller.
-
-
Field Summary
Fields Modifier and Type Field Description private javax.xml.bind.Marshallermarshallerprivate java.lang.Objectobjectprivate booleanuserObjectFactory
-
Constructor Summary
Constructors Modifier Constructor Description protectedJaxbBuilder(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.Sourcebuild()build the actualSourceinstance.private voidcreateDefaultMarshaller()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.ObjectgetPreparedJaxbObject()private static java.lang.StringinferName(java.lang.Class clazz)JaxbBuilderuseObjectFactory()If the given Object has noXmlRootElementannotation and is not an instants ofJAXBElementit must be wrapped by aJAXBElement.JaxbBuilderwithMarshaller(javax.xml.bind.Marshaller marshaller)Sets a non-defaultMarshallerto use when creating theSource.
-
-
-
Method Detail
-
withMarshaller
public JaxbBuilder withMarshaller(javax.xml.bind.Marshaller marshaller)
Sets a non-defaultMarshallerto use when creating theSource.
-
useObjectFactory
public JaxbBuilder useObjectFactory()
If the given Object has noXmlRootElementannotation and is not an instants ofJAXBElementit must be wrapped by aJAXBElement.This method will find the
ObjectFactoryclass (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:simpleflag 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.Builderbuild the actualSourceinstance.- Specified by:
buildin 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.JAXBExceptionjavax.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)
-
-