Commits

John Marsden committed 22c3372

Marshal Updates. Got a bit excited.

Comments (0)

Files changed (26)

src/main/java/cc/plural/jsonij/FastJSONParser.java

         } else if (r == OPEN_ARRAY) {
             value = parseArray();
         } else {
-            throw new JSONParserException("invalidExpecting2", (char) OPEN_OBJECT, (char) OPEN_ARRAY, (char) r);
+            //throw new JSONParserException("invalidExpecting2", (char) OPEN_OBJECT, (char) OPEN_ARRAY, (char) r);
+            value = parseValue();
         }
         if (target.peek() != -1) {
             //throw new JSONParserException("invalidExtraJunk", (char) OPEN_OBJECT, (char) OPEN_ARRAY);

src/main/java/cc/plural/jsonij/JSON.java

  * types extend Value. The following table documents which class to use when
  * representing each of the JSON types.
  *
- * <table>
- *  <tr>
- *      <td style="border:1px solid black;"><strong>JSON Type</strong></td>
- *      <td style="border:1px solid black;"><strong>Class</strong></td>
- *  </tr>
- *  <tr>
- *      <td style="border:1px solid black;">Object</td>
- *      <td style="border:1px solid black;">JSON.Object<String,Value></td>
- *  </tr>
- *  <tr>
- *      <td style="border:1px solid black;">Array</td>
- *      <td style="border:1px solid black;">JSON.Array<Value></td>
- *  </tr>
- *  <tr>
- *      <td style="border:1px solid black;">String</td>
- *      <td style="border:1px solid black;">JSON.String</td>
- *  </tr>
- *  <tr>
- *      <td style="border:1px solid black;">Numeric</td>
- *      <td style="border:1px solid black;">JSON.Numeric</td>
- *  </tr>
- *  <tr>
- *      <td style="border:1px solid black;">True</td>
- *      <td style="border:1px solid black;">JSON.TRUE</td>
- *  </tr>
- *  <tr>
- *      <td style="border:1px solid black;">False</td>
- *      <td style="border:1px solid black;">JSON.FALSE</td>
- *  </tr>
- *  <tr>
- *      <td style="border:1px solid black;">Null</td>
- *      <td style="border:1px solid black;">JSON.NULL</td>
- *  </tr>
+ * <table> <tr> <td style="border:1px solid black;"><strong>JSON
+ * Type</strong></td> <td style="border:1px solid
+ * black;"><strong>Class</strong></td> </tr> <tr> <td style="border:1px solid
+ * black;">Object</td> <td style="border:1px solid
+ * black;">JSON.Object<String,Value></td> </tr> <tr> <td style="border:1px solid
+ * black;">Array</td> <td style="border:1px solid black;">JSON.Array<Value></td>
+ * </tr> <tr> <td style="border:1px solid black;">String</td> <td
+ * style="border:1px solid black;">JSON.String</td> </tr> <tr> <td
+ * style="border:1px solid black;">Numeric</td> <td style="border:1px solid
+ * black;">JSON.Numeric</td> </tr> <tr> <td style="border:1px solid
+ * black;">True</td> <td style="border:1px solid black;">JSON.TRUE</td> </tr>
+ * <tr> <td style="border:1px solid black;">False</td> <td style="border:1px
+ * solid black;">JSON.FALSE</td> </tr> <tr> <td style="border:1px solid
+ * black;">Null</td> <td style="border:1px solid black;">JSON.NULL</td> </tr>
  * </table>
  *
  * @author J.W.Marsden
      * constructing new JSON.Null instances.
      */
     public static final Null NULL;
-    
     public static final JSONParser parser;
 
     static {
     public static JSON parse(java.lang.String document) throws ParserException, IOException {
         return new JSON(parser.parse(document));
     }
-    
+
     public static JSON parse(InputStream documentStream) throws ParserException, IOException {
         return new JSON(parser.parse(new InputStreamReader(documentStream)));
     }
         return new JSON(parser.parse(documentReader));
     }
 
+    public static Value parseValue(java.lang.String document) throws ParserException, IOException {
+        return parser.parse(document);
+    }
+
     /**
      * JSON Object. Wrapper for ObjectImp.
      *

src/main/java/cc/plural/jsonij/NumericImp.java

 /**
  * Copyright (C) 2010-2011 J.W.Marsden
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- **/
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
 package cc.plural.jsonij;
 
 import java.io.Serializable;
 public class NumericImp extends Value implements Serializable {
 
     /**
-	 * Serial UID
-	 */
-	private static final long serialVersionUID = 7016727603513295556L;
-	
-	protected InternalNumber internalNumberData;
-    
+     * Serial UID
+     */
+    private static final long serialVersionUID = 7016727603513295556L;
+    protected InternalNumber internalNumberData;
+
     public NumericImp(int value) {
         internalNumberData = new LongInternalNumber(value);
     }
-    
+
     public NumericImp(long value) {
         internalNumberData = new LongInternalNumber(value);
     }
-    
+
     public NumericImp(double value) {
         internalNumberData = new DoubleInternalNumber(value);
     }
-     
+
     public NumericImp(Number numberValue) {
-        if(numberValue == null) {
+        if (numberValue == null) {
             internalNumberData = new LongInternalNumber(0);
         }
         internalNumberData = new NumberInternalNumber(numberValue);
     }
-    
+
     /* (non-Javadoc)
      * @see com.realitypipe.json.Value#internalType()
      */
     @Override
     public int hashCode() {
         int hash = 7;
-        hash = 23 * hash + ( this.internalNumberData != null ? this.internalNumberData.hashCode() : 0 );
+        hash = 23 * hash + (this.internalNumberData != null ? this.internalNumberData.hashCode() : 0);
         return hash;
     }
 }

src/main/java/cc/plural/jsonij/StringImp.java

 /**
  * Copyright (C) 2010-2011 J.W.Marsden
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- **/
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
 package cc.plural.jsonij;
 
 import java.io.Serializable;
 
 /**
  * JSON String Implementation.
- * 
+ *
  * @author openecho
  * @version 1.0.0
  */
 public class StringImp extends Value implements Serializable, CharSequence {
 
     /**
-	 * Serial UID
-	 */
-	private static final long serialVersionUID = -9098386245749540342L;
-	
-	/**
+     * Serial UID
+     */
+    private static final long serialVersionUID = -9098386245749540342L;
+    /**
      * Container for the String.
      */
     protected String value;
      * @param orig The original String for this Value
      */
     public StringImp(String orig) {
-        if(orig == null) {
+        if (orig == null) {
             value = "";
         } else {
             value = orig;
                     /**
                      * TODO: Make Constants.
                      */
-                    if(a == 32 || a == 33 || ((a >= 35) && (a <= 91)) || ((a >= 93) && (a <= 127))) {
+                    if (a == 32 || a == 33 || ((a >= 35) && (a <= 91)) || ((a >= 93) && (a <= 127))) {
                         outputStringBuilder.append(c);
                     } else {
                         String hex = Integer.toHexString(a);
                         outputStringBuilder.append("\\u");
-                        for(int j=hex.length();j<4;j++) {
+                        for (int j = hex.length(); j < 4; j++) {
                             outputStringBuilder.append("0");
                         }
                         outputStringBuilder.append(hex);

src/main/java/cc/plural/jsonij/Value.java

 /**
  * Copyright (C) 2010-2011 J.W.Marsden
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- **/
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
 package cc.plural.jsonij;
 
 import java.io.Serializable;
  * Value is extended by every JSON internalType implementation. This class
  * provides generic access to all values to make life a little easier when
  * traversing the JSON Document.
- * 
+ *
  * @author J.W.Marsden
  * @version 1.0.0
  */
 public abstract class Value implements Serializable, Comparable<Value> {
 
-	/**
-	 * Serial UID
-	 */
-	private static final long serialVersionUID = 2774919263250085887L;
-
-	/**
-	 * Current Value Type
-	 */
-	protected TYPE valueType;
+    /**
+     * Serial UID
+     */
+    private static final long serialVersionUID = 2774919263250085887L;
+    /**
+     * Current Value Type
+     */
+    protected TYPE valueType;
 
-	/**
-	 * Type enumeration.
-	 */
-	public enum TYPE {
+    /**
+     * Type enumeration.
+     */
+    public enum TYPE {
 
-		/**
-		 * OBJECT used to denote JSON Object Types.
-		 */
-		OBJECT,
-		/**
-		 * ARRAY used to denote JSON Array Types.
-		 */
-		ARRAY,
-		/**
-		 * STRING used to denote JSON String Types.
-		 */
-		STRING,
-		/**
-		 * NUMERIC used to denote JSON Numeric Types.
-		 */
-		NUMERIC,
-		/**
-		 * TRUE used to denote JSON True Types.
-		 */
-		TRUE,
-		/**
-		 * False used to denote JSON False Types.
-		 */
-		FALSE,
-		/**
-		 * Null used to denote JSON Null Types.
-		 */
-		NULL
-	}
+        /**
+         * OBJECT used to denote JSON Object Types.
+         */
+        OBJECT,
+        /**
+         * ARRAY used to denote JSON Array Types.
+         */
+        ARRAY,
+        /**
+         * STRING used to denote JSON String Types.
+         */
+        STRING,
+        /**
+         * NUMERIC used to denote JSON Numeric Types.
+         */
+        NUMERIC,
+        /**
+         * TRUE used to denote JSON True Types.
+         */
+        TRUE,
+        /**
+         * False used to denote JSON False Types.
+         */
+        FALSE,
+        /**
+         * Null used to denote JSON Null Types.
+         */
+        NULL
+    }
 
-	/**
-	 * Constructor for Value. As a Value constructs it must have a internalType
-	 * or it cannot construct.
-	 */
-	public Value() {
-		this.valueType = internalType();
-		if (this.valueType == null) {
-			throw new NullPointerException("type() method must be implemented and return a valid type.");
-		}
-	}
+    /**
+     * Constructor for Value. As a Value constructs it must have a internalType
+     * or it cannot construct.
+     */
+    public Value() {
+        this.valueType = internalType();
+        if (this.valueType == null) {
+            throw new NullPointerException("type() method must be implemented and return a valid type.");
+        }
+    }
 
-	/**
-	 * Internal Method to find the internalType for the Object. Must be
-	 * implemented and not return null.
-	 * 
-	 * @return The internalType of this JSON Value.
-	 */
-	protected abstract TYPE internalType();
+    /**
+     * Internal Method to find the internalType for the Object. Must be
+     * implemented and not return null.
+     *
+     * @return The internalType of this JSON Value.
+     */
+    protected abstract TYPE internalType();
 
-	/**
-	 * Accessor for the Value TYPE.
-	 * 
-	 * @return TYPE The value valueType.
-	 */
-	public TYPE getValueType() {
-		return valueType;
-	}
+    /**
+     * Accessor for the Value TYPE.
+     *
+     * @return TYPE The value valueType.
+     */
+    public TYPE getValueType() {
+        return valueType;
+    }
 
-	/**
-	 * Accessor for the Value TYPE.
-	 * 
-	 * @return TYPE The value valueType.
-	 */
-	public TYPE type() {
-		return valueType;
-	}
+    /**
+     * Accessor for the Value TYPE.
+     *
+     * @return TYPE The value valueType.
+     */
+    public TYPE type() {
+        return valueType;
+    }
 
-	/**
-	 * Retrieves the size of the Value. If string internalType, this will return
-	 * the length of the String. If this internalType is an Array or an Object
-	 * then it will return the number of elements in the Object. If this Value
-	 * is not a String, Array or Object then this will return -1.
-	 * 
-	 * @return size of the Value or -1 if this Value has no size.
-	 */
-	public int size() {
-		switch (valueType) {
-			case STRING:
-				return ((JSON.String) this).length();
-			case ARRAY:
-				return ((JSON.Array<?>) this).size();
-			case OBJECT:
-				return ((JSON.Object<?, ?>) this).size();
-			default:
-				return -1;
-		}
-	}
+    /**
+     * Retrieves the size of the Value. If string internalType, this will return
+     * the length of the String. If this internalType is an Array or an Object
+     * then it will return the number of elements in the Object. If this Value
+     * is not a String, Array or Object then this will return -1.
+     *
+     * @return size of the Value or -1 if this Value has no size.
+     */
+    public int size() {
+        switch (valueType) {
+            case STRING:
+                return ((JSON.String) this).length();
+            case ARRAY:
+                return ((JSON.Array<?>) this).size();
+            case OBJECT:
+                return ((JSON.Object<?, ?>) this).size();
+            default:
+                return -1;
+        }
+    }
 
-	/**
-	 * Finds the nested elements under this Value. This is effectively the count
-	 * of all JSON Values attached to this Value. This number does not include
-	 * this value itself.
-	 * 
-	 * @return int The count of all Values attached to this Value.
-	 */
-	public abstract int nestedSize();
+    /**
+     * Finds the nested elements under this Value. This is effectively the count
+     * of all JSON Values attached to this Value. This number does not include
+     * this value itself.
+     *
+     * @return int The count of all Values attached to this Value.
+     */
+    public abstract int nestedSize();
 
-	public boolean isNull() {
-		switch (valueType) {
-			case NULL:
-				return true;
-			default:
-				return !getBoolean();
-		}
-	}
+    public boolean isNull() {
+        switch (valueType) {
+            case NULL:
+                return true;
+            default:
+                return !getBoolean();
+        }
+    }
 
-	/**
-	 * Finds the boolean representation for the Value. If the value is JSON.TRUE
-	 * or JSON.FALSE then those booleans are returned. If the value is Numeric
-	 * then true is returned for all values that are not zero. If the value is a
-	 * String then an empty String returns 0. If the value is an Object or Array
-	 * then all sizes that are not zero return true.
-	 * 
-	 * @return boolean The boolean for the Value.
-	 */
-	public boolean getBoolean() {
-		boolean result = false;
-		switch (valueType) {
-			case TRUE:
-				result = true;
-				break;
-			case FALSE:
-				result = false;
-				break;
-			case NUMERIC:
-				result = ((JSON.Numeric) this).intValue() != 0;
-				break;
-			case STRING:
-				result = ((JSON.String) this).length() != 0;
-				break;
-			case ARRAY:
-				result = ((JSON.Array<?>) this).size() != 0;
-				break;
-			case OBJECT:
-				result = ((JSON.Object<?, ?>) this).size() != 0;
-				break;
-		}
-		return result;
-	}
+    /**
+     * Finds the boolean representation for the Value. If the value is JSON.TRUE
+     * or JSON.FALSE then those booleans are returned. If the value is Numeric
+     * then true is returned for all values that are not zero. If the value is a
+     * String then an empty String returns 0. If the value is an Object or Array
+     * then all sizes that are not zero return true.
+     *
+     * @return boolean The boolean for the Value.
+     */
+    public boolean getBoolean() {
+        boolean result = false;
+        switch (valueType) {
+            case TRUE:
+                result = true;
+                break;
+            case FALSE:
+                result = false;
+                break;
+            case NUMERIC:
+                result = ((JSON.Numeric) this).intValue() != 0;
+                break;
+            case STRING:
+                result = ((JSON.String) this).length() != 0;
+                break;
+            case ARRAY:
+                result = ((JSON.Array<?>) this).size() != 0;
+                break;
+            case OBJECT:
+                result = ((JSON.Object<?, ?>) this).size() != 0;
+                break;
+        }
+        return result;
+    }
 
-	/**
-	 * Finds the int representation for the Value. Returns 1 when the value is
-	 * JSON True and 0 when the value is JSON False. When the value is Numeric
-	 * it will return the intValue from Number. If the value is a String then an
-	 * attempt is made to parse the String value into an integer and return it.
-	 * All other types return -1.
-	 * 
-	 * @return int The int for the Value.
-	 */
-	public int getInt() {
-		int result = -1;
-		switch (valueType) {
-			case TRUE:
-				result = 1;
-				break;
-			case FALSE:
-				result = 0;
-				break;
-			case NUMERIC:
-				result = ((JSON.Numeric) this).intValue();
-				break;
-			case STRING:
-				result = Integer.parseInt((this).toString());
-				break;
-		}
-		return result;
-	}
+    /**
+     * Finds the int representation for the Value. Returns 1 when the value is
+     * JSON True and 0 when the value is JSON False. When the value is Numeric
+     * it will return the intValue from Number. If the value is a String then an
+     * attempt is made to parse the String value into an integer and return it.
+     * All other types return -1.
+     *
+     * @return int The int for the Value.
+     */
+    public int getInt() {
+        int result = -1;
+        switch (valueType) {
+            case TRUE:
+                result = 1;
+                break;
+            case FALSE:
+                result = 0;
+                break;
+            case NUMERIC:
+                result = ((JSON.Numeric) this).intValue();
+                break;
+            case STRING:
+                result = Integer.parseInt((this).toString());
+                break;
+        }
+        return result;
+    }
 
-	/**
-	 * Finds the double representation for the Value. Returns 1D when the value
-	 * is JSON True and 0D when the value is JSON False. When the value is
-	 * Numeric it will return the doubleValue from Number. If the value is a
-	 * String then an attempt is made to parse the String value into an Double
-	 * and return it. All other types return -1D.
-	 * 
-	 * @return double The double value for the Value.
-	 */
-	public double getDouble() {
-		double result = -1D;
-		switch (valueType) {
-			case TRUE:
-				result = 1D;
-				break;
-			case FALSE:
-				result = 0D;
-				break;
-			case NUMERIC:
-				result = ((JSON.Numeric) this).doubleValue();
-				break;
-			case STRING:
-				result = Double.parseDouble((this).toString());
-				break;
-		}
-		return result;
-	}
+    /**
+     * Finds the double representation for the Value. Returns 1D when the value
+     * is JSON True and 0D when the value is JSON False. When the value is
+     * Numeric it will return the doubleValue from Number. If the value is a
+     * String then an attempt is made to parse the String value into an Double
+     * and return it. All other types return -1D.
+     *
+     * @return double The double value for the Value.
+     */
+    public double getDouble() {
+        double result = -1D;
+        switch (valueType) {
+            case TRUE:
+                result = 1D;
+                break;
+            case FALSE:
+                result = 0D;
+                break;
+            case NUMERIC:
+                result = ((JSON.Numeric) this).doubleValue();
+                break;
+            case STRING:
+                result = Double.parseDouble((this).toString());
+                break;
+        }
+        return result;
+    }
 
-	/**
-	 * Finds the Number representation for the Value. Returns 1D when the value
-	 * is JSON True and 0D when the value is JSON False. When the value is
-	 * Numeric it will return the Number. If the value is a String then an
-	 * attempt is made to parse the String value into an Double and return it.
-	 * All other types return -1D.
-	 * 
-	 * @return double The double value for the Value.
-	 */
-	public Number getNumber() {
-		Number result = -1D;
-		switch (valueType) {
-			case TRUE:
-				result = 1D;
-				break;
-			case FALSE:
-				result = 0D;
-				break;
-			case NUMERIC:
-				result = ((JSON.Numeric) this).getNumber();
-				break;
-			case STRING:
-				result = Double.parseDouble((this).toString());
-				break;
-		}
-		return result;
-	}
+    /**
+     * Finds the Number representation for the Value. Returns 1D when the value
+     * is JSON True and 0D when the value is JSON False. When the value is
+     * Numeric it will return the Number. If the value is a String then an
+     * attempt is made to parse the String value into an Double and return it.
+     * All other types return -1D.
+     *
+     * @return double The double value for the Value.
+     */
+    public Number getNumber() {
+        Number result = -1D;
+        switch (valueType) {
+            case TRUE:
+                result = 1D;
+                break;
+            case FALSE:
+                result = 0D;
+                break;
+            case NUMERIC:
+                result = ((JSON.Numeric) this).getNumber();
+                break;
+            case STRING:
+                result = Double.parseDouble((this).toString());
+                break;
+        }
+        return result;
+    }
 
-	/**
-	 * Finds the String representation for the Value. When the value is true or
-	 * false it will return "true" or "false" respectively. If the value is
-	 * Numeric it will return the toString() version of the Number instance or
-	 * the String itself. All other values return null.
-	 * 
-	 * @return String The String value for the Value.
-	 */
-	public String getString() {
-		String result = null;
-		switch (valueType) {
-			case TRUE:
-				result = "true";
-				break;
-			case FALSE:
-				result = "false";
-				break;
-			case NUMERIC:
-				result = ((JSON.Numeric) this).toString();
-				break;
-			case STRING:
-				result = (this).toString();
-				break;
-		}
-		return result;
-	}
+    /**
+     * Finds the String representation for the Value. When the value is true or
+     * false it will return "true" or "false" respectively. If the value is
+     * Numeric it will return the toString() version of the Number instance or
+     * the String itself. All other values return null.
+     *
+     * @return String The String value for the Value.
+     */
+    public String getString() {
+        String result = null;
+        switch (valueType) {
+            case TRUE:
+                result = "true";
+                break;
+            case FALSE:
+                result = "false";
+                break;
+            case NUMERIC:
+                result = ((JSON.Numeric) this).toString();
+                break;
+            case STRING:
+                result = (this).toString();
+                break;
+        }
+        return result;
+    }
 
-	/**
-	 * Extracts a Value instance at an Index. This method only returns values
-	 * when the internalType is OBJECT or ARRAY. All other cases will return
-	 * null.
-	 * 
-	 * @param i
-	 *            The index to get the value for.
-	 * @return Value The Value at the index or null.
-	 */
-	public Value get(int i) {
-		Value result = null;
-		switch (valueType) {
-			case ARRAY:
-				result = ((JSON.Array<?>) this).get(i);
-				break;
-			case OBJECT:
-				result = ((JSON.Object<?, ?>) this).get(i);
-				break;
-		}
-		return result;
-	}
+    /**
+     * Extracts a Value instance at an Index. This method only returns values
+     * when the internalType is OBJECT or ARRAY. All other cases will return
+     * null.
+     *
+     * @param i The index to get the value for.
+     * @return Value The Value at the index or null.
+     */
+    public Value get(int i) {
+        Value result = null;
+        switch (valueType) {
+            case ARRAY:
+                result = ((JSON.Array<?>) this).get(i);
+                break;
+            case OBJECT:
+                result = ((JSON.Object<?, ?>) this).get(i);
+                break;
+        }
+        return result;
+    }
 
-	/**
-	 * Tests if there is a Value at the specified key. This method only responds
-	 * when the Value is of internalType OBJECT. All other cases will return
-	 * false.
-	 * 
-	 * @param key
-	 *            Key to extract the value from.
-	 * @return true when there is a value at the key.
-	 */
-	public boolean has(String key) {
-		boolean result = false;
-		switch (valueType) {
-			case OBJECT:
-				result = ((JSON.Object<?, ?>) this).containsKey(new JSON.String(key));
-				break;
-		}
-		return result;
-	}
+    /**
+     * Tests if there is a Value at the specified key. This method only responds
+     * when the Value is of internalType OBJECT. All other cases will return
+     * false.
+     *
+     * @param key Key to extract the value from.
+     * @return true when there is a value at the key.
+     */
+    public boolean has(String key) {
+        boolean result = false;
+        switch (valueType) {
+            case OBJECT:
+                result = ((JSON.Object<?, ?>) this).containsKey(new JSON.String(key));
+                break;
+        }
+        return result;
+    }
 
-	public Set<CharSequence> valueKeySet() {
-		Set<CharSequence> keys = null;
-		switch (valueType) {
-			case OBJECT:
-				keys = ((JSON.Object<CharSequence, Value>) this).mapValue.keySet();
-				break;
-		}
-		return keys;
-	}
+    public Set<CharSequence> valueKeySet() {
+        Set<CharSequence> keys = null;
+        switch (valueType) {
+            case OBJECT:
+                keys = ((JSON.Object<CharSequence, Value>) this).mapValue.keySet();
+                break;
+        }
+        return keys;
+    }
 
-	/**
-	 * Gets a Value at a key for the current Value. This method only responds
-	 * when the Value is of internalType OBJECT. All other cases will return
-	 * null.
-	 * 
-	 * @param key
-	 *            Key to extract the value from.
-	 * @return Value The value at the given Key.
-	 */
-	public Value get(CharSequence key) {
-		Value result = null;
-		switch (valueType) {
-			case OBJECT:
-				result = ((JSON.Object<?, ?>) this).safeGet(key.toString());
-				break;
-		}
-		return result;
-	}
+    /**
+     * Gets a Value at a key for the current Value. This method only responds
+     * when the Value is of internalType OBJECT. All other cases will return
+     * null.
+     *
+     * @param key Key to extract the value from.
+     * @return Value The value at the given Key.
+     */
+    public Value get(CharSequence key) {
+        Value result = null;
+        switch (valueType) {
+            case OBJECT:
+                result = ((JSON.Object<?, ?>) this).safeGet(key.toString());
+                break;
+        }
+        return result;
+    }
 
-	/**
-	 * Converts the current Value into a JSON String that represents it.
-	 * 
-	 * @return The JSON Value as JSON String.
-	 */
-	public abstract String toJSON();
+    /**
+     * Converts the current Value into a JSON String that represents it.
+     *
+     * @return The JSON Value as JSON String.
+     */
+    public abstract String toJSON();
 
-	/**
-	 * Default toString for a JSON Value. Returns the JSON string for the Value.
-	 * 
-	 * @return
-	 */
-	@Override
-	public String toString() {
-		return toJSON();
-	}
+    /**
+     * Default toString for a JSON Value. Returns the JSON string for the Value.
+     *
+     * @return
+     */
+    @Override
+    public String toString() {
+        return toJSON();
+    }
 
-	@Override
-	public boolean equals(Object obj) {
-		if (obj == null) {
-			return false;
-		}
-		if (getClass() != obj.getClass()) {
-			return false;
-		}
-		final Value o = (Value) obj;
-		boolean equalsResult = false;
-		if (internalType() == Value.TYPE.OBJECT) {
-			if (o.internalType() == Value.TYPE.OBJECT) {
-				if (o.size() == size()) {
-					equalsResult = true;
-					Iterator<CharSequence> keySetIterator = valueKeySet().iterator();
-					Value thisValue = null;
-					Value otherValue = null;
-					while (keySetIterator.hasNext()) {
-						CharSequence key = keySetIterator.next();
-						thisValue = get(key);
-						otherValue = o.get(key);
-						if (otherValue != null) {
-							if (!thisValue.equals(otherValue)) {
-								equalsResult = false;
-								break;
-							}
-						}
-					}
-				} else {
-					equalsResult = false;
-				}
-			} else {
-				equalsResult = toString().equals(o.toString());
-			}
-		} else if (internalType() == Value.TYPE.ARRAY) {
-			if (o.internalType() == Value.TYPE.ARRAY) {
-				if (o.size() == size()) {
-					equalsResult = true;
-					for (int i = 0; i < size(); i++) {
-						if (!get(i).equals(o.get(i))) {
-							equalsResult = false;
-							break;
-						}
-					}
-				} else {
-					equalsResult = false;
-				}
-			} else {
-				equalsResult = toString().equals(o.toString());
-			}
-		} else if (internalType() == Value.TYPE.NULL) {
-			equalsResult = (isNull() && o.isNull());
-		} else if (internalType() == Value.TYPE.TRUE || internalType() == Value.TYPE.FALSE) {
-			equalsResult = (getBoolean() == o.getBoolean());
-		} else if (internalType() == Value.TYPE.NUMERIC) {
-			Number thisNumber = getNumber();
-			Number otherNumber = o.getNumber();
-			if (thisNumber != null && otherNumber != null) {
-				equalsResult = thisNumber.equals(otherNumber);
-			}
-		} else if (internalType() == Value.TYPE.STRING) {
-			equalsResult = getString().equals(o.getString());
-		}
-		return equalsResult;
-	}
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final Value o = (Value) obj;
+        boolean equalsResult = false;
+        if (internalType() == Value.TYPE.OBJECT) {
+            if (o.internalType() == Value.TYPE.OBJECT) {
+                if (o.size() == size()) {
+                    equalsResult = true;
+                    Iterator<CharSequence> keySetIterator = valueKeySet().iterator();
+                    Value thisValue = null;
+                    Value otherValue = null;
+                    while (keySetIterator.hasNext()) {
+                        CharSequence key = keySetIterator.next();
+                        thisValue = get(key);
+                        otherValue = o.get(key);
+                        if (otherValue != null) {
+                            if (!thisValue.equals(otherValue)) {
+                                equalsResult = false;
+                                break;
+                            }
+                        }
+                    }
+                } else {
+                    equalsResult = false;
+                }
+            } else {
+                equalsResult = toString().equals(o.toString());
+            }
+        } else if (internalType() == Value.TYPE.ARRAY) {
+            if (o.internalType() == Value.TYPE.ARRAY) {
+                if (o.size() == size()) {
+                    equalsResult = true;
+                    for (int i = 0; i < size(); i++) {
+                        if (!get(i).equals(o.get(i))) {
+                            equalsResult = false;
+                            break;
+                        }
+                    }
+                } else {
+                    equalsResult = false;
+                }
+            } else {
+                equalsResult = toString().equals(o.toString());
+            }
+        } else if (internalType() == Value.TYPE.NULL) {
+            equalsResult = (isNull() && o.isNull());
+        } else if (internalType() == Value.TYPE.TRUE || internalType() == Value.TYPE.FALSE) {
+            equalsResult = (getBoolean() == o.getBoolean());
+        } else if (internalType() == Value.TYPE.NUMERIC) {
+            Number thisNumber = getNumber();
+            Number otherNumber = o.getNumber();
+            if (thisNumber != null && otherNumber != null) {
+                equalsResult = thisNumber.equals(otherNumber);
+            }
+        } else if (internalType() == Value.TYPE.STRING) {
+            equalsResult = getString().equals(o.getString());
+        }
+        return equalsResult;
+    }
 
-	@Override
-	public int hashCode() {
-		int hash = 7;
-		hash = 13 * hash + (this.valueType != null ? this.valueType.hashCode() : 0);
-		if (internalType() == Value.TYPE.OBJECT) {
-			for (int i = 0; i < size(); i++) {
-				hash = 13 * hash + (get(i).hashCode());
-			}
-		} else if (internalType() == Value.TYPE.ARRAY) {
-			for (int i = 0; i < size(); i++) {
-				hash = 13 * hash + (get(i).hashCode());
-			}
-		} else if (internalType() == Value.TYPE.NULL) {
-			hash = 13 * hash + (JSON.NULL.hashCode());
-		} else if (internalType() == Value.TYPE.TRUE) {
-			hash = 13 * hash + (JSON.TRUE.hashCode());
-		} else if (internalType() == Value.TYPE.FALSE) {
-			hash = 13 * hash + (JSON.FALSE.hashCode());
-		} else if (internalType() == Value.TYPE.NUMERIC) {
-			hash = 13 * hash + (getNumber().hashCode());
-		} else if (internalType() == Value.TYPE.STRING) {
-			hash = (getString() != null) ? getString().hashCode() : 0;
-		}
-		return hash;
-	}
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 13 * hash + (this.valueType != null ? this.valueType.hashCode() : 0);
+        if (internalType() == Value.TYPE.OBJECT) {
+            for (int i = 0; i < size(); i++) {
+                hash = 13 * hash + (get(i).hashCode());
+            }
+        } else if (internalType() == Value.TYPE.ARRAY) {
+            for (int i = 0; i < size(); i++) {
+                hash = 13 * hash + (get(i).hashCode());
+            }
+        } else if (internalType() == Value.TYPE.NULL) {
+            hash = 13 * hash + (JSON.NULL.hashCode());
+        } else if (internalType() == Value.TYPE.TRUE) {
+            hash = 13 * hash + (JSON.TRUE.hashCode());
+        } else if (internalType() == Value.TYPE.FALSE) {
+            hash = 13 * hash + (JSON.FALSE.hashCode());
+        } else if (internalType() == Value.TYPE.NUMERIC) {
+            hash = 13 * hash + (getNumber().hashCode());
+        } else if (internalType() == Value.TYPE.STRING) {
+            hash = (getString() != null) ? getString().hashCode() : 0;
+        }
+        return hash;
+    }
 
-	public int compareTo(Value o) {
-		int compare = 0;
-		if (internalType() == Value.TYPE.OBJECT) {
-			if (o.internalType() == Value.TYPE.NULL || o.internalType() == Value.TYPE.TRUE || o.internalType() == Value.TYPE.FALSE) {
-				compare = 1;
-			} else {
-				compare = toJSON().compareTo(o.toJSON());
-			}
-		} else if (internalType() == Value.TYPE.ARRAY) {
-			if (o.internalType() == Value.TYPE.NULL || o.internalType() == Value.TYPE.TRUE || o.internalType() == Value.TYPE.FALSE || o.internalType() == Value.TYPE.OBJECT) {
-				compare = 1;
-			} else {
-				compare = toJSON().compareTo(o.toJSON());
-			}
-		} else if (internalType() == Value.TYPE.NULL) {
-			if (o.internalType() == Value.TYPE.NULL) {
-				compare = 0;
-			} else {
-				compare = -1;
-			}
-		} else if (internalType() == Value.TYPE.TRUE) {
-			if (o.internalType() == Value.TYPE.NULL) {
-				compare = 1;
-			} else if (o.internalType() == Value.TYPE.TRUE) {
-				compare = 0;
-			} else {
-				compare = -1;
-			}
-		} else if (internalType() == Value.TYPE.FALSE) {
-			if (o.internalType() == Value.TYPE.NULL) {
-				compare = 1;
-			} else if (o.internalType() == Value.TYPE.TRUE) {
-				compare = 1;
-			} else if (o.internalType() == Value.TYPE.FALSE) {
-				compare = 0;
-			} else {
-				compare = -1;
-			}
-		} else if (internalType() == Value.TYPE.NUMERIC) {
-			double thisDouble = getDouble();
-			double thatDouble = o.getDouble();
-			if (thisDouble < thatDouble) {
-				compare = -1;
-			} else if (thisDouble == thatDouble) {
-				compare = 0;
-			} else if (thisDouble > thatDouble) {
-				compare = 1;
-			}
-		} else if (internalType() == Value.TYPE.STRING) {
-			compare = getString().compareTo(o.getString());
-		}
-		return compare;
-	}
+    public int compareTo(Value o) {
+        int compare = 0;
+        if (internalType() == Value.TYPE.OBJECT) {
+            if (o.internalType() == Value.TYPE.NULL || o.internalType() == Value.TYPE.TRUE || o.internalType() == Value.TYPE.FALSE) {
+                compare = 1;
+            } else {
+                compare = toJSON().compareTo(o.toJSON());
+            }
+        } else if (internalType() == Value.TYPE.ARRAY) {
+            if (o.internalType() == Value.TYPE.NULL || o.internalType() == Value.TYPE.TRUE || o.internalType() == Value.TYPE.FALSE || o.internalType() == Value.TYPE.OBJECT) {
+                compare = 1;
+            } else {
+                compare = toJSON().compareTo(o.toJSON());
+            }
+        } else if (internalType() == Value.TYPE.NULL) {
+            if (o.internalType() == Value.TYPE.NULL) {
+                compare = 0;
+            } else {
+                compare = -1;
+            }
+        } else if (internalType() == Value.TYPE.TRUE) {
+            if (o.internalType() == Value.TYPE.NULL) {
+                compare = 1;
+            } else if (o.internalType() == Value.TYPE.TRUE) {
+                compare = 0;
+            } else {
+                compare = -1;
+            }
+        } else if (internalType() == Value.TYPE.FALSE) {
+            if (o.internalType() == Value.TYPE.NULL) {
+                compare = 1;
+            } else if (o.internalType() == Value.TYPE.TRUE) {
+                compare = 1;
+            } else if (o.internalType() == Value.TYPE.FALSE) {
+                compare = 0;
+            } else {
+                compare = -1;
+            }
+        } else if (internalType() == Value.TYPE.NUMERIC) {
+            double thisDouble = getDouble();
+            double thatDouble = o.getDouble();
+            if (thisDouble < thatDouble) {
+                compare = -1;
+            } else if (thisDouble == thatDouble) {
+                compare = 0;
+            } else if (thisDouble > thatDouble) {
+                compare = 1;
+            }
+        } else if (internalType() == Value.TYPE.STRING) {
+            compare = getString().compareTo(o.getString());
+        }
+        return compare;
+    }
 }

src/main/java/cc/plural/jsonij/marshal/Inspector.java

-/**
- * Copyright (C) 2010-2011 J.W.Marsden
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package cc.plural.jsonij.marshal;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import cc.plural.jsonij.marshal.InspectorProperty.TYPE;
-import cc.plural.jsonij.marshal.annotation.JSONAccessor;
-import cc.plural.jsonij.marshal.annotation.JSONCollector;
-import cc.plural.jsonij.marshal.annotation.JSONIgnore;
-import cc.plural.jsonij.marshal.annotation.JSONMutator;
-import cc.plural.jsonij.marshal.annotation.JSONName;
-import cc.plural.jsonij.reflect.InspectionFilter;
-
-/**
- *
- * @author openecho
- * @deprecated 
- */
-public class Inspector {
-
-    public static final String IS_PREFIX;
-
-    public static final String SET_PREFIX;
-
-    public static final String GET_PREFIX;
-
-    private Object o;
-
-    private Class<?> c;
-
-    private InspectorProperty[] properties;
-
-    private InspectionFilter filter;
-
-    private boolean innerArray;
-
-    private boolean innerObject;
-
-    static {
-        IS_PREFIX = "is";
-        SET_PREFIX = "set";
-        GET_PREFIX = "get";
-    }
-
-    public Inspector(Class<?> c) {
-        this.c = c;
-        this.o = null;
-        properties = null;
-        filter = InspectionFilter.getDefaultFilters();
-        innerArray = false;
-        innerObject = false;
-    }
-
-    public Inspector(Object o) {
-        this.o = o;
-        properties = null;
-        filter = InspectionFilter.getDefaultFilters();
-        innerArray = false;
-        innerObject = false;
-    }
-
-    public Object getC() {
-        return c;
-    }
-
-    public Object getO() {
-        return o;
-    }
-
-    public boolean hasInnerArray() {
-        return innerArray;
-    }
-
-    public boolean hasInnerObject() {
-        return innerObject;
-    }
-
-    public boolean hasProperty(String name) {
-        for(InspectorProperty property : properties) {
-            if(property.getPropertyName().equals(name)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public InspectorProperty getProperty(String name) {
-        for(InspectorProperty property : properties) {
-            if(property.getPropertyName().equals(name)) {
-                return property;
-            }
-        }
-        return null;
-    }
-
-    public void inspect() {
-        if(o == null && c == null) {
-            return;
-        }
-        if(o != null) {
-            c = o.getClass();
-        }
-        Class<?> objectClass = c;
-        // Inspect Properties
-        InspectorProperty[] propertyList = getMethodProperties(objectClass);
-        if(propertyList != null) {
-            InspectorProperty[] fieldPropertyList = getAttributeProperties(objectClass);
-            if(fieldPropertyList != null) {
-                HashMap<String, InspectorProperty> propertiesMap = new HashMap<String, InspectorProperty>();
-                for(InspectorProperty prop : propertyList) {
-                    propertiesMap.put(prop.getPropertyName(), prop);
-                }
-                for(InspectorProperty prop : fieldPropertyList) {
-                    if(propertiesMap.containsKey(prop.getPropertyName())) {
-                        InspectorProperty existingProp = propertiesMap.get(prop.getPropertyName());
-                        if(!existingProp.hasAccessor()) {
-                            existingProp.setAccessName(prop.getAccessName());
-                            existingProp.setAccessPropertyType(TYPE.FIELD);
-                        }
-                        if(!existingProp.hasMutator()) {
-                            existingProp.setMutateName(prop.getMutateName());
-                            existingProp.setMutatePropertyType(TYPE.FIELD);
-                        }
-                        if(prop.getAnnotations() != null && existingProp.getAnnotations() != null) {
-                            existingProp.getAnnotations().addAll(prop.getAnnotations());
-                        } else if(prop.getAnnotations() != null && existingProp.getAnnotations() == null) {
-                            existingProp.setAnnotations(prop.getAnnotations());
-                        }
-                    } else {
-                        propertiesMap.put(prop.getPropertyName(), prop);
-                    }
-                }
-                propertyList = new InspectorProperty[propertiesMap.size()];
-                propertiesMap.values().toArray(propertyList);
-            }
-        } else {
-            propertyList = getAttributeProperties(objectClass);
-        }
-
-        if(propertyList == null) {
-            propertyList = new InspectorProperty[0];
-        }
-        properties = propertyList;
-
-        // Inspect inner array (List type) and Inspect inner object (Map type)
-        Class<?>[] interfaces;
-        Class<?> parent = objectClass.getSuperclass();
-        if(parent != null) {
-            do {
-                interfaces = parent.getInterfaces();
-                for(int i = 0; i < Array.getLength(interfaces); i++) {
-                    if(interfaces[i] == List.class) {
-                        innerArray = true;
-                    }
-                    if(interfaces[i] == Map.class) {
-                        innerObject = true;
-                    }
-                    if(innerArray && innerObject) {
-                        break;
-                    }
-                }
-                if(innerArray && innerObject) {
-                    break;
-                }
-            } while((parent = parent.getSuperclass()) != null);
-        }
-    }
-
-    public InspectorProperty[] getAttributeProperties(Class<?> objectClass) {
-        InspectorProperty[] result = null;
-        HashMap<String, InspectorProperty> attributeProperties = new HashMap<String, InspectorProperty>();
-        Field[] objectFields = objectClass.getFields();
-        for(Field field : objectFields) {
-            if(isJSONIgnored(field) || filter.isFiltered(field.getDeclaringClass())) {
-                continue;
-            }
-            InspectionData fieldInspectionData = getFieldInspectionData(field);
-            if(fieldInspectionData == null || !fieldInspectionData.hasPropertyName()) {
-                continue;
-            }
-            String propertyName = fieldInspectionData.getPropertyName();
-            InspectorProperty property = null;
-            if(!attributeProperties.containsKey(propertyName)) {
-                property = new InspectorProperty(propertyName, TYPE.FIELD);
-                attributeProperties.put(propertyName, property);
-                property.setPropertyName(propertyName);
-                property.setAccessName(fieldInspectionData.getName());
-                property.setMutateName(fieldInspectionData.getName());
-                property.setAccessReturnType(fieldInspectionData.getReturnType());
-                property.setMutateInputType(fieldInspectionData.getArgumentType());
-
-                if(field.getAnnotations() != null) {
-                    property.annotations = new ArrayList<Annotation>();
-                    property.annotations.addAll(Arrays.asList(field.getAnnotations()));
-                }
-            }
-        }
-        if(!attributeProperties.isEmpty()) {
-            result = new InspectorProperty[attributeProperties.size()];
-            attributeProperties.values().toArray(result);
-        }
-        return result;
-    }
-
-    public InspectorProperty[] getMethodProperties(Class<?> objectClass) {
-        InspectorProperty[] result = null;
-        HashMap<String, InspectorProperty> methodProperties = new HashMap<String, InspectorProperty>();
-        Method[] objectMethods = objectClass.getMethods();
-        for(Method method : objectMethods) {
-            if(isJSONIgnored(method) || filter.isFiltered(method.getDeclaringClass())) {
-                continue;
-            }
-            InspectionData methodInspectionData = getMethodInspectionData(method);
-            if(methodInspectionData == null || !methodInspectionData.hasPropertyName()) {
-                continue;
-            }
-            String propertyName = methodInspectionData.getPropertyName();
-            InspectorProperty property;
-            if(methodProperties.containsKey(propertyName)) {
-                property = methodProperties.get(propertyName);
-            } else {
-                property = new InspectorProperty(propertyName, TYPE.METHOD);
-                methodProperties.put(propertyName, property);
-            }
-            if(methodInspectionData.getAccessType() == ACCESS_TYPE.ACCESS && !property.hasAccessor()) {
-                property.setAccessName(methodInspectionData.getName());
-                property.setAccessReturnType(methodInspectionData.getReturnType());
-            } else if(methodInspectionData.getAccessType() == ACCESS_TYPE.MUTATE && !property.hasMutator()) {
-                property.setMutateName(methodInspectionData.getName());
-                property.setMutateInputType(methodInspectionData.getArgumentType());
-            }
-
-            if(method.getAnnotations() != null && property != null) {
-                property.annotations = new ArrayList<Annotation>();
-                property.annotations.addAll(Arrays.asList(method.getAnnotations()));
-            }
-        }
-        if(!methodProperties.isEmpty()) {
-            result = new InspectorProperty[methodProperties.size()];
-            methodProperties.values().toArray(result);
-        }
-        return result;
-    }
-
-    public InspectionData getFieldInspectionData(Field field) {
-        InspectionData fieldInspectionData = new InspectionData();
-        fieldInspectionData.setName(field.getName());
-        fieldInspectionData.setAccessType(ACCESS_TYPE.BOTH);
-        String jsonName = Inspector.getJSONName(field);
-        if(jsonName != null) {
-            fieldInspectionData.setPropertyName(jsonName);
-        }
-        if(!fieldInspectionData.hasPropertyName()) {
-            fieldInspectionData.setPropertyName(fieldInspectionData.getName());
-        }
-        fieldInspectionData.setArgumentType(field.getType());
-        fieldInspectionData.setReturnType(field.getType());
-        return fieldInspectionData;
-    }
-
-    public InspectionData getMethodInspectionData(Method method) {
-        InspectionData methodInspectionData = new InspectionData();
-        methodInspectionData.setName(method.getName());
-        String jsonName = Inspector.getJSONName(method);
-        if(jsonName != null) {
-            methodInspectionData.setPropertyName(jsonName);
-        }
-        if(!methodInspectionData.hasPropertyName()) {
-            String accessorName = Inspector.getJSONAccessor(method);
-            if(accessorName != null) {
-                methodInspectionData.setPropertyName(accessorName);
-                methodInspectionData.setAccessType(ACCESS_TYPE.ACCESS);
-            }
-        }
-        if(!methodInspectionData.hasPropertyName()) {
-            String mutatorName = Inspector.getJSONMutator(method);
-            if(mutatorName != null) {
-                methodInspectionData.setPropertyName(mutatorName);
-                methodInspectionData.setAccessType(ACCESS_TYPE.MUTATE);
-            }
-        }
-        methodInspectionData.setReturnType(method.getReturnType());
-        if(!methodInspectionData.hasPropertyName()) {
-            char ch;
-            String propertyName;
-            String methodName = methodInspectionData.getName();
-            Class<?> returnType = methodInspectionData.getReturnType();
-            if(methodName.length() > IS_PREFIX.length() && methodName.startsWith(IS_PREFIX) && returnType == boolean.class && Character.isUpperCase(ch = methodName.charAt(IS_PREFIX.length()))) {
-                propertyName = Character.toLowerCase(ch) + methodName.substring(IS_PREFIX.length() + 1, methodName.length());
-                methodInspectionData.setPropertyName(propertyName);
-                methodInspectionData.setAccessType(ACCESS_TYPE.ACCESS);
-            } else if(methodName.length() > SET_PREFIX.length() && methodName.startsWith(SET_PREFIX) && Character.isUpperCase(ch = methodName.charAt(SET_PREFIX.length()))) {
-                propertyName = Character.toLowerCase(ch) + methodName.substring(SET_PREFIX.length() + 1, methodName.length());
-                methodInspectionData.setPropertyName(propertyName);
-                methodInspectionData.setAccessType(ACCESS_TYPE.MUTATE);
-            } else if(methodName.length() > GET_PREFIX.length() && methodName.startsWith(GET_PREFIX) && Character.isUpperCase(ch = methodName.charAt(GET_PREFIX.length())) && returnType != null) {
-                propertyName = Character.toLowerCase(ch) + methodName.substring(GET_PREFIX.length() + 1, methodName.length());
-                methodInspectionData.setPropertyName(propertyName);
-                methodInspectionData.setAccessType(ACCESS_TYPE.ACCESS);
-            }
-        }
-        if(methodInspectionData.getAccessType() == ACCESS_TYPE.ACCESS) {
-            Class<?> returnType = method.getReturnType();
-            if(returnType != null) {
-                methodInspectionData.setReturnType(returnType);
-            } else {
-                return null;
-            }
-        } else if(methodInspectionData.getAccessType() == ACCESS_TYPE.MUTATE) {
-            Class<?>[] parameterTypes = method.getParameterTypes();
-            if(Array.getLength(parameterTypes) == 1) {
-                Class<?> parameterType = parameterTypes[0];
-                methodInspectionData.setArgumentType(parameterType);
-            } else {
-                return null;
-            }
-        }
-        return methodInspectionData;
-    }
-
-    public InspectorProperty[] getProperties() {
-        if(o != null && properties == null) {
-            inspect();
-        }
-        return properties;
-    }
-
-    public boolean hasCollector() {
-        for(InspectorProperty prop : properties) {
-            if(prop.getAnnotations() != null) {
-                for(Annotation annotation : prop.getAnnotations()) {
-                    if(annotation instanceof JSONCollector) {
-                        return true;
-                    }
-                }
-            }
-        }
-        return false;
-    }
-
-    public InspectorProperty getCollector() {
-        for(InspectorProperty prop : properties) {
-            if(prop.getAnnotations() != null) {
-                for(Annotation annotation : prop.getAnnotations()) {
-                    if(annotation instanceof JSONCollector) {
-                        return prop;
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    public void setProperties(InspectorProperty[] properties) {
-        this.properties = properties;
-    }
-
-    private boolean isJSONIgnored(AccessibleObject object) {
-        return object.getAnnotation(JSONIgnore.class) != null;
-    }
-
-    private static String getAnnotatedName(AccessibleObject object) {
-        String name = getJSONName(object);
-        if(name == null) {
-            name = getJSONMutator(object);
-        }
-        if(name == null) {
-            name = getJSONAccessor(object);
-        }
-        return name;
-    }
-
-    private static String getJSONName(AccessibleObject object) {
-        String name = null;
-        JSONName jsonNameAnnotation = object.getAnnotation(JSONName.class);
-        if(jsonNameAnnotation != null) {
-            name = jsonNameAnnotation.value();
-        }
-        return name;
-    }
-
-    private static String getJSONMutator(AccessibleObject object) {
-        String name = null;
-        JSONMutator jsonMutatorAnnotation = object.getAnnotation(JSONMutator.class);
-        if(jsonMutatorAnnotation != null) {
-            name = jsonMutatorAnnotation.value();
-        }
-        return name;
-    }
-
-    private static String getJSONAccessor(AccessibleObject object) {
-        String name = null;
-        JSONAccessor jsonAccessorAnnotation = object.getAnnotation(JSONAccessor.class);
-        if(jsonAccessorAnnotation != null) {
-            name = jsonAccessorAnnotation.value();
-        }
-        return name;
-    }
-
-    public enum ACCESS_TYPE {
-
-        ACCESS,
-        MUTATE,
-        BOTH
-
-    }
-
-    public static class InspectionData {
-
-        protected String name;
-
-        protected String propertyName;
-
-        protected Class<?> returnType;
-
-        protected Class<?> argumentType;
-
-        protected ACCESS_TYPE accessType;
-
-        protected Annotation[] annotations;
-
-        public InspectionData() {
-            name = null;
-            propertyName = null;
-            returnType = null;
-            accessType = null;
-            annotations = null;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        public String getPropertyName() {
-            return propertyName;
-        }
-
-        public void setPropertyName(String propertyName) {
-            this.propertyName = propertyName;
-        }
-
-        public Class<?> getReturnType() {
-            return returnType;
-        }
-
-        public void setReturnType(Class<?> returnType) {
-            this.returnType = returnType;
-        }
-
-        public Class<?> getArgumentType() {
-            return argumentType;
-        }
-
-        public void setArgumentType(Class<?> argumentType) {
-            this.argumentType = argumentType;
-        }
-
-        public boolean hasPropertyName() {
-            return propertyName != null;
-        }
-
-        public ACCESS_TYPE getAccessType() {
-            return accessType;
-        }
-
-        public void setAccessType(ACCESS_TYPE accessType) {
-            this.accessType = accessType;
-        }
-
-        public Annotation[] getAnnotations() {
-            return annotations;
-        }
-
-        public void setAnnotations(Annotation[] annotations) {
-            this.annotations = annotations;
-        }
-    }
-
-    public static boolean isMapType(Class<?> c) {
-        Class<?> currentClass = c;
-        do {
-            Class<?>[] interfaces = currentClass.getInterfaces();
-            for(Class<?> i : interfaces) {
-                if(i == Map.class) {
-                    return true;
-                }
-            }
-        } while((currentClass = currentClass.getSuperclass()) != null);
-        return false;
-    }
-
-    public static boolean isListType(Class<?> c) {
-        Class<?> currentClass = c;
-        do {
-            Class<?>[] interfaces = currentClass.getInterfaces();
-            for(Class<?> i : interfaces) {
-                if(i == List.class) {
-                    return true;
-                }
-            }
-        } while((currentClass = currentClass.getSuperclass()) != null);
-        return false;
-    }
-}

src/main/java/cc/plural/jsonij/marshal/InspectorProperty.java

-/*
- *  Copyright 2011 jmarsden.
- * 
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- * 
- *       http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  under the License.
- */
-package cc.plural.jsonij.marshal;
-
-import java.lang.annotation.Annotation;
-import java.util.List;
-
-/**
- * @deprecated 
- */
-public class InspectorProperty {
-
-    public enum TYPE {
-
-        FIELD,
-        METHOD
-
-    }
-    public String propertyName;
-
-    public String accessName;
-
-    public String mutateName;
-
-    public TYPE accessPropertyType;
-
-    public TYPE mutatePropertyType;
-
-    public Class<?> accessReturnType;
-
-    public Class<?> mutateInputType;
-
-    public List<Annotation> annotations;
-
-    public InspectorProperty() {
-        propertyName = null;
-        accessPropertyType = null;
-        mutatePropertyType = null;
-        accessName = null;
-        mutateName = null;
-        annotations = null;
-    }
-
-    public InspectorProperty(String name, TYPE accessType) {
-        this.propertyName = name;
-        this.accessPropertyType = accessType;
-        this.mutatePropertyType = accessType;
-        accessName = null;
-        mutateName = null;
-    }
-
-    public TYPE getAccessPropertyType() {
-        return accessPropertyType;
-    }
-
-    public void setAccessPropertyType(TYPE propertyType) {
-        this.accessPropertyType = propertyType;
-    }
-
-    public TYPE getMutatePropertyType() {
-        return mutatePropertyType;
-    }
-
-    public void setMutatePropertyType(TYPE propertyType) {
-        this.mutatePropertyType = propertyType;
-    }
-
-    public String getAccessName() {
-        return accessName;
-    }
-
-    public void setAccessName(String accessName) {
-        this.accessName = accessName;
-    }
-
-    public String getMutateName() {
-        return mutateName;
-    }
-
-    public void setMutateName(String mutateName) {
-        this.mutateName = mutateName;
-    }
-
-    public String getPropertyName() {
-        return propertyName;
-    }
-
-    public void setPropertyName(String name) {
-        this.propertyName = name;
-    }
-
-    public Class<?> getAccessReturnType() {
-        return accessReturnType;
-    }
-
-    public void setAccessReturnType(Class<?> accessReturnType) {
-        this.accessReturnType = accessReturnType;
-    }
-
-    public Class<?> getMutateInputType() {
-        return mutateInputType;
-    }
-
-    public void setMutateInputType(Class<?> mutateInputType) {
-        this.mutateInputType = mutateInputType;
-    }
-
-    public boolean hasAccessor() {
-        return accessPropertyType == TYPE.FIELD || (accessName != null);
-    }
-
-    public boolean hasMutator() {
-        return mutatePropertyType == TYPE.FIELD || (mutateName != null);
-    }
-
-    public List<Annotation> getAnnotations() {
-        return annotations;
-    }
-
-    public void setAnnotations(List<Annotation> annotations) {
-        this.annotations = annotations;
-    }
-
-    @Override
-    public String toString() {
-        return String.format("Property %s (Access %s %s):(Mutate %s %s)", propertyName, accessReturnType, accessName, mutateInputType, mutateName);
-    }
-}

src/main/java/cc/plural/jsonij/marshal/JSONCodecStore.java

  **/
 package cc.plural.jsonij.marshal;
 
+import cc.plural.jsonij.Value;
 import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import cc.plural.jsonij.Value;
-
 /**
  *
  * @author openecho

src/main/java/cc/plural/jsonij/marshal/JSONDocumentMarshaler.java

  */