Package org.apache.tuscany.sca.databinding

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


    public XMLStreamReader transform(Object source, TransformationContext context) {
        try {
            JSONObject json = JSONHelper.toJettison(source);
            return new BadgerFishXMLStreamReader(json);
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here


            StreamResult result = new StreamResult(writer);
            JAXBElement<?> jaxbElement = JAXBContextHelper.createJAXBElement(tContext.getSourceDataType(), source);
            marshaller.marshal(jaxbElement, result);
            return writer.toString();
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

            if (context != null && context.getTargetDataType() != null) {
                type = context.getTargetDataType().getPhysical();
            }
            return JSONHelper.toJSON(source, type);
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

        super();
        serializer = new JSONSerializer();
        try {
            serializer.registerDefaultSerializers();
        } catch (Exception e) {
            throw new TransformationException(e);
        }
        serializer.setMarshallClassHints(true);
        serializer.setMarshallNullAttributes(true);
    }
View Full Code Here

        try {
            SerializerState state = new SerializerState();
            return serializer.unmarshall(state, context.getTargetDataType().getPhysical(), source);
        } catch (Exception e) {
            throw new TransformationException(e);
        }

    }
View Full Code Here

    private JAXBContextHelper() {
    }

    public static JAXBContext createJAXBContext(TransformationContext tContext, boolean source) throws JAXBException {
        if (tContext == null)
            throw new TransformationException("JAXB context is not set for the transformation.");

        DataType<?> dataType = source ? tContext.getSourceDataType() : tContext.getTargetDataType();
        // FIXME: We should check the context path or classes
        // FIXME: What should we do if JAXB is an intermediate node?

        // String contextPath = null;
        JAXBContext context = null;
        Class<?> cls = getJavaType(dataType);

        context = JAXBContext.newInstance(cls);

        if (context == null) {
            throw new TransformationException("JAXB context is not set for the transformation.");
        }
        return context;
    }
View Full Code Here

    public Object transform(Object source, TransformationContext context) {
        try {
            return toJSON(source);
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

            if (context != null && context.getTargetDataType() != null) {
                type = context.getTargetDataType().getPhysical();
            }
            return JSONHelper.toJSON(writer.toString(), type);
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

        if (dataBindingId != null) {
            DataBinding dataBinding = mediator.getDataBindings().getDataBinding(dataBindingId);
            wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler();
        }
        if (wrapperHandler == null && required) {
            throw new TransformationException("No wrapper handler is provided for databinding: " + dataBindingId);
        }
        return wrapperHandler;
    }
View Full Code Here

                // FIXME: Do we want to handle wrapped to wrapped?
                return mediator.mediate(response, sourceType.getLogical(), targetType.getLogical(), context
                    .getMetadata());
            }
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

TOP

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

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.