Package com.thoughtworks.xstream.io.xml

Examples of com.thoughtworks.xstream.io.xml.DomReader


    public boolean canConvert(Class clazz) {
        return Document.class.isAssignableFrom(clazz) || Element.class.isAssignableFrom(clazz);
    }

    public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext marshallingContext) {
        DomReader reader;
        if (object instanceof Document) {
            Document doc = (Document) object;
            reader = new DomReader(doc);
        } else {
            Element element = (Element) object;
            reader = new DomReader(element);
        }

        copy(reader, writer);
    }
View Full Code Here


            // Set the thread context classloader so deserializing classes can grab the cl from the thread
            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(classLoader);

                DomReader reader = new DomReader(element);
                XStream xstream = XStreamUtil.createXStream();
                xstream.setClassLoader(classLoader);
                Object o = xstream.unmarshal(reader);
                GBeanData[] gbeanDatas = (GBeanData[]) o;
                return Arrays.asList(gbeanDatas);
View Full Code Here

            // Set the thread context classloader so deserializing classes can grab the cl from the thread
            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(classLoader);

                DomReader reader = new DomReader(element);
                XStream xstream = XStreamUtil.createXStream();
                xstream.setClassLoader(classLoader);
                Object o = xstream.unmarshal(reader);
                GBeanData[] gbeanDatas = (GBeanData[]) o;
                return Arrays.asList(gbeanDatas);
View Full Code Here

*/
public class Node2XObject extends BaseTransformer<Node, XObject> implements PullTransformer<Node, XObject> {

    public XObject transform(Node source, TransformationContext context) {
        try {
            DomReader in = null;
            if (source instanceof Document) {
                in = new DomReader((Document)source);
            } else if (source instanceof Element) {
                in = new DomReader((Element)source);
            }
            XStream xs = new XStream();
            return (XObject)xs.unmarshal(in);
        } catch (Exception e) {
            throw new TransformationException(e);
View Full Code Here

            // Set the thread context classloader so deserializing classes can grab the cl from the thread
            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            try {
//                Thread.currentThread().setContextClassLoader(bundle);

                DomReader reader = new DomReader(element);
                XStream xstream = XStreamUtil.createXStream();
                //TODO Obviously, totally broken
//                xstream.setClassLoader(bundle);
                Object o = xstream.unmarshal(reader);
                GBeanData[] gbeanDatas = (GBeanData[]) o;
View Full Code Here

            // Set the thread context classloader so deserializing classes can grab the cl from the thread
            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(classLoader);

                DomReader reader = new DomReader(element);
                XStream xstream = XStreamUtil.createXStream();
                xstream.setClassLoader(classLoader);
                Object o = xstream.unmarshal(reader);
                GBeanData[] gbeanDatas = (GBeanData[]) o;
                return Arrays.asList(gbeanDatas);
View Full Code Here

  protected Object fromXmlToObject(String xml, Object root ) throws ActionProcessingException
  {
    HierarchicalStreamReader reader = null;
    try
    {
      reader = new DomReader( getRootElement( xml, rootNodeName ) );
       
          XStream xstream = new XStream( new DomDriver() );
          xstream.alias(getAlias(incomingType), incomingType);
          addAliases( aliases, xstream );
            XStreamConfigurator.addFieldAliases(fieldAliases, xstream);
View Full Code Here

                catch (TransformerException e) {
                    throw new MessagingException("Failed to transform content: " + content + " to DOMResult: " + e, e);
                }
                document = (Document) result.getNode();
            }
            return getXStream().unmarshal(new DomReader(document));
        }
        return super.unmarshal(exchange, message);
    }
View Full Code Here

        NodeList children = rootElement.getChildNodes();
        Node child;
        for (int i = 0; i < children.getLength(); i++) {
            child = children.item(i);
            if (child.getNodeType() == Document.ELEMENT_NODE) {
                return (new XStream(xsdriver)).unmarshal(new DomReader((Element) child));
            }
        }
        return null;
    }
View Full Code Here

     * {@inheritDoc}
     *
     * @see XMLComponentInstanceFactory#makeInstance(org.picocontainer.PicoContainer,org.w3c.dom.Element,ClassLoader)
     */
    public Object makeInstance(PicoContainer pico, Element element, ClassLoader classLoader) throws ClassNotFoundException {
        return xstream.unmarshal(new DomReader(element));
    }
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.io.xml.DomReader

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.