Package cc.plural.jsonij.reflect

Examples of cc.plural.jsonij.reflect.ReflectType


    }

    public Object marshalJSONDocument(Value value, Class<?> objectClass) throws JSONMarshalerException {
        Object resultObject = null;

        ReflectType type = ReflectType.inspectObjectType(objectClass);
        switch (type) {
            case OBJECT:
                if (value.type() == Value.TYPE.OBJECT) {
                    JSON.Object<CharSequence, Value> jsonObjectRoot = (JSON.Object<CharSequence, Value>) value;
                    resultObject = marshalJSONDocumentObject(jsonObjectRoot, objectClass);
View Full Code Here


            } catch (IllegalAccessException ex) {
                Logger.getLogger(JSONDocumentMarshaler.class.getName()).log(Level.SEVERE, null, ex);
                throw new JSONMarshalerException("illegalAccess");
            }

            ReflectType type = ReflectType.inspectObjectType(objectClass);
            Inspection inspection = ReflectType.getInspection(objectClass);

            boolean hasCollector = inspection.hasCollectors();
            Map<CharSequence, Value> collector = null;
            Map<CharSequence, Value> innerObjectCollector = null;
View Full Code Here

        return object;
    }

    public Object marshalJSONDocumentArray(JSON.Array<Value> jsonArray, Class<?> objectClass) throws JSONMarshalerException {
        int size = jsonArray.size();
        ReflectType type = ReflectType.inspectObjectType(objectClass);
        if (type == ReflectType.OBJECT) {
            return marshalJSONDocumentList(jsonArray, objectClass);
        } else {
            Class<?> componentClass = objectClass.getComponentType();
            ReflectType componentType = ReflectType.inspectObjectType(componentClass);
            Object array = Array.newInstance(componentClass, size);
            for (int i = 0; i < size; i++) {
                Value value = jsonArray.get(i);
                if (value.getValueType() == Value.TYPE.OBJECT) {
                    Array.set(array, i, marshalJSONDocumentObject((JSON.Object<CharSequence, Value>) value, componentClass));
View Full Code Here

        return null;
    }

    private void marshalJSONValue(Value value, Object object, ClassProperty inspectorProperty) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, JSONMarshalerException {
        ClassProperty.ClassPropertyMutator mutator = inspectorProperty.getMutator();
        ReflectType type = ReflectType.inspectObjectType(mutator.getType());
        switch (type) {
            case BOOLEAN:
                mutator.fire(object, value.getBoolean());
                return;
            case BYTE:
View Full Code Here

            } catch (InvocationTargetException ex) {
                Logger.getLogger(JavaMarshaler.class.getName()).log(Level.SEVERE, null, ex);
            }
            return value;
        }
        ReflectType objectType = ReflectType.inspectObjectType(objectClass);
        switch (objectType) {
            case BOOLEAN:
                marshaledObject = marshalJavaBoolean(o);
                break;
            case BYTE:
View Full Code Here

     */
    @Test
    public void testSetPrimitive() {
        System.out.println("setPrimitive");
        boolean primitive = false;
        ReflectType instance = ReflectType.INTEGER;
        instance.setPrimitive(primitive);
        assertEquals(instance.isPrimitive(), primitive);
    }
View Full Code Here

     */
    @Test
    public void testIsPrimitive() {
        System.out.println("isPrimitive");
        boolean primitive = true;
        ReflectType instance = ReflectType.INTEGER;
        instance.setPrimitive(primitive);
        assertEquals(instance.isPrimitive(), primitive);
    }
View Full Code Here

     */
    @Test
    public void inspectObjectType_boolean() {
        System.out.println("inspectObjectType_boolean");
        Class<?> c = null;
        ReflectType expResult = null;

        c = boolean.class;
        expResult = ReflectType.BOOLEAN;

        ReflectType result = ReflectType.inspectObjectType(c);
        System.out.println(String.format("Found Class: \"%s\"", c));
        assertEquals(expResult, result);

        boolean expResultPrimitive = true;
        boolean resultPrimitive = result.isPrimitive();
        assertEquals(expResultPrimitive, resultPrimitive);
    }
View Full Code Here

     */
    @Test
    public void testInspectObjectType_Boolean() {
        System.out.println("inspectObjectType_Boolean");
        Class<?> c = null;
        ReflectType expResult = null;

        c = Boolean.class;
        expResult = ReflectType.BOOLEAN;

        System.out.println(String.format("Found Class: \"%s\"", c));
        ReflectType result = ReflectType.inspectObjectType(c);
        assertEquals(expResult, result);

        boolean expResultPrimitive = false;
        boolean resultPrimitive = result.isPrimitive();
        assertEquals(expResultPrimitive, resultPrimitive);
    }
View Full Code Here

     */
    @Test
    public void inspectObjectType_byte() {
        System.out.println("inspectObjectType_byte");
        Class<?> c = null;
        ReflectType expResult = null;

        c = byte.class;
        expResult = ReflectType.BYTE;

        ReflectType result = ReflectType.inspectObjectType(c);
        System.out.println(String.format("Found Class: \"%s\"", c));
        assertEquals(expResult, result);

        boolean expResultPrimitive = true;
        boolean resultPrimitive = result.isPrimitive();
        assertEquals(expResultPrimitive, resultPrimitive);
    }
View Full Code Here

TOP

Related Classes of cc.plural.jsonij.reflect.ReflectType

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