Package org.apache.tuscany.spi.databinding

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


    public XmlObject transform(XMLStreamReader source, TransformationContext context) {
        try {
            return XmlObject.Factory.parse(source);
        } catch (XmlException e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here


            StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(source.getBytes()));
            OMElement element = builder.getDocumentElement();
            adjustElementName(context, element);
            return element;
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

    public XmlObject transform(Node source, TransformationContext context) {
        try {
            return XmlObject.Factory.parse(source);
        } catch (XmlException e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

            StAXOMBuilder builder = new StAXOMBuilder(source);
            OMElement element = builder.getDocumentElement();
            adjustElementName(context, element);
            return element;
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

        try {
            StringWriter writer = new StringWriter();
            source.serialize(writer);
            return writer.toString();
        } catch (XMLStreamException e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

            if (method != null) {
                Class typeClass = method.getParameterTypes()[0];
                Object value = typeClass.newInstance();
                return (JAXBElement<?>) method.invoke(factory, new Object[] { value });
            } else {
                throw new TransformationException("ObjectFactory cannot be resolved.");
            }
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

                    return d.getReadMethod().invoke(value, new Object[] {});
                }
            }
            return null;
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

                    d.getWriteMethod().invoke(wrapperValue, new Object[] { value });
                    break;
                }
            }
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

        try {
            JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
            return unmarshaller.unmarshal(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.");

        // FIXME: We should check the context path or classes
        // FIXME: What should we do if JAXB is an intermediate node?
        DataType<?> bindingContext = source ? tContext.getSourceDataType() : tContext.getTargetDataType();
        String contextPath = (String) bindingContext.getMetadata(JAXB_CONTEXT_PATH);
        JAXBContext context = null;
        if (contextPath != null)
            context = JAXBContext.newInstance(contextPath);
        else {
            Class[] classes = (Class[]) bindingContext.getMetadata(JAXB_CLASSES);
            context = JAXBContext.newInstance(classes);
        }
        if (context == null)
            throw new TransformationException("JAXB context is not set for the transformation.");
        return context;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.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.