Class JsonOutput


  • public class JsonOutput
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonOutput()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void add​(org.json.JSONWriter writer, java.lang.String field, java.util.Date value, java.text.SimpleDateFormat format)
      Adds a value to a writer.
      static <T> void addArrayIfNotEmpty​(org.json.JSONWriter writer, java.lang.String field, java.util.Collection<T> items, JsonObjectWriter<T> objWriter)
      Adds a list of objects.
      static void addIfNotNull​(org.json.JSONWriter writer, java.lang.String field, java.lang.Boolean value)
      Adds a value to a writer if value is not null.
      static void addIfNotNull​(org.json.JSONWriter writer, java.lang.String field, java.lang.Float value)
      Adds a value to a writer if value is not null.
      static void addIfNotNull​(org.json.JSONWriter writer, java.lang.String field, java.lang.Integer value)
      Adds a value to a writer if value is not null.
      static void addIfNotNull​(org.json.JSONWriter writer, java.lang.String field, java.lang.String value)
      Adds a value to a writer if value is not null.
      static void addIfNotNull​(org.json.JSONWriter writer, java.lang.String field, java.util.Date value, java.text.SimpleDateFormat format)
      Adds a value to a writer if value is not null.
      static <T> void addIfNotNull​(org.json.JSONWriter writer, java.lang.String field, T value, JsonObjectWriter<T> objWriter)
      Adds an object if object is not null.
      static <T> void addScalarArray​(org.json.JSONWriter writer, java.lang.String field, java.util.Collection<T> items, JsonObjectWriter<T> objWriter)
      Adds a list of scalar values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JsonOutput

        public JsonOutput()
    • Method Detail

      • addIfNotNull

        public static void addIfNotNull​(org.json.JSONWriter writer,
                                        java.lang.String field,
                                        java.lang.String value)
                                 throws org.json.JSONException
        Adds a value to a writer if value is not null.
        Parameters:
        writer - writer to add object to.
        field - field name to set.
        value - field value.
        Throws:
        org.json.JSONException - if io error occurs.
      • addIfNotNull

        public static void addIfNotNull​(org.json.JSONWriter writer,
                                        java.lang.String field,
                                        java.lang.Integer value)
                                 throws org.json.JSONException
        Adds a value to a writer if value is not null.
        Parameters:
        writer - writer to add object to.
        field - field name to set.
        value - field value.
        Throws:
        org.json.JSONException - if io error occurs.
      • addIfNotNull

        public static void addIfNotNull​(org.json.JSONWriter writer,
                                        java.lang.String field,
                                        java.lang.Float value)
                                 throws org.json.JSONException
        Adds a value to a writer if value is not null.
        Parameters:
        writer - writer to add object to.
        field - field name to set.
        value - field value.
        Throws:
        org.json.JSONException - if io error occurs.
      • addIfNotNull

        public static void addIfNotNull​(org.json.JSONWriter writer,
                                        java.lang.String field,
                                        java.util.Date value,
                                        java.text.SimpleDateFormat format)
                                 throws org.json.JSONException
        Adds a value to a writer if value is not null.
        Parameters:
        writer - writer to add object to.
        field - field name to set.
        value - field value.
        format - date foramt to use.
        Throws:
        org.json.JSONException - if io error occurs.
      • addIfNotNull

        public static void addIfNotNull​(org.json.JSONWriter writer,
                                        java.lang.String field,
                                        java.lang.Boolean value)
                                 throws org.json.JSONException
        Adds a value to a writer if value is not null.
        Parameters:
        writer - writer to add object to.
        field - field name to set.
        value - field value.
        Throws:
        org.json.JSONException - if io error occurs.
      • add

        public static void add​(org.json.JSONWriter writer,
                               java.lang.String field,
                               java.util.Date value,
                               java.text.SimpleDateFormat format)
                        throws org.json.JSONException
        Adds a value to a writer.
        Parameters:
        writer - writer to add object to.
        field - field name to set.
        value - field value.
        format - date foramt to use.
        Throws:
        org.json.JSONException - if io error occurs.
      • addIfNotNull

        public static <T> void addIfNotNull​(org.json.JSONWriter writer,
                                            java.lang.String field,
                                            T value,
                                            JsonObjectWriter<T> objWriter)
                                     throws org.json.JSONException
        Adds an object if object is not null.
        Parameters:
        writer - object writer.
        field - field writer.
        value - value writer.
        objWriter - object value writer.
        Throws:
        org.json.JSONException - if io error occurs.
      • addScalarArray

        public static <T> void addScalarArray​(org.json.JSONWriter writer,
                                              java.lang.String field,
                                              java.util.Collection<T> items,
                                              JsonObjectWriter<T> objWriter)
                                       throws org.json.JSONException
        Adds a list of scalar values.
        Parameters:
        writer - used writer.
        field - field to write.
        items - used items.
        objWriter - single value writer.
        Throws:
        org.json.JSONException
      • addArrayIfNotEmpty

        public static <T> void addArrayIfNotEmpty​(org.json.JSONWriter writer,
                                                  java.lang.String field,
                                                  java.util.Collection<T> items,
                                                  JsonObjectWriter<T> objWriter)
                                           throws org.json.JSONException
        Adds a list of objects.
        Parameters:
        writer - used writer.
        field - field to write.
        items - used items.
        objWriter - single object writer.
        Throws:
        org.json.JSONException