Class MicroWriter


  • @Immutable
    public final class MicroWriter
    extends Object
    Utility class for serializing micro document objects.
    Author:
    Philip Helger
    • Method Detail

      • writeToFile

        @Nonnull
        public static com.helger.commons.state.ESuccess writeToFile​(@Nonnull
                                                                    IMicroNode aNode,
                                                                    @Nonnull
                                                                    File aFile)
        Write a Micro Node to a file using the default settings.
        Parameters:
        aNode - The node to be serialized. May be any kind of node (incl. documents). May not be null.
        aFile - The file to write to. May not be null.
        Returns:
        ESuccess
      • writeToFile

        @Nonnull
        public static com.helger.commons.state.ESuccess writeToFile​(@Nonnull
                                                                    IMicroNode aNode,
                                                                    @Nonnull
                                                                    File aFile,
                                                                    @Nonnull
                                                                    IXMLWriterSettings aSettings)
        Write a Micro Node to a file.
        Parameters:
        aNode - The node to be serialized. May be any kind of node (incl. documents). May not be null.
        aFile - The file to write to. May not be null.
        aSettings - The settings to be used for the creation. May not be null.
        Returns:
        ESuccess
      • writeToFile

        @Nonnull
        public static com.helger.commons.state.ESuccess writeToFile​(@Nonnull
                                                                    IMicroNode aNode,
                                                                    @Nonnull
                                                                    Path aPath)
        Write a Micro Node to a file using the default settings.
        Parameters:
        aNode - The node to be serialized. May be any kind of node (incl. documents). May not be null.
        aPath - The file to write to. May not be null.
        Returns:
        ESuccess
      • writeToFile

        @Nonnull
        public static com.helger.commons.state.ESuccess writeToFile​(@Nonnull
                                                                    IMicroNode aNode,
                                                                    @Nonnull
                                                                    Path aPath,
                                                                    @Nonnull
                                                                    IXMLWriterSettings aSettings)
        Write a Micro Node to a file.
        Parameters:
        aNode - The node to be serialized. May be any kind of node (incl. documents). May not be null.
        aPath - The file to write to. May not be null.
        aSettings - The settings to be used for the creation. May not be null.
        Returns:
        ESuccess
      • writeToStream

        @Nonnull
        public static com.helger.commons.state.ESuccess writeToStream​(@Nonnull
                                                                      IMicroNode aNode,
                                                                      @Nonnull @WillClose
                                                                      OutputStream aOS)
        Write a Micro Node to an output stream using the default settings.
        Parameters:
        aNode - The node to be serialized. May be any kind of node (incl. documents). May not be null.
        aOS - The output stream to write to. May not be null. The output stream is closed anyway directly after the operation finishes (on success and on error).
        Returns:
        ESuccess
      • writeToStream

        @Nonnull
        public static com.helger.commons.state.ESuccess writeToStream​(@Nonnull
                                                                      IMicroNode aNode,
                                                                      @Nonnull @WillClose
                                                                      OutputStream aOS,
                                                                      @Nonnull
                                                                      IXMLWriterSettings aSettings)
        Write a Micro Node to an OutputStream.
        Parameters:
        aNode - The node to be serialized. May be any kind of node (incl. documents). May not be null.
        aOS - The output stream to write to. May not be null. The output stream is closed anyway directly after the operation finishes (on success and on error).
        aSettings - The settings to be used for the creation. May not be null.
        Returns:
        ESuccess
      • writeToWriter

        @Nonnull
        public static com.helger.commons.state.ESuccess writeToWriter​(@Nonnull
                                                                      IMicroNode aNode,
                                                                      @Nonnull @WillClose
                                                                      Writer aWriter,
                                                                      @Nonnull
                                                                      IXMLWriterSettings aSettings)
        Write a Micro Node to a Writer.
        Parameters:
        aNode - The node to be serialized. May be any kind of node (incl. documents). May not be null.
        aWriter - The writer to write to. May not be null. The writer is closed anyway directly after the operation finishes (on success and on error).
        aSettings - The settings to be used for the creation. May not be null.
        Returns:
        ESuccess
      • writeToWriter

        @Nonnull
        public static com.helger.commons.state.ESuccess writeToWriter​(@Nonnull
                                                                      IMicroNode aNode,
                                                                      @Nonnull @WillClose
                                                                      Writer aWriter)
        Write a Micro Node to a Writer using the default XMLWriterSettings.DEFAULT_XML_SETTINGS.
        Parameters:
        aNode - The node to be serialized. May be any kind of node (incl. documents). May not be null.
        aWriter - The writer to write to. May not be null. The writer is closed anyway directly after the operation finishes (on success and on error).
        Returns:
        ESuccess
        Since:
        8.6.3
      • getNodeAsString

        @Nullable
        public static String getNodeAsString​(@Nonnull
                                             IMicroNode aNode,
                                             @Nonnull
                                             IXMLWriterSettings aSettings)
        Convert the passed micro node to an XML string using the provided settings.
        Parameters:
        aNode - The node to be converted to a string. May not be null .
        aSettings - The XML writer settings to use. May not be null.
        Returns:
        The string representation of the passed node.
      • getNodeAsBytes

        @Nullable
        public static byte[] getNodeAsBytes​(@Nonnull
                                            IMicroNode aNode,
                                            @Nonnull
                                            IXMLWriterSettings aSettings)
        Convert the passed micro node to an XML byte array using the provided settings.
        Parameters:
        aNode - The node to be converted to a byte array. May not be null .
        aSettings - The XML writer settings to use. May not be null.
        Returns:
        The byte array representation of the passed node.
        Since:
        8.6.3