Class CompositeJsonWriter

java.lang.Object
com.aquima.interactions.foundation.json.writer.CompositeJsonWriter
All Implemented Interfaces:
IJsonWriter

public class CompositeJsonWriter extends Object implements IJsonWriter
This class is an IJsonWriter implementation that can combine multiple json writers.
Since:
7.0
Author:
Jon van Leuven
  • Constructor Details

    • CompositeJsonWriter

      public CompositeJsonWriter(IJsonWriter writer1, IJsonWriter writer2)
      Create a composite json writer with 2 delegate writers.
      Parameters:
      writer1 - The first writer to delegate all json writer calls to. Will be called before the second writer.
      writer2 - The second writer to delegate all json writer calls to. Will be called after the first writer.
    • CompositeJsonWriter

      public CompositeJsonWriter(IJsonWriter[] writers)
      Construct a composite writer with an array of writers.
      Parameters:
      writers - The writers to delegate all json writer calls to (writers[0] will be called before writers[1], etc)
  • Method Details

    • close

      public void close() throws IOException
      Close this (and its internal) writer.
      Specified by:
      close in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeArrayEnd

      public void writeArrayEnd() throws IOException
      End appending an array.
      Specified by:
      writeArrayEnd in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeArrayStart

      public void writeArrayStart() throws IOException
      Begin appending an array.
      Specified by:
      writeArrayStart in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeArrayStart

      public void writeArrayStart(String memberName) throws IOException
      Begin appending an array with a name.
      Specified by:
      writeArrayStart in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName) throws IOException
      Appending a member.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName, long longValue) throws IOException
      Append a member with a long value.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      longValue - The value of the member.
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName, double doubleValue) throws IOException
      Append a member with a double value.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      doubleValue - The value of the member.
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName, boolean booleanValue) throws IOException
      Append a member with a boolean value.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      booleanValue - The value of the member.
      Throws:
      IOException - If an I/O error occurs.
    • writeMember

      public void writeMember(String memberName, String strValue) throws IOException
      Append a member with a string value.
      Specified by:
      writeMember in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      strValue - The value of the member.
      Throws:
      IOException - If an I/O error occurs.
    • writeNull

      public void writeNull(String memberName) throws IOException
      Append a member with a null value.
      Specified by:
      writeNull in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      Throws:
      IOException - If an I/O error occurs.
    • writeObjectEnd

      public void writeObjectEnd() throws IOException
      End appending an object.
      Specified by:
      writeObjectEnd in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeObjectStart

      public void writeObjectStart() throws IOException
      Begin appending an object.
      Specified by:
      writeObjectStart in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.
    • writeObjectStart

      public void writeObjectStart(String memberName) throws IOException
      Begin appending an object with a name.
      Specified by:
      writeObjectStart in interface IJsonWriter
      Parameters:
      memberName - The member name, may not be null or empty.
      Throws:
      IOException - If an I/O error occurs.
    • writeValue

      public void writeValue(long longValue) throws IOException
      Append a long value.
      Specified by:
      writeValue in interface IJsonWriter
      Parameters:
      longValue - The value.
      Throws:
      IOException - If an I/O error occurs.
    • writeValue

      public void writeValue(double doubleValue) throws IOException
      Append a double value.
      Specified by:
      writeValue in interface IJsonWriter
      Parameters:
      doubleValue - The value.
      Throws:
      IOException - If an I/O error occurs.
    • writeValue

      public void writeValue(boolean booleanValue) throws IOException
      Append a boolean value.
      Specified by:
      writeValue in interface IJsonWriter
      Parameters:
      booleanValue - The value.
      Throws:
      IOException - If an I/O error occurs.
    • writeValue

      public void writeValue(String strValue) throws IOException
      Append a string value.
      Specified by:
      writeValue in interface IJsonWriter
      Parameters:
      strValue - The value.
      Throws:
      IOException - If an I/O error occurs.
    • writeValueNull

      public void writeValueNull() throws IOException
      Append a null value.
      Specified by:
      writeValueNull in interface IJsonWriter
      Throws:
      IOException - If an I/O error occurs.