Examples of DataTypeImpl


Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

    }

    public void testJSON2OMElement() throws Exception {
        JSON2OMElement t1 = new JSON2OMElement();
        TransformationContext context = new TransformationContextImpl();
        DataType dt = new DataTypeImpl(Object.class, new XMLType(new QName("http://foo.com", "root"), null));
        context.setTargetDataType(dt);
        OMElement element = t1.transform(new JSONObject(JSON_STR), context);
        StringWriter writer = new StringWriter();
        element.serialize(writer);
        // System.out.println(writer.toString());
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

        Class physical = dataType.getPhysical();
        if (!physical.isArray() || physical == byte[].class) {
            return false;
        }
        Class componentType = physical.getComponentType();
        DataType logical = new DataTypeImpl(componentType, dataType.getLogical());
        introspectType(logical, operation);
        dataType.setDataBinding("java:array");
        dataType.setLogical(logical);
        return true;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

    }

    public void testJSON2OMElement() throws Exception {
        JSON2OMElement t1 = new JSON2OMElement();
        TransformationContext context = new TransformationContextImpl();
        DataType dt = new DataTypeImpl(Object.class, new XMLType(new QName("http://foo.com", "root"), null));
        context.setTargetDataType(dt);
        OMElement element = t1.transform(new JSONObject(JSON_STR), context);
        StringWriter writer = new StringWriter();
        element.serialize(writer);
        // System.out.println(writer.toString());
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

        Class<?> physical = dataType.getPhysical();
        if (!physical.isArray() || physical == byte[].class) {
            return false;
        }
        Class<?> componentType = physical.getComponentType();
        DataType logical = new DataTypeImpl(componentType, dataType.getLogical());
        introspectType(logical, operation);
        dataType.setDataBinding("java:array");
        dataType.setLogical(logical);
        return true;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

    private DataType domType;
   
    public DOMElementXmlAdapter(Mediator mediator, DataType dataType) {
        this.mediator = mediator;
        this.dataType = dataType;
        this.domType = new DataTypeImpl(DOMDataBinding.NAME, Element.class, dataType.getLogical());
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

        Class physical = dataType.getPhysical();
        if (!physical.isArray() || physical == byte[].class) {
            return false;
        }
        Class componentType = physical.getComponentType();
        DataType logical = new DataTypeImpl(componentType, dataType.getLogical());
        introspectType(logical, operation);
        dataType.setDataBinding("java:array");
        dataType.setLogical(logical);
        return true;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

                Class<?> propType = javaClass.getComponentType();
                Type genericPropType = propType;
                if (genericType instanceof GenericArrayType) {
                    genericPropType = ((GenericArrayType)genericType).getGenericComponentType();
                }
                DataType dt = new DataTypeImpl(null, propType, genericPropType, XMLType.UNKNOWN);
                property.setDataType(dt);
            } else {
                if (genericType instanceof ParameterizedType) {
                    // Collection<BaseType> property;
                    Type genericPropType = ((ParameterizedType)genericType).getActualTypeArguments()[0];
                    Class<?> propType = JavaIntrospectionHelper.getErasure(genericPropType);
                    DataType dt = new DataTypeImpl(null, propType, genericPropType, XMLType.UNKNOWN);
                    property.setDataType(dt);
                } else {
                    // Collection property;
                    DataType dt = new DataTypeImpl(null, Object.class, Object.class, XMLType.UNKNOWN);
                    property.setDataType(dt);
                }
            }
        } else {
            DataType dt = new DataTypeImpl(null, javaClass, genericType, XMLType.UNKNOWN);
            property.setDataType(dt);
        }
        return property;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

        Class<?> componentType = physical.getComponentType();
        Type genericComponentType = componentType;
        if(dataType.getGenericType() instanceof GenericArrayType) {
            genericComponentType = ((GenericArrayType) dataType.getGenericType()).getGenericComponentType();
        }
        DataType logical = new DataTypeImpl(dataType.getDataBinding(), componentType, genericComponentType, dataType.getLogical());
        introspectType(logical, operation);
        dataType.setDataBinding("java:array");
        dataType.setLogical(logical);
        return true;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

        JavaBean2JSON t1 = new JavaBean2JSON();
        Object result = t1.transform(me, null);
        System.out.println(result);
        JSON2JavaBean t2 = new JSON2JavaBean();
        TransformationContext context = new TransformationContextImpl();
        context.setTargetDataType(new DataTypeImpl(MyBean.class, null));
        Object v = t2.transform(new JSONObject(result.toString()), context);
        Assert.assertTrue(v instanceof MyBean);
        //        String json =
        //            "{\"age\":30,\"books\":[],\"friends\":[\"John\",\"Mike\"],\"name\":\"Me\",\"vip\":true,\"you\":{\"id\":123,\"name\":null}}";
        //        Assert.assertEquals(json, result.toString());
View Full Code Here

Examples of org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl

        JavaBean2JSONObject t1 = new JavaBean2JSONObject();
        Object result = t1.transform("ABC", null);
        System.out.println(result);
        JSON2JavaBean t2 = new JSON2JavaBean();
        TransformationContext context = new TransformationContextImpl();
        context.setTargetDataType(new DataTypeImpl(String.class, null));
        Object v = t2.transform(result, context);
        Assert.assertTrue(v instanceof String);
        Assert.assertEquals("ABC", v);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.