Package eu.de4a.iem.xml
Interface IJAXBVersatileWriter<T>
-
- Type Parameters:
T- Type to be written.
- All Superinterfaces:
IVersatileWriter<T>
- All Known Implementing Classes:
JAXBVersatileWriter
public interface IJAXBVersatileWriter<T> extends IVersatileWriter<T>
Default implementation ofIVersatileWriterbased onIJAXBWriter.- Author:
- Philip Helger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ByteBuffergetAsByteBuffer()Write the passed object to aByteBufferand return it (write).default byte[]getAsBytes()Write the passed object to a byte array and return the created byte array (write).default DocumentgetAsDocument()Convert the passed object to a new DOM document (write).default com.helger.commons.io.stream.NonBlockingByteArrayInputStreamgetAsInputStream()Write the passed object to a byte array and return the input stream on that array.default com.helger.xml.microdom.IMicroDocumentgetAsMicroDocument()Convert the passed object to a new micro document (write).default com.helger.xml.microdom.IMicroElementgetAsMicroElement()Convert the passed object to a new micro document and return only the root element (write).default StringgetAsString()Utility method to directly convert the passed domain object to an XML string (write).TgetObjectToWrite()com.helger.jaxb.IJAXBWriter<T>getWriter()default com.helger.commons.state.ESuccesswrite(com.helger.commons.io.resource.IWritableResource aResource)Write the passed object to anIWritableResource.default com.helger.commons.state.ESuccesswrite(com.helger.jaxb.IJAXBWriter.IJAXBMarshaller<T> aMarshallerFunc)Convert the passed object to XML.default com.helger.commons.state.ESuccesswrite(File aResultFile)Write the passed object to aFile.default com.helger.commons.state.ESuccesswrite(OutputStream aOS)Write the passed object to anOutputStream.default com.helger.commons.state.ESuccesswrite(Writer aWriter)Write the passed object to aWriter.default com.helger.commons.state.ESuccesswrite(ByteBuffer aBuffer)Write the passed object to aByteBuffer.default com.helger.commons.state.ESuccesswrite(Path aResultPath)Write the passed object to aPath.default com.helger.commons.state.ESuccesswrite(XMLStreamWriter aWriter)Convert the passed object to XML.default com.helger.commons.state.ESuccesswrite(Result aResult)Convert the passed object to XML.default com.helger.commons.state.ESuccesswrite(ContentHandler aHandler)Convert the passed object to XML.
-
-
-
Method Detail
-
getObjectToWrite
@Nonnull T getObjectToWrite()
- Returns:
- The object to write. May not be
null.
-
getWriter
@Nonnull com.helger.jaxb.IJAXBWriter<T> getWriter()
- Returns:
- The JAXB writer to use. May not be
null.
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull File aResultFile)Write the passed object to aFile.- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aResultFile- The result file to be written to. May not benull.- Returns:
ESuccess
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull Path aResultPath)Write the passed object to aPath.- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aResultPath- The result path to be written to. May not benull.- Returns:
ESuccess
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull @WillClose OutputStream aOS)Write the passed object to anOutputStream.- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aOS- The output stream to write to. Will always be closed. May not benull.- Returns:
ESuccess
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull @WillClose Writer aWriter)Write the passed object to aWriter.- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aWriter- The writer to write to. Will always be closed. May not benull.- Returns:
ESuccess
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull ByteBuffer aBuffer)Write the passed object to aByteBuffer.- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aBuffer- The byte buffer to write to. If the buffer is too small, it is automatically extended. May not benull.- Returns:
ESuccess- Throws:
BufferOverflowException- If the ByteBuffer is too small
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull com.helger.commons.io.resource.IWritableResource aResource)Write the passed object to anIWritableResource.- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aResource- The result resource to be written to. May not benull.- Returns:
ESuccess
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull com.helger.jaxb.IJAXBWriter.IJAXBMarshaller<T> aMarshallerFunc)Convert the passed object to XML.- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aMarshallerFunc- The marshalling function. May not benull.- Returns:
ESuccess
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull Result aResult)Convert the passed object to XML. This method is potentially dangerous, when using StreamResult because it may create invalid XML. Only when using theSafeXMLStreamWriterit is ensured that only valid XML is created!- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aResult- The result object holder. May not benull. Usually SAXResult, DOMResult and StreamResult are supported.- Returns:
ESuccess
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull ContentHandler aHandler)Convert the passed object to XML.- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aHandler- XML will be sent to this handler as SAX2 events. May not benull.- Returns:
ESuccess
-
write
@Nonnull default com.helger.commons.state.ESuccess write(@Nonnull @WillClose XMLStreamWriter aWriter)Convert the passed object to XML.- Specified by:
writein interfaceIVersatileWriter<T>- Parameters:
aWriter- XML will be sent to this writer. May not benull.- Returns:
ESuccess
-
getAsDocument
@Nullable default Document getAsDocument()
Convert the passed object to a new DOM document (write).- Specified by:
getAsDocumentin interfaceIVersatileWriter<T>- Returns:
nullif converting the document failed.
-
getAsMicroDocument
@Nullable default com.helger.xml.microdom.IMicroDocument getAsMicroDocument()
Convert the passed object to a new micro document (write).- Specified by:
getAsMicroDocumentin interfaceIVersatileWriter<T>- Returns:
nullif converting the document failed.
-
getAsMicroElement
@Nullable default com.helger.xml.microdom.IMicroElement getAsMicroElement()
Convert the passed object to a new micro document and return only the root element (write).- Specified by:
getAsMicroElementin interfaceIVersatileWriter<T>- Returns:
nullif converting the document failed.
-
getAsString
@Nullable default String getAsString()
Utility method to directly convert the passed domain object to an XML string (write).- Specified by:
getAsStringin interfaceIVersatileWriter<T>- Returns:
nullif the passed domain object could not be converted because of validation errors.
-
getAsByteBuffer
@Nullable default ByteBuffer getAsByteBuffer()
Write the passed object to aByteBufferand return it (write).- Specified by:
getAsByteBufferin interfaceIVersatileWriter<T>- Returns:
nullif the passed domain object could not be converted because of validation errors.
-
getAsBytes
@Nullable default byte[] getAsBytes()
Write the passed object to a byte array and return the created byte array (write).- Specified by:
getAsBytesin interfaceIVersatileWriter<T>- Returns:
nullif the passed domain object could not be converted because of validation errors.
-
getAsInputStream
@Nullable default com.helger.commons.io.stream.NonBlockingByteArrayInputStream getAsInputStream()
Write the passed object to a byte array and return the input stream on that array.- Specified by:
getAsInputStreamin interfaceIVersatileWriter<T>- Returns:
nullif the passed domain object could not be converted because of validation errors.
-
-