Package org.apache.sling.commons.json

Examples of org.apache.sling.commons.json.JSONException


        for (int i=0; i < jsonArray.length(); i++) {
          Object object = jsonArray.get(i);
          if (object instanceof JSONObject) {
              createPrincipal((JSONObject)object, contentCreator);
          } else {
            throw new JSONException("Unexpected data type in principals array: " + object.getClass().getName());
          }
        }
      }
    }
View Full Code Here


        for (int i=0; i < jsonArray.length(); i++) {
          Object object = jsonArray.get(i);
          if (object instanceof JSONObject) {
              createAce((JSONObject)object, contentCreator);
          } else {
            throw new JSONException("Unexpected data type in acl array: " + object.getClass().getName());
          }
        }
      }
    }
View Full Code Here

        if (value instanceof JSONString) {
            Object o;
            try {
                o = ((JSONString)value).toJSONString();
            } catch (Exception e) {
                throw new JSONException(e);
            }
            if (o instanceof String) {
                return (String)o;
            }
            throw new JSONException("Bad value from toJSONString: " + o);
        }
        if (value instanceof Number) {
            return numberToString((Number) value);
        }
        if (value instanceof Boolean || value instanceof JSONObject ||
View Full Code Here

     * @throws JSONException If n is a non-finite number.
     */
    public String numberToString(Number n)
            throws JSONException {
        if (n == null) {
            throw new JSONException("Null pointer");
        }
        testNumberValidity(n);

        // Shave off trailing zeros and decimal point, if possible.

View Full Code Here

     */
    public void testNumberValidity(Object o) throws JSONException {
        if (o != null) {
            if (o instanceof Double) {
                if (((Double)o).isInfinite() || ((Double)o).isNaN()) {
                    throw new JSONException(
                        "JSON does not allow non-finite numbers");
                }
            } else if (o instanceof Float) {
                if (((Float)o).isInfinite() || ((Float)o).isNaN()) {
                    throw new JSONException(
                        "JSON does not allow non-finite numbers.");
                }
            }
        }
    }
View Full Code Here

               b = true;
           }
           writer.write('}');
           return writer;
       } catch (IOException e) {
           throw new JSONException(e);
       }
    }
View Full Code Here

                b = true;
            }
            writer.write(']');
            return writer;
        } catch (IOException e) {
           throw new JSONException(e);
        }
    }
View Full Code Here

     * @return this
     * @throws JSONException If the value is out of sequence.
     */
    private JSONWriter append(String s) throws JSONException {
        if (s == null) {
            throw new JSONException("Null pointer");
        }
        if (this.mode == 'o' || this.mode == 'a') {
            try {
                if (this.comma && this.mode == 'a') {
                    this.writer.write(',');
                }
                this.writer.write(s);
            } catch (IOException e) {
                throw new JSONException(e);
            }
            if (this.mode == 'o') {
                this.mode = 'k';
            }
            this.comma = true;
            return this;
        }
        throw new JSONException("Value out of sequence.");
    }
View Full Code Here

            this.push('a');
            this.append("[");
            this.comma = false;
            return this;
        }
        throw new JSONException("Misplaced array.");
    }
View Full Code Here

     * @return this
     * @throws JSONException If unbalanced.
     */
    private JSONWriter end(char m, char c) throws JSONException {
        if (this.mode != m) {
            throw new JSONException(m == 'o' ? "Misplaced endObject." :
                "Misplaced endArray.");
        }
        this.pop(m);
        try {
            this.writer.write(c);
        } catch (IOException e) {
            throw new JSONException(e);
        }
        this.comma = true;
        return this;
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.json.JSONException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.