Package org.apache.tuscany.sca.databinding

Examples of org.apache.tuscany.sca.databinding.TransformationContext


        Object result = source;
        int size = path.size();
        int i = 0;
        while (i < size) {
            Transformer transformer = path.get(i);
            TransformationContext context =
                createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata);
            // the source and target type
            if (transformer instanceof PullTransformer) {
                // For intermediate node, set data type to null
                result = ((PullTransformer)transformer).transform(result, context);
View Full Code Here


        if (metadata != null) {
            copy.putAll(metadata);
        }
        copy.put(ExtensionPointRegistry.class.getName(), registry);

        TransformationContext context = new TransformationContextImpl(sourceType, targetType, copy);
        return context;
    }
View Full Code Here

        List<Transformer> path = getTransformerChain(sourceDataType, targetDataType);
        Object result = source;
        int size = path.size();
        for (int i = 0; i < size; i++) {
            Transformer transformer = path.get(i);
            TransformationContext context =
                createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata);

            if (transformer instanceof PullTransformer) {
                result = ((PullTransformer)transformer).transform(result, context);
            } else if (transformer instanceof PushTransformer) {
View Full Code Here

    public void testTransform() throws Exception {
        Reader2JAXB t0 = new Reader2JAXB();

        DataType targetDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        expect(tContext.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext);

        Object object1 = t0.transform(new StringReader(IPO_XML), tContext);

        DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
        expect(tContext1.getSourceOperation()).andReturn(null).anyTimes();
        expect(tContext1.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        Node node = t1.transform(object1, tContext1);
View Full Code Here

        QName root = new QName("http://www.example.com/IPO", "purchaseOrder");
        DataType targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
        // targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        expect(tContext.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext);

        Object object1 = t0.transform(new StringReader(IPO_XML), tContext);

        DataType sourceDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
        // sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
        expect(tContext1.getSourceOperation()).andReturn(null).anyTimes();
        expect(tContext1.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        Node node = t1.transform(object1, tContext1);
View Full Code Here

    public void testTransform3() throws Exception {

        DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
        expect(tContext1.getSourceOperation()).andReturn(null).anyTimes();
        expect(tContext1.getTargetOperation()).andReturn(null).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        PurchaseOrderType po = new ObjectFactory().createPurchaseOrderType();
        Node node = t1.transform(po, tContext1);
View Full Code Here

        service.setId("ID001");
        bean.setService(service);
        bean.setOtherService(service);
        QName name = new QName("http://ns1", "bean");
        JAXBElement<Object> element = new JAXBElement<Object>(name, Object.class, bean);
        TransformationContext tContext = new TransformationContextImpl();
        XMLStreamReader reader = new JAXB2XMLStreamReader().transform(element, tContext);

//        XMLStreamReader2String t2 = new XMLStreamReader2String();
//        String xml = t2.transform(reader, null);
        // System.out.println(xml);
View Full Code Here

        super.setUp();
    }

    public void testMap() throws Exception {
        SimpleTypeMapperImpl extension = new SimpleTypeMapperImpl();
        TransformationContext context = EasyMock.createMock(TransformationContext.class);
        Map<String, Object> metaData = new HashMap<String, Object>();
        EasyMock.expect(context.getMetadata()).andReturn(metaData).anyTimes();
        EasyMock.replay(context);

        NamespaceContext namespaceContext = EasyMock.createMock(NamespaceContext.class);
        EasyMock.expect(namespaceContext.getNamespaceURI(EasyMock.eq("f"))).andReturn("http://foo").anyTimes();
        EasyMock.expect(namespaceContext.getPrefix(EasyMock.eq("http://foo"))).andReturn("f").anyTimes();
        EasyMock.replay(namespaceContext);
        context.getMetadata().put(NamespaceContext.class.getName(), namespaceContext);
        for (TypeInfo simpleType : SimpleTypeMapperImpl.XSD_SIMPLE_TYPES.values()) {
            String name = simpleType.getQName().getLocalPart();
            Object value = SAMPLE_VALUES.get(name);
            if (value instanceof String[]) {
                for (String s : (String[])value) {
View Full Code Here

        Object result = source;
        int size = path.size();
        int i = 0;
        while (i < size) {
            Transformer transformer = path.get(i);
            TransformationContext context =
                createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata);
            // the source and target type
            if (transformer instanceof PullTransformer) {
                // For intermediate node, set data type to null
                result = ((PullTransformer)transformer).transform(result, context);
View Full Code Here

        if (metadata != null) {
            copy.putAll(metadata);
        }
        copy.put(ExtensionPointRegistry.class.getName(), registry);

        TransformationContext context = new TransformationContextImpl(sourceType, targetType, classLoader, copy);
        return context;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.databinding.TransformationContext

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.