@Override protected Object unmarshalDomNode(Node node) throws XmlMappingException { HierarchicalStreamReader streamReader; if (node instanceof Document) { streamReader = new DomReader((Document) node, this.nameCoder); } else if (node instanceof Element) { streamReader = new DomReader((Element) node, this.nameCoder); } else { throw new IllegalArgumentException("DOMSource contains neither Document nor Element"); } return doUnmarshal(streamReader, null); }
private HierarchicalStreamReader createReader(InputSource source) { try { if (documentBuilderFactory == null) { synchronized (this) { if (documentBuilderFactory == null) { documentBuilderFactory = createDocumentBuilderFactory(); } } } final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (encoding != null) { source.setEncoding(encoding); } Document document = documentBuilder.parse(source); return new DomReader(document, getNameCoder()); } catch (FactoryConfigurationError e) { throw new StreamException(e); } catch (ParserConfigurationException e) { throw new StreamException(e); } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
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); }
protected Object unmarshalDomNode(Node node) throws XmlMappingException { HierarchicalStreamReader streamReader; if (node instanceof Document) { streamReader = new DomReader((Document) node); } else if (node instanceof Element) { streamReader = new DomReader((Element) node); } else { throw new IllegalArgumentException("DOMSource contains neither Document nor Element"); } return unmarshal(streamReader); }
public Object makeInstance(PicoContainer pico, Element element, ClassLoader classLoader) { return xstream.unmarshal(new DomReader(element)); } }
public Object makeInstance(final PicoContainer pico, final Element element, final ClassLoader classLoader) { return xstream.unmarshal(new DomReader(element)); } }
/** * parse element child with xstream and provide object * * @return * @param rootElement */ protected Object parseElementChild(final Element rootElement) { NodeList children = rootElement.getChildNodes(); Node child; for (int i = 0; i < children.getLength(); i++) { child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { return (new XStream(xsdriver)).unmarshal(new DomReader((Element) child)); } } return null; }
/** * parse element child with xstream and provide object * * @return * @param rootElement */ protected Object parseElementChild(Element rootElement) { 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; }
private static List loadGBeans(Element element, ClassLoader classLoader) throws InvalidConfigException { if (element != null) { // 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); } catch (Exception e) { throw new InvalidConfigException("Unable to load gbeans", e); } finally { Thread.currentThread().setContextClassLoader(oldCl); } } return Collections.EMPTY_LIST; }
private HierarchicalStreamReader createReader(InputSource source) { try { DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (encoding != null) { source.setEncoding(encoding); } Document document = documentBuilder.parse(source); return new DomReader(document, getNameCoder()); } catch (FactoryConfigurationError e) { throw new StreamException(e); } catch (ParserConfigurationException e) { throw new StreamException(e); } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
private HierarchicalStreamReader createReader(InputSource source) { try { DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (encoding != null) { source.setEncoding(encoding); } Document document = documentBuilder.parse(source); return new DomReader(document, xmlFriendlyReplacer()); } catch (FactoryConfigurationError e) { throw new StreamException(e); } catch (ParserConfigurationException e) { throw new StreamException(e); } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
private HierarchicalStreamReader createReader(InputSource source) { try { DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (encoding != null) { source.setEncoding(encoding); } Document document = documentBuilder.parse(source); return new DomReader(document, xmlFriendlyReplacer()); } catch (FactoryConfigurationError e) { throw new StreamException(e); } catch (ParserConfigurationException e) { throw new StreamException(e); } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
private HierarchicalStreamReader createReader(InputSource source) { try { DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (encoding != null) { source.setEncoding(encoding); } Document document = documentBuilder.parse(source); return new DomReader(document, getNameCoder()); } catch (FactoryConfigurationError e) { throw new StreamException(e); } catch (ParserConfigurationException e) { throw new StreamException(e); } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
private GeoWebCacheConfiguration loadConfiguration(InputStream xmlFile) throws IOException, ConfigurationException { Node rootNode = loadDocument(xmlFile); XStream xs = getConfiguredXStreamWithContext(new GeoWebCacheXStream(), Context.PERSIST); GeoWebCacheConfiguration config; config = (GeoWebCacheConfiguration) xs.unmarshal(new DomReader((Element) rootNode)); return config; }
private HierarchicalStreamReader createReader(InputSource source) { try { if (documentBuilderFactory == null) { synchronized (this) { if (documentBuilderFactory == null) { documentBuilderFactory = createDocumentBuilderFactory(); } } } final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (encoding != null) { source.setEncoding(encoding); } Document document = documentBuilder.parse(source); return new DomReader(document, getNameCoder()); } catch (FactoryConfigurationError e) { throw new StreamException(e); } catch (ParserConfigurationException e) { throw new StreamException(e); } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
private HierarchicalStreamReader createReader(final InputSource source) { try { if (documentBuilderFactory == null) { synchronized (this) { if (documentBuilderFactory == null) { documentBuilderFactory = createDocumentBuilderFactory(); } } } final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (encoding != null) { source.setEncoding(encoding); } final Document document = documentBuilder.parse(source); return new DomReader(document, getNameCoder()); } catch (final FactoryConfigurationError e) { throw new StreamException(e); } catch (final ParserConfigurationException e) { throw new StreamException(e); } catch (final SAXException e) { throw new StreamException(e); } catch (final IOException e) { throw new StreamException(e); } }
private HierarchicalStreamReader createReader(InputSource source) { try { if (documentBuilderFactory == null) { synchronized (this) { if (documentBuilderFactory == null) { documentBuilderFactory = createDocumentBuilderFactory(); } } } final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (encoding != null) { source.setEncoding(encoding); } Document document = documentBuilder.parse(source); return new DomReader(document, getNameCoder()); } catch (FactoryConfigurationError e) { throw new StreamException(e); } catch (ParserConfigurationException e) { throw new StreamException(e); } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
private HierarchicalStreamReader createReader(InputSource source) { try { if (documentBuilderFactory == null) { synchronized (this) { if (documentBuilderFactory == null) { documentBuilderFactory = createDocumentBuilderFactory(); } } } final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (encoding != null) { source.setEncoding(encoding); } Document document = documentBuilder.parse(source); return new DomReader(document, getNameCoder()); } catch (FactoryConfigurationError e) { throw new StreamException(e); } catch (ParserConfigurationException e) { throw new StreamException(e); } catch (SAXException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
public Object unmarshal(MessageExchange exchange, NormalizedMessage message) throws MessagingException { Source content = message.getContent(); if (content != null) { if (content instanceof StreamSource) { StreamSource source = (StreamSource) content; return getXStream().fromXML(source.getReader()); } Document document = null; if (content instanceof DOMSource) { DOMSource domSource = (DOMSource) content; document = (Document) domSource.getNode(); } else { DOMResult result = new DOMResult(); try { transformer.toResult(content, result); } 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); }