Interface StreamWriter

    • Method Detail

      • getPostfix

        String getPostfix()
        Returns a string of data that must appear at the end of the data stream.
        Returns:
        postfix
      • getPrefix

        String getPrefix()
        Returns a string of data that must appear at the start of the data stream. E.g. a namespace declaration.
        Returns:
        prefix
      • writeStartDocument

        void writeStartDocument()
                         throws Exception
        Writes the data that is compulsory to appear at the start of the data structure.
        E.g. for XML this might be: <?xml version="1.0" ?>
        Throws:
        Exception - Any exception thrown while writing. E.g. for JSON this might be a JsonGenerationException.
      • writeEndDocument

        void writeEndDocument()
                       throws Exception
        Writes the data that is compulsory to appear at the end of the data structure.
        Throws:
        Exception - Any exception thrown while writing. E.g. for JSON this might be a JsonGenerationException.
      • writeStartObject

        void writeStartObject​(String element)
                       throws Exception
        Writes the start of a new object, with the specified name.
        Parameters:
        element - The name of the object
        Throws:
        Exception - Any exception thrown while writing. E.g. for JSON this might be a JsonGenerationException.
      • writeEndObject

        void writeEndObject()
                     throws Exception
        Writes the end of an object. An object must have been started, or an exception will be thrown.
        Throws:
        Exception - Any exception thrown while writing. E.g. for JSON this might be a JsonGenerationException.
      • writeStartArray

        void writeStartArray​(String element)
                      throws Exception
        Writes the start of an array, with the specified name. If the data structure doesn't support arrays, this method will do nothing.
        Parameters:
        element - The name of the array
        Throws:
        Exception - Any exception thrown while writing. E.g. for JSON this might be a JsonGenerationException.
      • writeEndArray

        void writeEndArray()
                    throws Exception
        Writes the end of an array. An array must have been started, or an exception will be thrown. If the data structure doesn't support arrays, this method will do nothing.
        Throws:
        Exception - Any exception thrown while writing. E.g. for JSON this might be a JsonGenerationException.
      • writeAttribute

        void writeAttribute​(String name,
                            String value)
                     throws Exception
        Writes a String attribute with the specified name and value. E.g. for JSON this will write: "name":"value".
        Parameters:
        name - The name of the attribute
        value - The value of the attribute
        Throws:
        Exception - Any exception thrown while writing. E.g. for JSON this might be a JsonGenerationException.
      • writeAttribute

        void writeAttribute​(String name,
                            Boolean value)
                     throws Exception
        Writes a Boolean attribute with the specified name and value. E.g. for JSON this will write: "name":true/false.
        Parameters:
        name - The name of the attribute
        value - The value of the attribute
        Throws:
        Exception - Any exception thrown while writing. E.g. for JSON this might be a JsonGenerationException.
      • close

        void close()
            throws Exception
        Closes the OutputStream associated with this object. Some OutputStreams require closing before any data will be written.
        Throws:
        Exception - Any exception thrown while closing the OutputStream. E.g. for JSON this might be a JsonGenerationException.