@NotThreadSafe public abstract class AbstractJAXBMarshaller<JAXBTYPE> extends Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_FORMATTED
Deprecated.
|
static boolean |
DEFAULT_READ_SECURE |
static boolean |
DEFAULT_WRITE_FORMATTED |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractJAXBMarshaller(Class<JAXBTYPE> aType,
IReadableResource... aXSDs)
Constructor.
|
protected |
AbstractJAXBMarshaller(Class<JAXBTYPE> aType,
IReadableResource aXSD)
Constructor.
|
protected |
AbstractJAXBMarshaller(Class<JAXBTYPE> aType,
List<? extends IReadableResource> aXSDs)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
EChange |
clearLastValidationErrors()
Clear the latest parsing errors.
|
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.
|
String |
getAsXMLString(JAXBTYPE aObject)
Utility method to directly convert the passed domain object to an XML
string.
|
CollectingValidationEventHandler |
getCollectingValidationEventHandler()
Get the last created collecting validation event handler.
|
IResourceErrorGroup |
getLastValidationErrors()
Get the parsing errors from the last read/write actions.
|
ValidationEventHandler |
getLastValidationEventHandler()
Get the last created validation event handler.
|
List<IReadableResource> |
getOriginalXSDs() |
IValidationEventHandlerFactory |
getValidationEventHandlerFactory() |
protected void |
handleReadException(JAXBException ex) |
protected void |
handleWriteException(JAXBException ex) |
boolean |
isReadSecure() |
boolean |
isWriteFormatted() |
JAXBTYPE |
read(File aFile)
Read a document from the specified file.
|
JAXBTYPE |
read(InputStream aIS)
Read a document from the specified input stream.
|
JAXBTYPE |
read(IReadableResource aResource)
Read a document from the specified resource.
|
JAXBTYPE |
read(Node aNode)
Read a document from the specified DOM node.
|
JAXBTYPE |
read(Source aSource)
Read a document from the specified source.
|
JAXBTYPE |
read(String sXML)
Read a document from the specified String.
|
EChange |
setReadSecure(boolean bReadSecure)
Enable or disable secure reading.
|
void |
setValidationEventHandlerFactory(IValidationEventHandlerFactory aVEHFactory)
Set another factory to be used to create
ValidationEventHandler
objects. |
EChange |
setWriteFormatted(boolean bWriteFormatted)
Change the way formatting happens when calling write.
|
protected boolean |
useJAXBContextCache()
Should the
JAXBContextCache be used? |
protected abstract JAXBElement<JAXBTYPE> |
wrapObject(JAXBTYPE aObject)
Wrap the passed domain object into a
JAXBElement for marshalling. |
Document |
write(JAXBTYPE aObject)
Convert the passed object to a new DOM document
|
ESuccess |
write(JAXBTYPE aObject,
File aResultFile)
Write the passed object to a
File. |
ESuccess |
write(JAXBTYPE aObject,
IWritableResource aResource)
Write the passed object to an
IWritableResource. |
ESuccess |
write(JAXBTYPE aObject,
Result aResult)
Convert the passed object to XML.
|
public static final boolean DEFAULT_READ_SECURE
public static final boolean DEFAULT_WRITE_FORMATTED
@Deprecated public static final boolean DEFAULT_FORMATTED
protected AbstractJAXBMarshaller(@Nonnull Class<JAXBTYPE> aType, @Nullable IReadableResource aXSD)
aType - The class of the JAXB document implementation type. May not be
null.aXSD - The XSD used to validate document. May be null
indicating that no XSD check is needed.protected AbstractJAXBMarshaller(@Nonnull Class<JAXBTYPE> aType, @Nullable List<? extends IReadableResource> aXSDs)
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.protected AbstractJAXBMarshaller(@Nonnull Class<JAXBTYPE> aType, @Nullable IReadableResource... aXSDs)
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.public final void setValidationEventHandlerFactory(@Nullable IValidationEventHandlerFactory aVEHFactory)
ValidationEventHandler
objects. By default a
CollectingLoggingValidationEventHandlerFactory is used.aVEHFactory - The new factory to be used. May be null.@Nullable public final IValidationEventHandlerFactory getValidationEventHandlerFactory()
CollectingLoggingValidationEventHandlerFactory
is used. May be null if explicitly set.@Nullable public final ValidationEventHandler getLastValidationEventHandler()
CollectingValidationEventHandler.null if
none was created so far.@Nullable public final CollectingValidationEventHandler getCollectingValidationEventHandler()
null if none was created so far.@Nullable public final IResourceErrorGroup getLastValidationErrors()
CollectingValidationEventHandler or wraps one.null in case no
CollectingValidationEventHandler is present.@Nonnull public final EChange clearLastValidationErrors()
CollectingValidationEventHandler or wraps one.EChange.CHANGED if a
CollectingValidationEventHandler was found, and at least
one element was removed from it.@Nonnull public final EChange setReadSecure(boolean bReadSecure)
bReadSecure - true to read secure, false to disable
secure reading.EChangepublic final boolean isReadSecure()
@Nonnull public final EChange setWriteFormatted(boolean bWriteFormatted)
bWriteFormatted - true to write formatted output.EChangepublic final boolean isWriteFormatted()
@Nonnull @Nonempty @ReturnsMutableCopy public final List<IReadableResource> getOriginalXSDs()
null.@OverrideOnDemand protected boolean useJAXBContextCache()
JAXBContextCache be used? Since creating the JAXB
context is quite cost intensive this is recommended.true if the JAXBContextCache should be used,
false otherwise. It's true by default.@Nullable @OverrideOnDemand protected Schema createValidationSchema()
null
indicating that no validation is required.@Nullable public final JAXBTYPE read(@Nonnull File aFile)
aFile - The file to read. May not be null.null in case reading fails.@Nullable public final JAXBTYPE read(@Nonnull IReadableResource aResource)
aResource - The resource to read. May not be null.null in case reading fails.@Nullable public final JAXBTYPE read(@Nonnull InputStream aIS)
aIS - The input stream to read. May not be null.null in case reading fails.@Nullable public final JAXBTYPE read(@Nonnull String sXML)
sXML - The XML string to read. May not be null.null in case reading fails.@Nullable public final JAXBTYPE read(@Nonnull Node aNode)
aNode - The DOM node to read. May not be null.null in case reading fails.@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 Source aSource)
aSource - The source to read. May not be null.null in case reading fails.@Nonnull protected abstract JAXBElement<JAXBTYPE> wrapObject(@Nonnull JAXBTYPE aObject)
JAXBElement for marshalling.
This can usually be done using the respective's package ObjectFactory
implementation.aObject - The object to be wrapped.JAXBElement wrapping the document.@Nullable public final Document write(@Nonnull JAXBTYPE aObject)
aObject - The object to be converted. May not be null.null if converting the document failed.@Nonnull public final ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull File aResultFile)
File.aObject - The object to be written. May not be null.aResultFile - The result file to be written to. May not be null.ESuccess@Nonnull public final ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull IWritableResource aResource)
IWritableResource.aObject - The object to be written. May not be null.aResource - The result resource to be written to. May not be null.ESuccess@OverrideOnDemand protected void customizeMarshaller(@Nonnull Marshaller aMarshaller)
aMarshaller - The object to customize. Never null.@OverrideOnDemand protected void handleWriteException(@Nonnull JAXBException ex)
@Nonnull public final ESuccess write(@Nonnull JAXBTYPE aObject, @Nonnull Result aResult)
aObject - The object to be converted. May not be null.aResult - The result object holder. May not be null.ESuccess@Nullable public final String getAsXMLString(@Nonnull JAXBTYPE aObject)
aObject - The domain object to be converted. May not be null.null if the passed domain object could not be
converted because of validation errors.Copyright © 2006–2015 phloc systems. All rights reserved.