Examples of DataTypeImpl


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

            dataBinding = targetDataType.getDataBinding();
            source = convert(entityStream, mediaType.toString(), type);
            return (T) source;
        }
        DataType sourceDataType =
            new DataTypeImpl(dataBinding, InputStream.class, InputStream.class, InputStream.class);

        Object result = mediator.mediate(source, sourceDataType, targetDataType, Collections.<String, Object>emptyMap());
        return (T)result;
    }
View Full Code Here

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

            dataBinding = dataType.getDataBinding();
            write(entityStream, t, type);
            return;
        }
        DataType targetDataType =
            new DataTypeImpl(dataBinding, OutputStream.class, OutputStream.class, OutputStream.class);
        // dataBindingExtensionPoint.introspectType(targetDataType, null);

        introspectAnnotations(annotations, targetDataType);

        mediator.mediate(t, entityStream, dataType, targetDataType, Collections.<String, Object> emptyMap());
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

            targetDataType.setLogical(new XMLType(name, null));
        }
    }

    protected DataType createDataType(Class<?> type, Type genericType) {
        DataType dataType = new DataTypeImpl(null, type, genericType, genericType);
        dataBindingExtensionPoint.introspectType(dataType, null);
        return dataType;
    }
View Full Code Here

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

    @Test
    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

        Object json = t1.transform(bean, null);
        System.out.println(json);
        JSON2Object t2 = new JSON2Object();

        TransformationContext context = new TransformationContextImpl();
        context.setTargetDataType(new DataTypeImpl(bean == null ? Object.class : bean.getClass(), null));
        Object newBean = t2.transform(json, context);

        if (newBean != null && newBean.getClass().isArray()) {
            int len = Array.getLength(newBean);
            Assert.assertEquals(Array.getLength(bean), len);
View Full Code Here

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

        Object2JSON t1 = new Object2JSON();
        Object result = t1.transform(me, null);
        System.out.println(result);
        JSON2Object t2 = new JSON2Object();
        TransformationContext context = new TransformationContextImpl();
        context.setTargetDataType(new DataTypeImpl(MyBean.class, null));
        Object v = t2.transform(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

        Object2JSON t1 = new Object2JSON();
        Object result = t1.transform("ABC", null);
        System.out.println(result);
        JSON2Object t2 = new JSON2Object();
        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

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

        Object2JSON t1 = new Object2JSON();
        Object result = t1.transform(new String[] {"ABC", "DF"}, null);
        System.out.println(result);
        JSON2Object t2 = new JSON2Object();
        TransformationContext context = new TransformationContextImpl();
        context.setTargetDataType(new DataTypeImpl(String[].class, null));
        Object v = t2.transform(result, context);
        Assert.assertTrue(v instanceof String[]);
        String[] strs = (String[])v;
        Assert.assertEquals("ABC", strs[0]);
        Assert.assertEquals("DF", strs[1]);
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
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.