private Object unmarshal(Object o, boolean nullOut) throws IOException { try (InputStream in = new BufferedInputStream(Files.newInputStream(file.toPath()))) { // TODO: expose XStream the driver from XStream if (nullOut) { return ((XStream2) xs).unmarshal(DEFAULT_DRIVER.createReader(in), o, null, true); } else { return xs.unmarshal(DEFAULT_DRIVER.createReader(in), o); } } catch (RuntimeException | Error e) { throw new IOException("Unable to read "+file,e); } }
public Object unmarshalInputStream(InputStream inputStream, @Nullable DataHolder dataHolder) throws XmlMappingException, IOException { if (this.streamDriver != null) { return doUnmarshal(this.streamDriver.createReader(inputStream), dataHolder); } else { return unmarshalReader(new InputStreamReader(inputStream, this.encoding), dataHolder); } }
public Object unmarshalReader(Reader reader, @Nullable DataHolder dataHolder) throws XmlMappingException, IOException { return doUnmarshal(getDefaultDriver().createReader(reader), dataHolder); }
/** * Deserialize an object from an XML InputStream. * * @throws XStreamException if the object cannot be deserialized */ public Object fromXML(InputStream input) { return unmarshal(hierarchicalStreamDriver.createReader(input), null); }
/** * Deserialize an object from an XML InputStream, populating the fields of the given root * object instead of instantiating a new one. Note, that this is a special use case! With * the ReflectionConverter XStream will write directly into the raw memory area of the * existing object. Use with care! * * @throws XStreamException if the object cannot be deserialized */ public Object fromXML(InputStream input, Object root) { return unmarshal(hierarchicalStreamDriver.createReader(input), root); }
/** * Creates an ObjectInputStream that deserializes a stream of objects from a reader using * XStream. * * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader) * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, * String) * @since 1.0.3 */ public ObjectInputStream createObjectInputStream(Reader xmlReader) throws IOException { return createObjectInputStream(hierarchicalStreamDriver.createReader(xmlReader)); }
/** * Deserialize an object from an XML Reader, populating the fields of the given root object * instead of instantiating a new one. Note, that this is a special use case! With the * ReflectionConverter XStream will write directly into the raw memory area of the existing * object. Use with care! * * @throws XStreamException if the object cannot be deserialized */ public Object fromXML(Reader xml, Object root) { return unmarshal(hierarchicalStreamDriver.createReader(xml), root); }
/** * Creates an ObjectInputStream that deserializes a stream of objects from an InputStream * using XStream. * * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader) * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, * String) * @since 1.3 */ public ObjectInputStream createObjectInputStream(InputStream in) throws IOException { return createObjectInputStream(hierarchicalStreamDriver.createReader(in)); }
/** * Deserialize an object from an XML Reader. * * @throws XStreamException if the object cannot be deserialized */ public Object fromXML(Reader reader) { return unmarshal(hierarchicalStreamDriver.createReader(reader), null); }
public static XStreamDOM from(InputStream in) { return from(XStream2.getDefaultDriver().createReader(in)); }
public static XStreamDOM from(Reader in) { return from(XStream2.getDefaultDriver().createReader(in)); }
/** * Deserialize an object from a URL, populating the fields of the given root * object instead of instantiating a new one. Note, that this is a special use case! With * the ReflectionConverter XStream will write directly into the raw memory area of the * existing object. Use with care! * * Depending on the parser implementation, some might take the file path as SystemId to * resolve additional references. * * @throws XStreamException if the object cannot be deserialized * @since 1.4 */ public Object fromXML(URL url, Object root) { return unmarshal(hierarchicalStreamDriver.createReader(url), root); }
Object o = Jenkins.XSTREAM2.unmarshal(XStream2.getDefaultDriver().createReader(in), this, null, true); if (!o.getClass().equals(getClass())) {
/** * Deserialize an object from a file, populating the fields of the given root * object instead of instantiating a new one. Note, that this is a special use case! With * the ReflectionConverter XStream will write directly into the raw memory area of the * existing object. Use with care! * * Depending on the parser implementation, some might take the file path as SystemId to * resolve additional references. * * @throws XStreamException if the object cannot be deserialized * @since 1.4 */ public Object fromXML(File file, Object root) { HierarchicalStreamReader reader = hierarchicalStreamDriver.createReader(file); try { return unmarshal(reader, root); } finally { reader.close(); } }
outer.addPermission(permissions[i]); final HierarchicalStreamReader reader = driver.createReader(xml); final ObjectInputStream configIn = outer.createObjectInputStream(reader); try {
/** * Creates an ObjectInputStream that deserializes a stream of objects from an InputStream using XStream. * * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader) * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String) * @since 1.3 */ public ObjectInputStream createObjectInputStream(final InputStream in) throws IOException { return createObjectInputStream(hierarchicalStreamDriver.createReader(in)); }
/** * Deserialize an object from an XML Reader. * * @throws XStreamException if the object cannot be deserialized */ public <T> T fromXML(final Reader reader) { return unmarshal(hierarchicalStreamDriver.createReader(reader), null); }
/** * Deserialize an object from an XML InputStream. * * @throws XStreamException if the object cannot be deserialized */ public <T> T fromXML(final InputStream input) { return unmarshal(hierarchicalStreamDriver.createReader(input), null); }
/** * Parse an element with a big text as value. * * @since 1.4.9 */ @Benchmark public void parseBigText() { final Object o = xstream.unmarshal(driver.createReader(new ByteArrayInputStream(data))); dataFactory.checkData(o); }
/** * Parse an element with a lot of simple children. * * @since 1.4.9 */ @Benchmark public void parseManyChildren() { final Object o = xstream.unmarshal(driver.createReader(new ByteArrayInputStream(data))); dataFactory.checkData(o); } }