Commits

John Marsden committed 7882549

Blah

  • Participants
  • Parent commits 0205c7b

Comments (0)

Files changed (2)

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

 import cc.plural.jsonij.JSON;
 import cc.plural.jsonij.Value;
 import cc.plural.jsonij.parser.ParserException;
+import cc.plural.jsonij.reflect.ClassProperty;
+import cc.plural.jsonij.reflect.Inspection;
 import cc.plural.jsonij.reflect.ReflectType;
 
 /**
     public Object marshalJSONDocumentObject(JSON.Object<CharSequence, Value> jsonObject, Class<?> objectClass) throws JSONMarshalerException {
         Object object = null;
 
-        Inspector inspector = new Inspector(objectClass);
-        inspector.inspect();
+        //Inspector inspector = new Inspector(objectClass);
+        //inspector.inspect();
 
-        boolean hasCollector = inspector.hasCollector();
+        Inspection inspection = ReflectType.getInspection(objectClass);
+        
+        /*
+        boolean hasCollector = null;
         try {
             object = objectClass.newInstance();
         } catch(InstantiationException ex) {
         if(hasCollector) {
             collector = new HashMap<CharSequence, Value>();
         }
-        if(inspector.hasInnerObject()) {
+        if(inspection.hasInnerMap()) {
             innerObjectCollector = new HashMap<CharSequence, Value>();
         }
         for(Entry<CharSequence, Value> documentPropertyEntry : jsonObject.entrySet()) {
             CharSequence key = documentPropertyEntry.getKey();
-            if(inspector.hasProperty(key.toString())) {
-                InspectorProperty inspectorProperty = inspector.getProperty(key.toString());
+            if(inspection.hasProperty(key.toString())) {
+                ClassProperty inspectorProperty = inspection.getProperty(key.toString());
                 Value documentValue = documentPropertyEntry.getValue();
                 try {
                     marshalDocumentToObject(objectClass, object, documentValue, inspectorProperty);
             } else if(hasCollector) {
                 collector.put(key, documentPropertyEntry.getValue());
             }
-            if(inspector.hasInnerObject()) {
+            if(inspection.hasInnerMap()) {
                 innerObjectCollector.put(key, documentPropertyEntry.getValue());
             }
         }
         
         if(inspector.hasInnerArray()) {
         }
-
+        */
         return object;
     }
 
         }
         return array;
     }
-
+/*
     public Map<?, ?> marshalJSONDocumentMap(InspectorProperty property, Value propertyValue) throws JSONMarshalerException {
         
         Class<?> mapType = property.getMutateInputType();
         return null;
     }
 
-    private void marshalDocumentToObject(Class<?> objectClass, Object object, Value propertyValue, InspectorProperty property) throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException, JSONMarshalerException, InvocationTargetException, NoSuchFieldException {
+    private void marshalDocumentToObject(Class<?> objectClass, Object object, Value propertyValue, ClassProperty property) throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException, JSONMarshalerException, InvocationTargetException, NoSuchFieldException {
         ReflectType mutateType = ReflectType.inspectObjectType(property.getMutateInputType());
         if(property.getAccessPropertyType() == InspectorProperty.TYPE.METHOD) {
             Method method = objectClass.getMethod(property.getMutateName(), property.getMutateInputType());
         }
     }
     
+    
     public static class MarshalerPropertyValue {
 
         String name;
             return resultBuilder.toString();
         }
     }
+    */
 }

File src/main/java/cc/plural/jsonij/reflect/Inspection.java

  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-
 package cc.plural.jsonij.reflect;
 
 import java.util.List;
 public class Inspection {
 
     private Class<?> klass;
-    private List<ClassProperty> properties; 
+
+    private List<ClassProperty> properties;
+
     private boolean innerList;
+
     private boolean innerMap;
-   
+
     public Inspection() {
-        
     }
 
     public boolean hasInnerList() {
         return innerList;
     }
-    
+
     public boolean isInnerList() {
         return innerList;
     }
     public void setInnerList(boolean innerList) {
         this.innerList = innerList;
     }
-    
+
     public boolean hasInnerMap() {
         return innerMap;
     }
 
     @Override
     public String toString() {
-        return "Inspection [" + klass  + " List:" + innerList + " Map:" + innerMap + " Properties:" + properties.size() + "]";
+        return "Inspection [" + klass + " List:" + innerList + " Map:" + innerMap + " Properties:" + properties.size() + "]";
+    }
+
+    public boolean hasProperty(String name) {
+        for(ClassProperty property : properties) {
+            if(property.getPropertyName().equals(name)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public ClassProperty getProperty(String name) {
+        for(ClassProperty property : properties) {
+            if(property.getPropertyName().equals(name)) {
+                return property;
+            }
+        }
+        return null;
     }
 }