Class JsonBean

    • Field Detail

      • json

        protected org.json.JSONObject json
    • Constructor Detail

      • JsonBean

        public JsonBean()
      • JsonBean

        public JsonBean​(org.json.JSONObject json)
    • Method Detail

      • getJson

        public org.json.JSONObject getJson()
        Gets the underlying JSONObject
        Returns:
        JSONObject
      • getJsonCopy

        public final org.json.JSONObject getJsonCopy()
        Gets a copy of underlying JSONObject
        Returns:
        JSONObject
      • getString

        public String getString​(String property)
        Helper method to extract data field from underlying JSONObject
        Parameters:
        property - name of the field
        Returns:
        String value of a field
      • getIntegerValue

        public int getIntegerValue​(String property)
        Helper method to extract data field from underlying JSONObject
        Parameters:
        property - name of the field
        Returns:
        Integer value of a field
      • getDoubleValue

        public double getDoubleValue​(String property)
        Helper method to extract data field from underlying JSONObject
        Parameters:
        property - name of the field
        Returns:
        Double value of a field
      • getDoubleValue

        public double getDoubleValue​(String property,
                                     double defaultValue)
      • getBooleanValue

        public boolean getBooleanValue​(String property)
        Helper method to extract data field from underlying JSONObject
        Parameters:
        property - name of the field
        Returns:
        Boolean value of a field
      • getBooleanValue

        public boolean getBooleanValue​(String property,
                                       boolean defaultValue)
        Helper method to extract data field from underlying JSONObject
        Parameters:
        property - name of the field
        defaultValue - default value if property is missing
        Returns:
        Boolean value of a field
      • getJsonValue

        public org.json.JSONObject getJsonValue​(String property)
        Helper method to extract data field from underlying JSONObject
        Parameters:
        property - name of the field
        Returns:
        JSONObject value of a field
      • put

        public JsonBean put​(String key,
                            Object value)
                     throws org.json.JSONException
        Set value for a property
        Parameters:
        key - name of the property
        value - value
        Returns:
        current object
        Throws:
        org.json.JSONException - from JSONObject.put
      • setBoolean

        public void setBoolean​(String name,
                               Boolean value)
      • setString

        public void setString​(String name,
                              String value)
      • getArray

        public org.json.JSONArray getArray​(String name)
      • getList

        public <T> List<T> getList​(String name)
      • setJsonArray

        public <T> void setJsonArray​(String name,
                                     List<T> values)
      • setInteger

        public void setInteger​(String name,
                               Integer value)
      • setLong

        public void setLong​(String name,
                            Long value)
      • getJsonBean

        public <T> T getJsonBean​(String name,
                                 Class<T> clazz)
      • getJsonBean

        public <T> T getJsonBean​(org.json.JSONObject obj,
                                 Class<T> clazz)
      • setJsonBean

        public <T extends JsonBean> void setJsonBean​(String name,
                                                     T jsonBean)
      • setRectangle

        public void setRectangle​(String name,
                                 Rectangle rect)