activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [23/53] [abbrv] [partial] activemq-artemis git commit: automatic checkstyle change
Date Mon, 10 Aug 2015 15:13:22 GMT
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONArray.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONArray.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONArray.java
index daa5709..7143273 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONArray.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONArray.java
@@ -59,25 +59,24 @@ import java.util.Map;
  * accept:
  * <ul>
  * <li>An extra <code>,</code>&nbsp;<small>(comma)</small>
may appear just
- *     before the closing bracket.</li>
+ * before the closing bracket.</li>
  * <li>The {@code null} value will be inserted when there
- *     is <code>,</code>&nbsp;<small>(comma)</small> elision.</li>
+ * is <code>,</code>&nbsp;<small>(comma)</small> elision.</li>
  * <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single
- *     quote)</small>.</li>
+ * quote)</small>.</li>
  * <li>Strings do not need to be quoted at all if they do not begin with a quote
- *     or single quote, and if they do not contain leading or trailing spaces,
- *     and if they do not contain any of these characters:
- *     <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers
- *     and if they are not the reserved words <code>true</code>,
- *     <code>false</code>, or {@code null}.</li>
+ * or single quote, and if they do not contain leading or trailing spaces,
+ * and if they do not contain any of these characters:
+ * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers
+ * and if they are not the reserved words <code>true</code>,
+ * <code>false</code>, or {@code null}.</li>
  * <li>Values can be separated by <code>;</code> <small>(semicolon)</small>
as
- *     well as by <code>,</code> <small>(comma)</small>.</li>
+ * well as by <code>,</code> <small>(comma)</small>.</li>
  * <li>Numbers may have the <code>0-</code> <small>(octal)</small>
or
- *     <code>0x-</code> <small>(hex)</small> prefix.</li>
+ * <code>0x-</code> <small>(hex)</small> prefix.</li>
  * </ul>
  */
