Package eu.de4a.iem.xml
Interface IVersatileWriter<T>
-
- Type Parameters:
T- Type to be written.
- All Known Subinterfaces:
IJAXBVersatileWriter<T>
- All Known Implementing Classes:
JAXBVersatileWriter
public interface IVersatileWriter<T>Base interface for something that can be written to different destinations.- Author:
- Philip Helger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ByteBuffergetAsByteBuffer()Write the object to aByteBufferand return it (write).byte[]getAsBytes()Write the object to a byte array and return the created byte array (write).DocumentgetAsDocument()Convert the object to a new DOM document (write).com.helger.commons.io.stream.NonBlockingByteArrayInputStreamgetAsInputStream()Write the object to a byte array and return the input stream on that array.com.helger.xml.microdom.IMicroDocumentgetAsMicroDocument()Convert the object to a new micro document (write).com.helger.xml.microdom.IMicroElementgetAsMicroElement()Convert the object to a new micro document and return only the root element (write).StringgetAsString()Utility method to directly convert the passed domain object to an XML string (write).com.helger.commons.state.ESuccesswrite(com.helger.commons.io.resource.IWritableResource aResource)Write the object to anIWritableResource.com.helger.commons.state.ESuccesswrite(com.helger.jaxb.IJAXBWriter.IJAXBMarshaller<T> aMarshallerFunc)Convert the object to XML.com.helger.commons.state.ESuccesswrite(File aResultFile)Write the object to aFile.com.helger.commons.state.ESuccesswrite(OutputStream aOS)Write the object to anOutputStream.com.helger.commons.state.ESuccesswrite(Writer aWriter)Write the object to aWriter.com.helger.commons.state.ESuccesswrite(ByteBuffer aBuffer)Write the object to aByteBuffer.com.helger.commons.state.ESuccesswrite(Path aResultPath)Write the object to aPath.com.helger.commons.state.ESuccesswrite(XMLStreamWriter aWriter)Convert the object to XML.com.helger.commons.state.ESuccesswrite(Result aResult)Convert the object to XML.com.helger.commons.state.ESuccesswrite(ContentHandler aHandler)Convert the object to XML.
-
-
-
Method Detail
-
write
@Nonnull com.helger.commons.state.ESuccess write(@Nonnull File aResultFile)Write the object to aFile.- Parameters:
aResultFile- The result file to be written to. May not benull.- Returns:
ESuccess
-
write
@Nonnull com.helger.commons.state.ESuccess write(@Nonnull Path aResultPath)Write the object to aPath.- Parameters:
aResultPath- The result path to be written to. May not benull.- Returns:
ESuccess
-
write
@Nonnull com.helger.commons.state.ESuccess write(@Nonnull @WillClose OutputStream aOS)Write the object to anOutputStream.- Parameters:
aOS- The output stream to write to. Will always be closed. May not benull.- Returns:
ESuccess
-
write
@Nonnull com.helger.commons.state.ESuccess write(@Nonnull @WillClose Writer aWriter)Write the object to aWriter.- Parameters:
aWriter- The writer to write to. Will always be closed. May not benull.- Returns:
ESuccess
-
write
@Nonnull com.helger.commons.state.ESuccess write(@Nonnull ByteBuffer aBuffer)Write the object to aByteBuffer.- 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 com.helger.commons.state.ESuccess write(@Nonnull com.helger.commons.io.resource.IWritableResource aResource)Write the object to anIWritableResource.- Parameters:
aResource- The result resource to be written to. May not benull.- Returns:
ESuccess
-
write
@Nonnull com.helger.commons.state.ESuccess write(@Nonnull com.helger.jaxb.IJAXBWriter.IJAXBMarshaller<T> aMarshallerFunc)Convert the object to XML.- Parameters:
aMarshallerFunc- The marshalling function. May not benull.- Returns:
ESuccess
-
write
@Nonnull com.helger.commons.state.ESuccess write(@Nonnull Result aResult)Convert the 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!- Parameters:
aResult- The result object holder. May not benull. Usually SAXResult, DOMResult and StreamResult are supported.- Returns:
ESuccess
-
write
@Nonnull com.helger.commons.state.ESuccess write(@Nonnull ContentHandler aHandler)Convert the object to XML.- Parameters:
aHandler- XML will be sent to this handler as SAX2 events. May not benull.- Returns:
ESuccess
-
write
@Nonnull com.helger.commons.state.ESuccess write(@Nonnull @WillClose XMLStreamWriter aWriter)Convert the object to XML.- Parameters:
aWriter- XML will be sent to this writer. May not benull.- Returns:
ESuccess
-
getAsDocument
@Nullable Document getAsDocument()
Convert the object to a new DOM document (write).- Returns:
nullif converting the document failed.
-
getAsMicroDocument
@Nullable com.helger.xml.microdom.IMicroDocument getAsMicroDocument()
Convert the object to a new micro document (write).- Returns:
nullif converting the document failed.
-
getAsMicroElement
@Nullable com.helger.xml.microdom.IMicroElement getAsMicroElement()
Convert the object to a new micro document and return only the root element (write).- Returns:
nullif converting the document failed.
-
getAsString
@Nullable String getAsString()
Utility method to directly convert the passed domain object to an XML string (write).- Returns:
nullif the passed domain object could not be converted because of validation errors.
-
getAsByteBuffer
@Nullable ByteBuffer getAsByteBuffer()
Write the object to aByteBufferand return it (write).- Returns:
nullif the passed domain object could not be converted because of validation errors.
-
getAsBytes
@Nullable byte[] getAsBytes()
Write the object to a byte array and return the created byte array (write).- Returns:
nullif the passed domain object could not be converted because of validation errors.
-
getAsInputStream
@Nullable com.helger.commons.io.stream.NonBlockingByteArrayInputStream getAsInputStream()
Write the object to a byte array and return the input stream on that array.- Returns:
nullif the passed domain object could not be converted because of validation errors.
-
-