本文整理了Java中com.thoughtworks.xstream.XStream.newDataHolder()
方法的一些代码示例,展示了XStream.newDataHolder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.newDataHolder()
方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:newDataHolder
[英]Create a DataHolder that can be used to pass data to the converters. The DataHolder is provided with a call to #marshal(Object,HierarchicalStreamWriter,DataHolder), #unmarshal(HierarchicalStreamReader,Object,DataHolder), #createObjectInputStream(HierarchicalStreamReader,DataHolder) or #createObjectOutputStream(HierarchicalStreamWriter,String,DataHolder).
[中]创建一个可用于向转换器传递数据的数据保持器。数据持有者可以调用#封送(Object,HierarchicalStreamWriter,DataHolder),#解组(HierarchicalStreamReader,Object,DataHolder),#createObjectInputStream(HierarchicalStreamReader,DataHolder)或#createObjectOutputStream(HierarchicalStreamWriter,String,DataHolder)。
代码示例来源:origin: riotfamily/riot
private DataHolder createDataHolder(Content content) {
DataHolder dataHolder = xstream.newDataHolder();
dataHolder.put("content", content);
return dataHolder;
}
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core
/**
* Read results from JTL file.
*
* @param reader of the file
* @param resultCollectorHelper helper class to enable TestResultWrapperConverter to deliver the samples
* @throws IOException if an I/O error occurs
*/
public static void loadTestResults(InputStream reader, ResultCollectorHelper resultCollectorHelper) throws IOException {
// Get the InputReader to use
InputStreamReader inputStreamReader = getInputStreamReader(reader);
DataHolder dh = JTLSAVER.newDataHolder();
dh.put(RESULTCOLLECTOR_HELPER_OBJECT, resultCollectorHelper); // Allow TestResultWrapper to feed back the samples
// This is effectively the same as saver.fromXML(InputStream) except we get to provide the DataHolder
// Don't know why there is no method for this in the XStream class
JTLSAVER.unmarshal(new XppDriver().createReader(reader), null, dh);
inputStreamReader.close();
}
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core
/**
* Save a sampleResult to an XML output file using XStream.
*
* @param evt sampleResult wrapped in a sampleEvent
* @param writer output stream which must be created using {@link #getFileEncoding(String)}
* @throws IOException when writing data to output fails
*/
// Used by ResultCollector.sampleOccurred(SampleEvent event)
public synchronized static void saveSampleResult(SampleEvent evt, Writer writer) throws IOException {
DataHolder dh = JTLSAVER.newDataHolder();
dh.put(SAMPLE_EVENT_OBJECT, evt);
// This is effectively the same as saver.toXML(Object, Writer) except we get to provide the DataHolder
// Don't know why there is no method for this in the XStream class
try {
JTLSAVER.marshal(evt.getResult(), new XppDriver().createWriter(writer), dh);
} catch(RuntimeException e) {
throw new IllegalArgumentException("Failed marshalling:"+(evt.getResult() != null ? showDebuggingInfo(evt.getResult()) : "null"), e);
}
writer.write('\n');
}
内容来源于网络,如有侵权,请联系作者删除!