com.thoughtworks.xstream.XStream.unmarshal()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(219)

本文整理了Java中com.thoughtworks.xstream.XStream.unmarshal()方法的一些代码示例,展示了XStream.unmarshal()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.unmarshal()方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:unmarshal

XStream.unmarshal介绍

[英]Deserialize an object from a hierarchical data structure (such as XML).
[中]从分层数据结构(如XML)反序列化对象。

代码示例

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * Deserialize an object from a hierarchical data structure (such as XML).
 *
 * @throws XStreamException if the object cannot be deserialized
 */
public Object unmarshal(HierarchicalStreamReader reader) {
  return unmarshal(reader, null, null);
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * Deserialize an object from a hierarchical data structure (such as XML), 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 unmarshal(HierarchicalStreamReader reader, Object root) {
  return unmarshal(reader, root, null);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Unmarshals this DOM into an object via the given XStream.
 */
public <T> T unmarshal(XStream xs) {
  return (T)xs.unmarshal(newReader());
}

代码示例来源:origin: jenkinsci/jenkins

public <T> T unmarshal(XStream xs, T root) {
  return (T)xs.unmarshal(newReader(),root);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Unmarshals the given graph to the given XStream HierarchicalStreamWriter.
 * Converts exceptions using {@link #convertXStreamException}.
 */
private Object doUnmarshal(HierarchicalStreamReader streamReader, @Nullable DataHolder dataHolder) {
  try {
    return getXStream().unmarshal(streamReader, null, dataHolder);
  }
  catch (Exception ex) {
    throw convertXStreamException(ex, false);
  }
}

代码示例来源:origin: jenkinsci/jenkins

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);
  }
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * 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);
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * 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);
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * 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);
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * 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);
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * 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);
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

public Object readFromStream() throws EOFException {
  if (!reader.hasMoreChildren()) {
    throw new EOFException();
  }
  reader.moveDown();
  final Object result = unmarshal(reader, dataHolder);
  reader.moveUp();
  return result;
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * 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();
  }
}

代码示例来源:origin: AxonFramework/AxonFramework

@SuppressWarnings({"unchecked"})
@Override
public Object doDeserialize(SerializedObject serializedObject, XStream xStream) {
  if ("org.dom4j.Document".equals(serializedObject.getContentType().getName())) {
    return xStream.unmarshal(new Dom4JReader((org.dom4j.Document) serializedObject.getData()));
  }
  if ("nu.xom.Document".equals(serializedObject.getContentType().getName())) {
    return xStream.unmarshal(new XomReader((nu.xom.Document) serializedObject.getData()));
  }
  InputStream serializedData = convert(serializedObject.getData(), serializedObject.getContentType(),
                     InputStream.class);
  return xStream.fromXML(new InputStreamReader(serializedData, getCharset()));
}

代码示例来源:origin: jenkinsci/jenkins

o = super.unmarshal(reader, root, dataHolder);
} else {
  Set<String> topLevelFields = new HashSet<>();
  o = super.unmarshal(new ReaderWrapper(reader) {
    int depth;
    @Override

代码示例来源:origin: x-stream/xstream

/**
 * Deserialize an object from a hierarchical data structure (such as XML).
 *
 * @throws XStreamException if the object cannot be deserialized
 */
public <T> T unmarshal(final HierarchicalStreamReader reader) {
  return unmarshal(reader, null, null);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Unmarshals this DOM into an object via the given XStream.
 */
public <T> T unmarshal(XStream xs) {
  return (T)xs.unmarshal(newReader());
}

代码示例来源:origin: x-stream/xstream

/**
   * 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);
  }
}

代码示例来源:origin: x-stream/xstream

/**
 * 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);
}

代码示例来源:origin: x-stream/xstream

@Override
public Object readFromStream() throws EOFException {
  if (!reader.hasMoreChildren()) {
    throw new EOFException();
  }
  reader.moveDown();
  final Object result = unmarshal(reader, dataHolder);
  reader.moveUp();
  return result;
}

相关文章