JAXBTYPE - The JAXB type to be marshaled@NotThreadSafe public class GenericJAXBMarshaller<JAXBTYPE> extends Object implements com.helger.commons.lang.IHasClassLoader, IJAXBReader<JAXBTYPE>, IJAXBWriter<JAXBTYPE>
IJAXBReader.IJAXBUnmarshaller<JAXBTYPE>IJAXBWriter.IJAXBMarshaller<JAXBTYPE>| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_READ_SECURE |
USE_JAXB_CHARSET_FIX| Constructor and Description |
|---|
GenericJAXBMarshaller(Class<JAXBTYPE> aType,
com.helger.commons.functional.IFunction<? super JAXBTYPE,? extends JAXBElement<JAXBTYPE>> aWrapper)
Constructor without XSD paths.
|
GenericJAXBMarshaller(Class<JAXBTYPE> aType,
List<? extends com.helger.commons.io.resource.ClassPathResource> aXSDs,
com.helger.commons.functional.IFunction<? super JAXBTYPE,? extends JAXBElement<JAXBTYPE>> aJAXBElementWrapper)
Constructor with XSD paths.
|
| Modifier and Type | Method and Description |
|---|---|
protected Schema |
createValidationSchema() |
protected void |
customizeMarshaller(Marshaller aMarshaller)
Customize the passed marshaller before marshalling something.
|
protected void |
customizeUnmarshaller(Unmarshaller aUnmarshaller)
Customize the passed unmarshaller before unmarshalling (reading) something.
|
Charset |
getCharset() |
ClassLoader |
getClassLoader() |
String |
getIndentString() |
com.helger.xml.namespace.INamespaceContext |
getNamespaceContext() |
String |
getNoNamespaceSchemaLocation() |
com.helger.commons.collection.impl.ICommonsList<com.helger.commons.io.resource.ClassPathResource> |
getOriginalXSDs() |
String |
getSchemaLocation() |
IValidationEventHandlerFactory |
getValidationEventHandlerFactory() |
protected void |
handleReadException(JAXBException ex) |
protected void |
handleWriteException(JAXBException ex) |
boolean |
isFormattedOutput() |
boolean |
isReadSecure()
Check if secure reading is enabled.
|
boolean |
isUseContextCache() |
JAXBTYPE |
read(IJAXBReader.IJAXBUnmarshaller<JAXBTYPE> aHandler)
Read a document using the passed handler.
|
com.helger.commons.state.EChange |
setCharset(Charset aCharset)
Set the charset to be used for writing JAXB objects.
|
void |
setClassLoader(ClassLoader aClassLoader)
Deprecated.
|
com.helger.commons.state.EChange |
setFormattedOutput(boolean bWriteFormatted)
Change the way formatting happens when calling write.
|
com.helger.commons.state.EChange |
setIndentString(String sIndentString)
Set the indent string to be used for writing JAXB objects.
|
com.helger.commons.state.EChange |
setNamespaceContext(com.helger.xml.namespace.INamespaceContext aNSContext)
Set the namespace context (prefix to namespace URL mapping) to be used.
|
com.helger.commons.state.EChange |
setNoNamespaceSchemaLocation(String sNoNamespaceSchemaLocation)
Set the no namespace schema location to be used for writing JAXB objects.
|
com.helger.commons.state.EChange |
setReadSecure(boolean bReadSecure)
Enable or disable secure reading.
|
com.helger.commons.state.EChange |
setSchemaLocation(String sSchemaLocation)
Set the schema location to be used for writing JAXB objects.
|
com.helger.commons.state.EChange |
setUseContextCache(boolean bUseContextCache)
Change whether the context cache should be used or not.
|
void |
setValidationEventHandlerFactory(IValidationEventHandlerFactory aVEHFactory)
Set a factory to be used to create
ValidationEventHandler objects. |
String |
toString() |
com.helger.commons.state.ESuccess |
write(JAXBTYPE aObject,
IJAXBWriter.IJAXBMarshaller<JAXBTYPE> aMarshallerFunc)
Convert the passed object to XML.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitread, read, read, read, read, read, read, read, read, read, read, read, read, read, read, readgetAsByteBuffer, getAsBytes, getAsDocument, getAsMicroDocument, getAsMicroElement, getAsString, getXMLWriterSettings, hasCharset, hasIndentString, hasNoNamespaceSchemaLocation, hasSchemaLocation, write, write, write, write, write, write, write, write, writepublic static final boolean DEFAULT_READ_SECURE
public GenericJAXBMarshaller(@Nonnull Class<JAXBTYPE> aType, @Nonnull com.helger.commons.functional.IFunction<? super JAXBTYPE,? extends JAXBElement<JAXBTYPE>> aWrapper)
aType - The class of the JAXB document implementation type. May not be
null.aWrapper - Wrap the passed domain object into a JAXBElement for
marshalling (writing). This can usually be done using the
respective's package ObjectFactory implementation. May not be
null.public GenericJAXBMarshaller(@Nonnull Class<JAXBTYPE> aType, @Nullable List<? extends com.helger.commons.io.resource.ClassPathResource> aXSDs, @Nonnull com.helger.commons.functional.IFunction<? super JAXBTYPE,? extends JAXBElement<JAXBTYPE>> aJAXBElementWrapper)
aType - The class of the JAXB document implementation type. May not be
null.aXSDs - The XSDs used to validate document. May be null or
empty indicating, that no XSD check is needed.aJAXBElementWrapper - Wrap the passed domain object into a JAXBElement for
marshalling (writing). This can usually be done using the
respective's package ObjectFactory implementation. May not be
null.@Deprecated @DevelopersNote(value="Deprecated since v9.0.0") public final void setClassLoader(@Nullable ClassLoader aClassLoader)
aClassLoader - The class loader to be used. May be null.@Nullable public final ClassLoader getClassLoader()
getClassLoader in interface com.helger.commons.lang.IHasClassLoaderpublic final void setValidationEventHandlerFactory(@Nullable IValidationEventHandlerFactory aVEHFactory)
ValidationEventHandler objects.
By default none is present.aVEHFactory - The new factory to be used. May be null.@Nullable public final IValidationEventHandlerFactory getValidationEventHandlerFactory()
null if explicitly set.public final boolean isReadSecure()
IJAXBReaderisReadSecure in interface IJAXBReader<JAXBTYPE>true if secure reading is enabled.@Nonnull public final com.helger.commons.state.EChange setReadSecure(boolean bReadSecure)
bReadSecure - true to read secure, false to disable
secure reading.EChange@Nullable public final com.helger.xml.namespace.INamespaceContext getNamespaceContext()
getNamespaceContext in interface IJAXBWriter<JAXBTYPE>null.@Nonnull public com.helger.commons.state.EChange setNamespaceContext(@Nullable com.helger.xml.namespace.INamespaceContext aNSContext)
aNSContext - The namespace context to be used. May be null.EChangepublic final boolean isFormattedOutput()
isFormattedOutput in interface IJAXBWriter<JAXBTYPE>true if the JAXB output should be formatted. Default
is false.@Nonnull public final com.helger.commons.state.EChange setFormattedOutput(boolean bWriteFormatted)
bWriteFormatted - true to write formatted output.EChange@Nullable public Charset getCharset()
getCharset in interface IJAXBWriter<JAXBTYPE>null
by default.@Nonnull public com.helger.commons.state.EChange setCharset(@Nullable Charset aCharset)
aCharset - The charset to be used by default. May be null.EChange@Nullable public String getIndentString()
getIndentString in interface IJAXBWriter<JAXBTYPE>null by default. Only used when formatted output is
used.@Nonnull public com.helger.commons.state.EChange setIndentString(@Nullable String sIndentString)
sIndentString - The indent string to be used. May be null.EChange@Nullable public String getSchemaLocation()
getSchemaLocation in interface IJAXBWriter<JAXBTYPE>null by
default.@Nonnull public com.helger.commons.state.EChange setSchemaLocation(@Nullable String sSchemaLocation)
sSchemaLocation - The schema location to be used. May be null.EChange@Nullable public String getNoNamespaceSchemaLocation()
getNoNamespaceSchemaLocation in interface IJAXBWriter<JAXBTYPE>null by default.@Nonnull public com.helger.commons.state.EChange setNoNamespaceSchemaLocation(@Nullable String sNoNamespaceSchemaLocation)
sNoNamespaceSchemaLocation - The no namespace schema location to be used. May be
null.EChange@Nonnull public final com.helger.commons.state.EChange setUseContextCache(boolean bUseContextCache)
bUseContextCache - true to use it (default), false if not.EChangepublic final boolean isUseContextCache()
@Nonnull @Nonempty @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<com.helger.commons.io.resource.ClassPathResource> getOriginalXSDs()
null.@Nullable protected Schema createValidationSchema()
null
indicating that no validation is required.@OverrideOnDemand protected void customizeUnmarshaller(@Nonnull Unmarshaller aUnmarshaller)
aUnmarshaller - The object to customize. Never null.@OverrideOnDemand protected void handleReadException(@Nonnull JAXBException ex)
@Nullable public final JAXBTYPE read(@Nonnull IJAXBReader.IJAXBUnmarshaller<JAXBTYPE> aHandler)
IJAXBReaderread in interface IJAXBReader<JAXBTYPE>aHandler - The unmarshalling handler. May not be null.null in case reading fails.@OverrideOnDemand protected void customizeMarshaller(@Nonnull Marshaller aMarshaller)
aMarshaller - The object to customize. Never null.@OverrideOnDemand protected void handleWriteException(@Nonnull JAXBException ex)
@Nonnull public final com.helger.commons.state.ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull IJAXBWriter.IJAXBMarshaller<JAXBTYPE> aMarshallerFunc)
IJAXBWriterwrite in interface IJAXBWriter<JAXBTYPE>aObject - The object to be converted. May not be null.aMarshallerFunc - The marshalling function. May not be null.ESuccessCopyright © 2015–2018 Philip Helger. All rights reserved.