-public class JSONArray
-{
+public class JSONArray {
 
    /**
     * The arrayList where the JSONArray's properties are kept.
@@ -87,65 +86,54 @@ public class JSONArray
    /**
     * Construct an empty JSONArray.
     */
-   public JSONArray()
-   {
+   public JSONArray() {
       myArrayList = new ArrayList<Object>();
    }
 
    /**
     * Construct a JSONArray from a JSONTokener.
+    *
     * @param x A JSONTokener
     * @throws JSONException If there is a syntax error.
     */
-   public JSONArray(final JSONTokener x) throws JSONException
-   {
+   public JSONArray(final JSONTokener x) throws JSONException {
       this();
       char c = x.nextClean();
       char q;
-      if (c == '[')
-      {
+      if (c == '[') {
          q = ']';
       }
-      else if (c == '(')
-      {
+      else if (c == '(') {
          q = ')';
       }
-      else
-      {
+      else {
          throw x.syntaxError("A JSONArray text must start with '['");
       }
-      if (x.nextClean() == ']')
-      {
+      if (x.nextClean() == ']') {
          return;
       }
       x.back();
-      for (;;)
-      {
-         if (x.nextClean() == ',')
-         {
+      for (; ; ) {
+         if (x.nextClean() == ',') {
             x.back();
             myArrayList.add(null);
          }
-         else
-         {
+         else {
             x.back();
             myArrayList.add(x.nextValue());
          }
          c = x.nextClean();
-         switch (c)
-         {
+         switch (c) {
             case ';':
             case ',':
-               if (x.nextClean() == ']')
-               {
+               if (x.nextClean() == ']') {
                   return;
                }
                x.back();
                break;
             case ']':
             case ')':
-               if (q != c)
-               {
+               if (q != c) {
                   throw x.syntaxError("Expected a '" + Character.valueOf(q) + "'");
                }
                return;
@@ -157,22 +145,22 @@ public class JSONArray
 
    /**
     * Construct a JSONArray from a source JSON text.
-    * @param source     A string that begins with
-    * <code>[</code>&nbsp;<small>(left bracket)</small>
-    *  and ends with <code>]</code>&nbsp;<small>(right bracket)</small>.
-    *  @throws JSONException If there is a syntax error.
+    *
+    * @param source A string that begins with
+    *               <code>[</code>&nbsp;<small>(left bracket)</small>
+    *               and ends with <code>]</code>&nbsp;<small>(right
bracket)</small>.
+    * @throws JSONException If there is a syntax error.
     */
-   public JSONArray(final String source) throws JSONException
-   {
+   public JSONArray(final String source) throws JSONException {
       this(new JSONTokener(source));
    }
 
    /**
     * Construct a JSONArray from a Collection.
-    * @param collection     A Collection.
+    *
+    * @param collection A Collection.
     */
-   public JSONArray(final Collection collection)
-   {
+   public JSONArray(final Collection collection) {
       myArrayList = collection == null ? new ArrayList<Object>() : new ArrayList<Object>(collection);
    }
 
@@ -180,25 +168,19 @@ public class JSONArray
     * Construct a JSONArray from a collection of beans.
     * The collection should have Java Beans.
     */
-   public JSONArray(final Collection collection, final boolean includeSuperClass)
-   {
+   public JSONArray(final Collection collection, final boolean includeSuperClass) {
       myArrayList = collection == null ? new ArrayList<Object>() : new ArrayList<Object>(collection.size());
-      if (collection != null)
-      {
+      if (collection != null) {
          Iterator<Object> iter = collection.iterator();
-         while (iter.hasNext())
-         {
+         while (iter.hasNext()) {
             Object o = iter.next();
-            if (o instanceof Map<?, ?>)
-            {
-               myArrayList.add(new JSONObject((Map<?, ?>)o, includeSuperClass));
+            if (o instanceof Map<?, ?>) {
+               myArrayList.add(new JSONObject((Map<?, ?>) o, includeSuperClass));
             }
-            else if (!JSONObject.isStandardProperty(o.getClass()))
-            {
+            else if (!JSONObject.isStandardProperty(o.getClass())) {
                myArrayList.add(new JSONObject(o, includeSuperClass));
             }
-            else
-            {
+            else {
                myArrayList.add(o);
             }
          }
@@ -207,21 +189,18 @@ public class JSONArray
 
    /**
     * Construct a JSONArray from an array
+    *
     * @throws JSONException If not an array.
     */
-   public JSONArray(final Object array) throws JSONException
-   {
+   public JSONArray(final Object array) throws JSONException {
       this();
-      if (array.getClass().isArray())
-      {
+      if (array.getClass().isArray()) {
          int length = Array.getLength(array);
-         for (int i = 0; i < length; i += 1)
-         {
+         for (int i = 0; i < length; i += 1) {
             this.put(Array.get(array, i));
          }
       }
-      else
-      {
+      else {
          throw new JSONException("JSONArray initial value should be a string or collection
or array.");
       }
    }
@@ -232,43 +211,35 @@ public class JSONArray
     *
     * @throws JSONException If not an array.
     */
-   public JSONArray(final Object array, final boolean includeSuperClass) throws JSONException
-   {
+   public JSONArray(final Object array, final boolean includeSuperClass) throws JSONException
{
       this();
-      if (array.getClass().isArray())
-      {
+      if (array.getClass().isArray()) {
          int length = Array.getLength(array);
-         for (int i = 0; i < length; i += 1)
-         {
+         for (int i = 0; i < length; i += 1) {
             Object o = Array.get(array, i);
-            if (JSONObject.isStandardProperty(o.getClass()))
-            {
+            if (JSONObject.isStandardProperty(o.getClass())) {
                myArrayList.add(o);
             }
-            else
-            {
+            else {
                myArrayList.add(new JSONObject(o, includeSuperClass));
             }
          }
       }
-      else
-      {
+      else {
          throw new JSONException("JSONArray initial value should be a string or collection
or array.");
       }
    }
 
    /**
     * Get the object value associated with an index.
-    * @param index
-    *  The index must be between 0 and length() - 1.
+    *
+    * @param index The index must be between 0 and length() - 1.
     * @return An object value.
     * @throws JSONException If there is no value for the index.
     */
-   public Object get(final int index) throws JSONException
-   {
+   public Object get(final int index) throws JSONException {
       Object o = opt(index);
-      if (o == null)
-      {
+      if (o == null) {
          throw new JSONException("JSONArray[" + index + "] not found.");
       }
       return o;
@@ -279,19 +250,16 @@ public class JSONArray
     * The string values "true" and "false" are converted to boolean.
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      The truth.
+    * @return The truth.
     * @throws JSONException If there is no value for the index or if the
-    *  value is not convertable to boolean.
+    *                       value is not convertable to boolean.
     */
-   public boolean getBoolean(final int index) throws JSONException
-   {
+   public boolean getBoolean(final int index) throws JSONException {
       Object o = get(index);
-      if (o.equals(Boolean.FALSE) || o instanceof String && ((String)o).equalsIgnoreCase("false"))
-      {
+      if (o.equals(Boolean.FALSE) || o instanceof String && ((String) o).equalsIgnoreCase("false"))
{
          return false;
       }
-      else if (o.equals(Boolean.TRUE) || o instanceof String && ((String)o).equalsIgnoreCase("true"))
-      {
+      else if (o.equals(Boolean.TRUE) || o instanceof String && ((String) o).equalsIgnoreCase("true"))
{
          return true;
       }
       throw new JSONException("JSONArray[" + index + "] is not a Boolean.");
@@ -301,19 +269,16 @@ public class JSONArray
     * Get the double value associated with an index.
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
-    * @throws   JSONException If the key is not found or if the value cannot
-    *  be converted to a number.
+    * @return The value.
+    * @throws JSONException If the key is not found or if the value cannot
+    *                       be converted to a number.
     */
-   public double getDouble(final int index) throws JSONException
-   {
+   public double getDouble(final int index) throws JSONException {
       Object o = get(index);
-      try
-      {
-         return o instanceof Number ? ((Number)o).doubleValue() : Double.valueOf((String)o).doubleValue();
+      try {
+         return o instanceof Number ? ((Number) o).doubleValue() : Double.valueOf((String)
o).doubleValue();
       }
-      catch (Exception e)
-      {
+      catch (Exception e) {
          throw new JSONException("JSONArray[" + index + "] is not a number.");
       }
    }
@@ -322,47 +287,44 @@ public class JSONArray
     * Get the int value associated with an index.
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
-    * @throws   JSONException If the key is not found or if the value cannot
-    *  be converted to a number.
-    *  if the value cannot be converted to a number.
+    * @return The value.
+    * @throws JSONException If the key is not found or if the value cannot
+    *                       be converted to a number.
+    *                       if the value cannot be converted to a number.
     */
-   public int getInt(final int index) throws JSONException
-   {
+   public int getInt(final int index) throws JSONException {
       Object o = get(index);
-      return o instanceof Number ? ((Number)o).intValue() : (int)getDouble(index);
+      return o instanceof Number ? ((Number) o).intValue() : (int) getDouble(index);
    }
 
    /**
     * Get the JSONArray associated with an index.
+    *
     * @param index The index must be between 0 and length() - 1.
-    * @return      A JSONArray value.
+    * @return A JSONArray value.
     * @throws JSONException If there is no value for the index. or if the
-    * value is not a JSONArray
+    *                       value is not a JSONArray
     */
-   public JSONArray getJSONArray(final int index) throws JSONException
-   {
+   public JSONArray getJSONArray(final int index) throws JSONException {
       Object o = get(index);
-      if (o instanceof JSONArray)
-      {
-         return (JSONArray)o;
+      if (o instanceof JSONArray) {
+         return (JSONArray) o;
       }
       throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
    }
 
    /**
     * Get the JSONObject associated with an index.
+    *
     * @param index subscript
-    * @return      A JSONObject value.
+    * @return A JSONObject value.
     * @throws JSONException If there is no value for the index or if the
-    * value is not a JSONObject
+    *                       value is not a JSONObject
     */
-   public JSONObject getJSONObject(final int index) throws JSONException
-   {
+   public JSONObject getJSONObject(final int index) throws JSONException {
       Object o = get(index);
-      if (o instanceof JSONObject)
-      {
-         return (JSONObject)o;
+      if (o instanceof JSONObject) {
+         return (JSONObject) o;
       }
       throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
    }
@@ -371,34 +333,33 @@ public class JSONArray
     * Get the long value associated with an index.
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
-    * @throws   JSONException If the key is not found or if the value cannot
-    *  be converted to a number.
+    * @return The value.
+    * @throws JSONException If the key is not found or if the value cannot
+    *                       be converted to a number.
     */
-   public long getLong(final int index) throws JSONException
-   {
+   public long getLong(final int index) throws JSONException {
       Object o = get(index);
-      return o instanceof Number ? ((Number)o).longValue() : (long)getDouble(index);
+      return o instanceof Number ? ((Number) o).longValue() : (long) getDouble(index);
    }
 
    /**
     * Get the string associated with an index.
+    *
     * @param index The index must be between 0 and length() - 1.
-    * @return      A string value.
+    * @return A string value.
     * @throws JSONException If there is no value for the index.
     */
-   public String getString(final int index) throws JSONException
-   {
+   public String getString(final int index) throws JSONException {
       return get(index).toString();
    }
 
    /**
     * Determine if the value is null.
+    *
     * @param index The index must be between 0 and length() - 1.
     * @return true if the value at the index is null, or if there is no value.
     */
-   public boolean isNull(final int index)
-   {
+   public boolean isNull(final int index) {
       return JSONObject.NULL.equals(opt(index));
    }
 
@@ -406,19 +367,17 @@ public class JSONArray
     * Make a string from the contents of this JSONArray. The
     * <code>separator</code> string is inserted between each element.
     * Warning: This method assumes that the data structure is acyclical.
+    *
     * @param separator A string that will be inserted between the elements.
     * @return a string.
     * @throws JSONException If the array contains an invalid number.
     */
-   public String join(final String separator) throws JSONException
-   {
+   public String join(final String separator) throws JSONException {
       int len = length();
       StringBuffer sb = new StringBuffer();
 
-      for (int i = 0; i < len; i += 1)
-      {
-         if (i > 0)
-         {
+      for (int i = 0; i < len; i += 1) {
+         if (i > 0) {
             sb.append(separator);
          }
          sb.append(JSONObject.valueToString(myArrayList.get(i)));
@@ -431,19 +390,18 @@ public class JSONArray
     *
     * @return The length (or size).
     */
-   public int length()
-   {
+   public int length() {
       return myArrayList.size();
    }
 
    /**
     * Get the optional object value associated with an index.
+    *
     * @param index The index must be between 0 and length() - 1.
-    * @return      An object value, or null if there is no
-    *              object at that index.
+    * @return An object value, or null if there is no
+    * object at that index.
     */
-   public Object opt(final int index)
-   {
+   public Object opt(final int index) {
       return index < 0 || index >= length() ? null : myArrayList.get(index);
    }
 
@@ -453,10 +411,9 @@ public class JSONArray
     * or if the value is not Boolean.TRUE or the String "true".
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      The truth.
+    * @return The truth.
     */
-   public boolean optBoolean(final int index)
-   {
+   public boolean optBoolean(final int index) {
       return optBoolean(index, false);
    }
 
@@ -465,18 +422,15 @@ public class JSONArray
     * It returns the defaultValue if there is no value at that index or if
     * it is not a Boolean or the String "true" or "false" (case insensitive).
     *
-    * @param index The index must be between 0 and length() - 1.
-    * @param defaultValue     A boolean default.
-    * @return      The truth.
+    * @param index        The index must be between 0 and length() - 1.
+    * @param defaultValue A boolean default.
+    * @return The truth.
     */
-   public boolean optBoolean(final int index, final boolean defaultValue)
-   {
-      try
-      {
+   public boolean optBoolean(final int index, final boolean defaultValue) {
+      try {
          return getBoolean(index);
       }
-      catch (Exception e)
-      {
+      catch (Exception e) {
          return defaultValue;
       }
    }
@@ -487,10 +441,9 @@ public class JSONArray
     * or if the value is not a number and cannot be converted to a number.
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
+    * @return The value.
     */
-   public double optDouble(final int index)
-   {
+   public double optDouble(final int index) {
       return optDouble(index, Double.NaN);
    }
 
@@ -499,18 +452,15 @@ public class JSONArray
     * The defaultValue is returned if there is no value for the index,
     * or if the value is not a number and cannot be converted to a number.
     *
-    * @param index subscript
-    * @param defaultValue     The default value.
-    * @return      The value.
+    * @param index        subscript
+    * @param defaultValue The default value.
+    * @return The value.
     */
-   public double optDouble(final int index, final double defaultValue)
-   {
-      try
-      {
+   public double optDouble(final int index, final double defaultValue) {
+      try {
          return getDouble(index);
       }
-      catch (Exception e)
-      {
+      catch (Exception e) {
          return defaultValue;
       }
    }
@@ -521,10 +471,9 @@ public class JSONArray
     * or if the value is not a number and cannot be converted to a number.
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
+    * @return The value.
     */
-   public int optInt(final int index)
-   {
+   public int optInt(final int index) {
       return optInt(index, 0);
    }
 
@@ -532,32 +481,30 @@ public class JSONArray
     * Get the optional int value associated with an index.
     * The defaultValue is returned if there is no value for the index,
     * or if the value is not a number and cannot be converted to a number.
-    * @param index The index must be between 0 and length() - 1.
-    * @param defaultValue     The default value.
-    * @return      The value.
+    *
+    * @param index        The index must be between 0 and length() - 1.
+    * @param defaultValue The default value.
+    * @return The value.
     */
-   public int optInt(final int index, final int defaultValue)
-   {
-      try
-      {
+   public int optInt(final int index, final int defaultValue) {
+      try {
          return getInt(index);
       }
-      catch (Exception e)
-      {
+      catch (Exception e) {
          return defaultValue;
       }
    }
 
    /**
     * Get the optional JSONArray associated with an index.
+    *
     * @param index subscript
-    * @return      A JSONArray value, or null if the index has no value,
+    * @return A JSONArray value, or null if the index has no value,
     * or if the value is not a JSONArray.
     */
-   public JSONArray optJSONArray(final int index)
-   {
+   public JSONArray optJSONArray(final int index) {
       Object o = opt(index);
-      return o instanceof JSONArray ? (JSONArray)o : null;
+      return o instanceof JSONArray ? (JSONArray) o : null;
    }
 
    /**
@@ -566,12 +513,11 @@ public class JSONArray
     * no value, or if the value is not a JSONObject.
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      A JSONObject value.
+    * @return A JSONObject value.
     */
-   public JSONObject optJSONObject(final int index)
-   {
+   public JSONObject optJSONObject(final int index) {
       Object o = opt(index);
-      return o instanceof JSONObject ? (JSONObject)o : null;
+      return o instanceof JSONObject ? (JSONObject) o : null;
    }
 
    /**
@@ -580,10 +526,9 @@ public class JSONArray
     * or if the value is not a number and cannot be converted to a number.
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
+    * @return The value.
     */
-   public long optLong(final int index)
-   {
+   public long optLong(final int index) {
       return optLong(index, 0);
    }
 
@@ -591,18 +536,16 @@ public class JSONArray
     * Get the optional long value associated with an index.
     * The defaultValue is returned if there is no value for the index,
     * or if the value is not a number and cannot be converted to a number.
-    * @param index The index must be between 0 and length() - 1.
-    * @param defaultValue     The default value.
-    * @return      The value.
+    *
+    * @param index        The index must be between 0 and length() - 1.
+    * @param defaultValue The default value.
+    * @return The value.
     */
-   public long optLong(final int index, final long defaultValue)
-   {
-      try
-      {
+   public long optLong(final int index, final long defaultValue) {
+      try {
          return getLong(index);
       }
-      catch (Exception e)
-      {
+      catch (Exception e) {
          return defaultValue;
       }
    }
@@ -613,10 +556,9 @@ public class JSONArray
     * is not a string and is not null, then it is converted to a string.
     *
     * @param index The index must be between 0 and length() - 1.
-    * @return      A String value.
+    * @return A String value.
     */
-   public String optString(final int index)
-   {
+   public String optString(final int index) {
       return optString(index, "");
    }
 
@@ -624,12 +566,11 @@ public class JSONArray
     * Get the optional string associated with an index.
     * The defaultValue is returned if the key is not found.
     *
-    * @param index The index must be between 0 and length() - 1.
-    * @param defaultValue     The default value.
-    * @return      A String value.
+    * @param index        The index must be between 0 and length() - 1.
+    * @param defaultValue The default value.
+    * @return A String value.
     */
-   public String optString(final int index, final String defaultValue)
-   {
+   public String optString(final int index, final String defaultValue) {
       Object o = opt(index);
       return o != null ? o.toString() : defaultValue;
    }
@@ -640,8 +581,7 @@ public class JSONArray
     * @param value A boolean value.
     * @return this.
     */
-   public JSONArray put(final boolean value)
-   {
+   public JSONArray put(final boolean value) {
       put(value ? Boolean.TRUE : Boolean.FALSE);
       return this;
    }
@@ -649,11 +589,11 @@ public class JSONArray
    /**
     * Put a value in the JSONArray, where the value will be a
     * JSONArray which is produced from a Collection.
+    *
     * @param value A Collection value.
-    * @return      this.
+    * @return this.
     */
-   public JSONArray put(final Collection value)
-   {
+   public JSONArray put(final Collection value) {
       put(new JSONArray(value));
       return this;
    }
@@ -662,11 +602,10 @@ public class JSONArray
     * Append a double value. This increases the array's length by one.
     *
     * @param value A double value.
-    * @throws JSONException if the value is not finite.
     * @return this.
+    * @throws JSONException if the value is not finite.
     */
-   public JSONArray put(final double value) throws JSONException
-   {
+   public JSONArray put(final double value) throws JSONException {
       Double d = new Double(value);
       JSONObject.testValidity(d);
       put(d);
@@ -679,8 +618,7 @@ public class JSONArray
     * @param value An int value.
     * @return this.
     */
-   public JSONArray put(final int value)
-   {
+   public JSONArray put(final int value) {
       put(Integer.valueOf(value));
       return this;
    }
@@ -691,8 +629,7 @@ public class JSONArray
     * @param value A long value.
     * @return this.
     */
-   public JSONArray put(final long value)
-   {
+   public JSONArray put(final long value) {
       put(Long.valueOf(value));
       return this;
    }
@@ -700,24 +637,24 @@ public class JSONArray
    /**
     * Put a value in the JSONArray, where the value will be a
     * JSONObject which is produced from a Map.
+    *
     * @param value A Map value.
-    * @return      this.
+    * @return this.
     */
-   public JSONArray put(final Map value)
-   {
+   public JSONArray put(final Map value) {
       put(new JSONObject(value));
       return this;
    }
 
    /**
     * Append an object value. This increases the array's length by one.
+    *
     * @param value An object value.  The value should be a
-    *  Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
-    *  JSONObject.NULL object.
+    *              Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
+    *              JSONObject.NULL object.
     * @return this.
     */
-   public JSONArray put(final Object value)
-   {
+   public JSONArray put(final Object value) {
       myArrayList.add(value);
       return this;
    }
@@ -726,13 +663,13 @@ public class JSONArray
     * Put or replace a boolean value in the JSONArray. If the index is greater
     * than the length of the JSONArray, then null elements will be added as
     * necessary to pad it out.
+    *
     * @param index The subscript.
     * @param value A boolean value.
     * @return this.
     * @throws JSONException If the index is negative.
     */
-   public JSONArray put(final int index, final boolean value) throws JSONException
-   {
+   public JSONArray put(final int index, final boolean value) throws JSONException {
       put(index, value ? Boolean.TRUE : Boolean.FALSE);
       return this;
    }
@@ -740,60 +677,60 @@ public class JSONArray
    /**
     * Put a value in the JSONArray, where the value will be a
     * JSONArray which is produced from a Collection.
+    *
     * @param index The subscript.
     * @param value A Collection value.
-    * @return      this.
+    * @return this.
     * @throws JSONException If the index is negative or if the value is
-    * not finite.
+    *                       not finite.
     */
-   public JSONArray put(final int index, final Collection value) throws JSONException
-   {
+   public JSONArray put(final int index, final Collection value) throws JSONException {
       put(index, new JSONArray(value));
       return this;
    }
 
    /**
     * Put or replace a double value. If the index is greater than the length of
-    *  the JSONArray, then null elements will be added as necessary to pad
-    *  it out.
+    * the JSONArray, then null elements will be added as necessary to pad
+    * it out.
+    *
     * @param index The subscript.
     * @param value A double value.
     * @return this.
     * @throws JSONException If the index is negative or if the value is
-    * not finite.
+    *                       not finite.
     */
-   public JSONArray put(final int index, final double value) throws JSONException
-   {
+   public JSONArray put(final int index, final double value) throws JSONException {
       put(index, new Double(value));
       return this;
    }
 
    /**
     * Put or replace an int value. If the index is greater than the length of
-    *  the JSONArray, then null elements will be added as necessary to pad
-    *  it out.
+    * the JSONArray, then null elements will be added as necessary to pad
+    * it out.
+    *
     * @param index The subscript.
     * @param value An int value.
     * @return this.
     * @throws JSONException If the index is negative.
     */
-   public JSONArray put(final int index, final int value) throws JSONException
-   {
+   public JSONArray put(final int index, final int value) throws JSONException {
       put(index, Integer.valueOf(value));
       return this;
    }
 
    /**
     * Put or replace a long value. If the index is greater than the length of
-    *  the JSONArray, then null elements will be added as necessary to pad
-    *  it out.
+    * the JSONArray, then null elements will be added as necessary to pad
+    * it out.
+    *
     * @param index The subscript.
     * @param value A long value.
     * @return this.
     * @throws JSONException If the index is negative.
     */
-   public JSONArray put(final int index, final long value) throws JSONException
-   {
+   public JSONArray put(final int index, final long value) throws JSONException {
       put(index, Long.valueOf(value));
       return this;
    }
@@ -801,45 +738,41 @@ public class JSONArray
    /**
     * Put a value in the JSONArray, where the value will be a
     * JSONObject which is produced from a Map.
+    *
     * @param index The subscript.
     * @param value The Map value.
-    * @return      this.
+    * @return this.
     * @throws JSONException If the index is negative or if the the value is
-    *  an invalid number.
+    *                       an invalid number.
     */
-   public JSONArray put(final int index, final Map value) throws JSONException
-   {
+   public JSONArray put(final int index, final Map value) throws JSONException {
       put(index, new JSONObject(value));
       return this;
    }
 
    /**
     * Put or replace an object value in the JSONArray. If the index is greater
-    *  than the length of the JSONArray, then null elements will be added as
-    *  necessary to pad it out.
+    * than the length of the JSONArray, then null elements will be added as
+    * necessary to pad it out.
+    *
     * @param index The subscript.
     * @param value The value to put into the array. The value should be a
-    *  Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
-    *  JSONObject.NULL object.
+    *              Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
+    *              JSONObject.NULL object.
     * @return this.
     * @throws JSONException If the index is negative or if the the value is
-    *  an invalid number.
+    *                       an invalid number.
     */
-   public JSONArray put(final int index, final Object value) throws JSONException
-   {
+   public JSONArray put(final int index, final Object value) throws JSONException {
       JSONObject.testValidity(value);
-      if (index < 0)
-      {
+      if (index < 0) {
          throw new JSONException("JSONArray[" + index + "] not found.");
       }
-      if (index < length())
-      {
+      if (index < length()) {
          myArrayList.set(index, value);
       }
-      else
-      {
-         while (index != length())
-         {
+      else {
+         while (index != length()) {
             put(JSONObject.NULL);
          }
          put(value);
@@ -849,12 +782,12 @@ public class JSONArray
 
    /**
     * Remove an index and close the hole.
+    *
     * @param index The index of the element to be removed.
     * @return The value that was associated with the index,
     * or null if there was no value.
     */
-   public Object remove(final int index)
-   {
+   public Object remove(final int index) {
       Object o = opt(index);
       myArrayList.remove(index);
       return o;
@@ -863,21 +796,19 @@ public class JSONArray
    /**
     * Produce a JSONObject by combining a JSONArray of names with the values
     * of this JSONArray.
+    *
     * @param names A JSONArray containing a list of key strings. These will be
-    * paired with the values.
+    *              paired with the values.
     * @return A JSONObject, or null if there are no names or if this JSONArray
     * has no values.
     * @throws JSONException If any of the names are null.
     */
-   public JSONObject toJSONObject(final JSONArray names) throws JSONException
-   {
-      if (names == null || names.length() == 0 || length() == 0)
-      {
+   public JSONObject toJSONObject(final JSONArray names) throws JSONException {
+      if (names == null || names.length() == 0 || length() == 0) {
          return null;
       }
       JSONObject jo = new JSONObject();
-      for (int i = 0; i < names.length(); i += 1)
-      {
+      for (int i = 0; i < names.length(); i += 1) {
          jo.put(names.getString(i), opt(i));
       }
       return jo;
@@ -892,17 +823,14 @@ public class JSONArray
     * Warning: This method assumes that the data structure is acyclical.
     *
     * @return a printable, displayable, transmittable
-    *  representation of the array.
+    * representation of the array.
     */
    @Override
-   public String toString()
-   {
-      try
-      {
+   public String toString() {
+      try {
          return '[' + join(",") + ']';
       }
-      catch (Exception e)
-      {
+      catch (Exception e) {
          return "";
       }
    }
@@ -910,57 +838,50 @@ public class JSONArray
    /**
     * Make a pretty-printed JSON text of this JSONArray. Warning: This method assumes that
the data
     * structure is acyclical.
+    *
     * @param indentFactor The number of spaces to add to each level of indentation.
     * @return a printable, displayable, transmittable representation of the object, beginning
with
-    *         <code>[</code>&nbsp;<small>(left bracket)</small>
and ending with <code>]</code>
-    *         &nbsp;<small>(right bracket)</small>.
+    * <code>[</code>&nbsp;<small>(left bracket)</small> and ending
with <code>]</code>
+    * &nbsp;<small>(right bracket)</small>.
     * @throws JSONException
     */
-   public String toString(final int indentFactor) throws JSONException
-   {
+   public String toString(final int indentFactor) throws JSONException {
       return toString(indentFactor, 0);
    }
 
    /**
     * Make a pretty-printed JSON text of this JSONArray. Warning: This method assumes that
the data
     * structure is acyclical.
+    *
     * @param indentFactor The number of spaces to add to each level of indentation.
-    * @param indent The indention of the top level.
+    * @param indent       The indention of the top level.
     * @return a printable, displayable, transmittable representation of the array.
     * @throws JSONException
     */
-   String toString(final int indentFactor, final int indent) throws JSONException
-   {
+   String toString(final int indentFactor, final int indent) throws JSONException {
       int len = length();
-      if (len == 0)
-      {
+      if (len == 0) {
          return "[]";
       }
       int i;
       StringBuffer sb = new StringBuffer("[");
-      if (len == 1)
-      {
+      if (len == 1) {
          sb.append(JSONObject.valueToString(myArrayList.get(0), indentFactor, indent));
       }
-      else
-      {
+      else {
          int newindent = indent + indentFactor;
          sb.append('\n');
-         for (i = 0; i < len; i += 1)
-         {
-            if (i > 0)
-            {
+         for (i = 0; i < len; i += 1) {
+            if (i > 0) {
                sb.append(",\n");
             }
-            for (int j = 0; j < newindent; j += 1)
-            {
+            for (int j = 0; j < newindent; j += 1) {
                sb.append(' ');
             }
             sb.append(JSONObject.valueToString(myArrayList.get(i), indentFactor, newindent));
          }
          sb.append('\n');
-         for (i = 0; i < indent; i += 1)
-         {
+         for (i = 0; i < indent; i += 1) {
             sb.append(' ');
          }
       }
@@ -977,32 +898,25 @@ public class JSONArray
     * @return The writer.
     * @throws JSONException
     */
-   public Writer write(final Writer writer) throws JSONException
-   {
-      try
-      {
+   public Writer write(final Writer writer) throws JSONException {
+      try {
          boolean b = false;
          int len = length();
 
          writer.write('[');
 
-         for (int i = 0; i < len; i += 1)
-         {
-            if (b)
-            {
+         for (int i = 0; i < len; i += 1) {
+            if (b) {
                writer.write(',');
             }
             Object v = myArrayList.get(i);
-            if (v instanceof JSONObject)
-            {
-               ((JSONObject)v).write(writer);
+            if (v instanceof JSONObject) {
+               ((JSONObject) v).write(writer);
             }
-            else if (v instanceof JSONArray)
-            {
-               ((JSONArray)v).write(writer);
+            else if (v instanceof JSONArray) {
+               ((JSONArray) v).write(writer);
             }
-            else
-            {
+            else {
                writer.write(JSONObject.valueToString(v));
             }
             b = true;
@@ -1010,8 +924,7 @@ public class JSONArray
          writer.write(']');
          return writer;
       }
-      catch (IOException e)
-      {
+      catch (IOException e) {
          throw new JSONException(e);
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONException.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONException.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONException.java
index 12232d5..abb79b0 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONException.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/json/JSONException.java
@@ -26,33 +26,31 @@ package org.apache.activemq.artemis.utils.json;
 /**
  * The JSONException is thrown by the JSON.org classes then things are amiss.
  */
-public class JSONException extends Exception
-{
+public class JSONException extends Exception {
+
    /**
-   *
-   */
+    *
+    */
    private static final long serialVersionUID = -3940674325153571604L;
 
    private Throwable cause;
 
    /**
     * Constructs a JSONException with an explanatory message.
+    *
     * @param message Detail about the reason for the exception.
     */
-   public JSONException(final String message)
-   {
+   public JSONException(final String message) {
       super(message);
    }
 
-   public JSONException(final Throwable t)
-   {
+   public JSONException(final Throwable t) {
       super(t.getMessage());
       cause = t;
    }
 
    @Override
-   public synchronized Throwable getCause()
-   {
+   public synchronized Throwable getCause() {
       return cause;
    }
 }


Mime
View raw message