Interface Builder

  • All Known Implementing Classes:
    JSONBuilder

    public interface Builder
    Interface for implement the methods to create generic data holding model of data mapper engine
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Method called to close builder, so that no more content can be written.
      String getContent()
      Methid called to get the final content after closing the builder
      void writeArrayFieldStart​(String fieldName)
      Convenience method for outputting a field entry ("member") (that will contain a JSON Array value), and the START_ARRAY marker.
      void writeBinary​(byte[] data, int offset, int len)
      Method that will output given chunk of binary data as base64 encoded, as a complete String value (surrounded by double quotes).
      void writeBinaryField​(String fieldName, byte[] data)
      Convenience method for outputting a field entry ("member") that contains specified data in base64-encoded form.
      void writeBoolean​(boolean state)
      Method for outputting literal boolean value (one of Strings 'true' and 'false').
      void writeBooleanField​(String fieldName, boolean value)
      Convenience method for outputting a field entry ("member") that has a boolean value.
      void writeEndArray()
      Method for writing closing marker of a Array.
      void writeEndObject()
      Method for writing closing marker of a Object value.
      void writeField​(String fieldName, Object value, String fieldType)
      Convenience method for outputting a field entry ("member") that has a String value.
      void writeFieldName​(String name)
      Method for writing a field name.
      void writeNumber​(double number)
      Method for outputting indicate JSON numeric value.
      void writeNumber​(int number)
      Method for outputting given value as number.
      void writeNumberField​(String fieldName, double value)
      Convenience method for outputting a field entry ("member") that has the specified numeric value.
      void writeNumberField​(String fieldName, int value)
      Convenience method for outputting a field entry ("member") that has the specified numeric value.
      void writeObjectFieldStart​(String fieldName)
      Convenience method for outputting a field entry ("member") (that will contain a JSON Object value), and the START_OBJECT marker.
      void writePrimitive​(Object value, String fieldType)
      Convenience method for outputting a primitive that has a primitive value.
      void writeStartArray()
      Method for writing start marker of a Array value.
      void writeStartObject()
      Method for writing starting marker of a Object value.
      void writeString​(String text)
      Method for outputting a String value.
      void writeStringField​(String fieldName, String value)
      Convenience method for outputting a field entry ("member") that has a String value.
    • Method Detail

      • writeStartArray

        void writeStartArray()
                      throws IOException
        Method for writing start marker of a Array value.

        Array values can be written in any context where values are allowed: meaning everywhere except for when a field name is expected.

        Throws:
        IOException
      • writeEndArray

        void writeEndArray()
                    throws IOException
        Method for writing closing marker of a Array.

        Marker can be written if the innermost structured type is Array.

        Throws:
        IOException
      • writeStartObject

        void writeStartObject()
                       throws IOException
        Method for writing starting marker of a Object value.

        Object values can be written in any context where values are allowed: meaning everywhere except for when a field name is expected.

        Throws:
        IOException
      • writeEndObject

        void writeEndObject()
                     throws IOException
        Method for writing closing marker of a Object value.

        Marker can be written if the innermost structured type is Object, and the last written event was either a complete value, or START-OBJECT marker

        Throws:
        IOException
      • writeFieldName

        void writeFieldName​(String name)
                     throws IOException
        Method for writing a field name.

        Field names can only be written in Object context , when field name is expected

        Throws:
        IOException
      • writeString

        void writeString​(String text)
                  throws IOException
        Method for outputting a String value. Depending on context this means either array element, (object) field value or a stand alone String; but in all cases, String will be surrounded in double quotes, and contents will be properly escaped.
        Throws:
        IOException
      • writeBinary

        void writeBinary​(byte[] data,
                         int offset,
                         int len)
                  throws IOException
        Method that will output given chunk of binary data as base64 encoded, as a complete String value (surrounded by double quotes). This method defaults

        Alternatively if linefeeds are not included, resulting String value may violate the requirement of base64 RFC which mandates line-length of 76 characters and use of linefeeds. However, all Parser implementations are required to accept such "long line base64"; as do typical production-level base64 decoders.

        Throws:
        IOException
      • writeNumber

        void writeNumber​(int number)
                  throws IOException
        Method for outputting given value as number. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
        Parameters:
        number - Number value to write
        Throws:
        IOException
      • writeNumber

        void writeNumber​(double number)
                  throws IOException
        Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object field value, root-level value).
        Parameters:
        number - Number value to write
        Throws:
        IOException
      • writeBoolean

        void writeBoolean​(boolean state)
                   throws IOException
        Method for outputting literal boolean value (one of Strings 'true' and 'false'). Can be called in any context where a value is expected (Array value, Object field value, root-level value).
        Throws:
        IOException
      • writeStringField

        void writeStringField​(String fieldName,
                              String value)
                       throws IOException
        Convenience method for outputting a field entry ("member") that has a String value. Equivalent to:
          writeFieldName(fieldName);
          writeString(value);
         
        Throws:
        IOException
      • writeField

        void writeField​(String fieldName,
                        Object value,
                        String fieldType)
                 throws IOException
        Convenience method for outputting a field entry ("member") that has a String value. Equivalent to:
          writeFieldName(fieldName);
          writeString(value);
         
        Throws:
        IOException
      • writeBooleanField

        void writeBooleanField​(String fieldName,
                               boolean value)
                        throws IOException
        Convenience method for outputting a field entry ("member") that has a boolean value. Equivalent to:
          writeFieldName(fieldName);
          writeBoolean(value);
         
        Throws:
        IOException
      • writeNumberField

        void writeNumberField​(String fieldName,
                              int value)
                       throws IOException
        Convenience method for outputting a field entry ("member") that has the specified numeric value. Equivalent to:
          writeFieldName(fieldName);
          writeNumber(value);
         
        Throws:
        IOException
      • writeNumberField

        void writeNumberField​(String fieldName,
                              double value)
                       throws IOException
        Convenience method for outputting a field entry ("member") that has the specified numeric value. Equivalent to:
          writeFieldName(fieldName);
          writeNumber(value);
         
        Throws:
        IOException
      • writeBinaryField

        void writeBinaryField​(String fieldName,
                              byte[] data)
                       throws IOException
        Convenience method for outputting a field entry ("member") that contains specified data in base64-encoded form. Equivalent to:
          writeFieldName(fieldName);
          writeBinary(value);
         
        Throws:
        IOException
      • writeArrayFieldStart

        void writeArrayFieldStart​(String fieldName)
                           throws IOException
        Convenience method for outputting a field entry ("member") (that will contain a JSON Array value), and the START_ARRAY marker. Equivalent to:
          writeFieldName(fieldName);
          writeStartArray();
         

        Note: caller still has to take care to close the array (by calling {#link #writeEndArray}) after writing all values of the value Array.

        Throws:
        IOException
      • writeObjectFieldStart

        void writeObjectFieldStart​(String fieldName)
                            throws IOException
        Convenience method for outputting a field entry ("member") (that will contain a JSON Object value), and the START_OBJECT marker. Equivalent to:
          writeFieldName(fieldName);
          writeStartObject();
         

        Note: caller still has to take care to close the Object (by calling {#link #writeEndObject}) after writing all entries of the value Object.

        Throws:
        IOException
      • close

        void close()
            throws IOException
        Method called to close builder, so that no more content can be written.
        Throws:
        IOException
      • getContent

        String getContent()
                   throws IOException
        Methid called to get the final content after closing the builder
        Returns:
        built content
        Throws:
        IOException
      • writePrimitive

        void writePrimitive​(Object value,
                            String fieldType)
                     throws IOException
        Convenience method for outputting a primitive that has a primitive value.
        Throws:
        IOException