本文整理汇总了Java中com.thoughtworks.xstream.converters.DataHolder类的典型用法代码示例。如果您正苦于以下问题:Java DataHolder类的具体用法?Java DataHolder怎么用?Java DataHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataHolder类属于com.thoughtworks.xstream.converters包,在下文中一共展示了DataHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unmarshal
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public Object unmarshal(HierarchicalStreamReader paramHierarchicalStreamReader, Object paramObject, DataHolder paramDataHolder)
{
try
{
Object localObject = this.marshallingStrategy.unmarshal(paramObject, paramHierarchicalStreamReader, paramDataHolder, this.converterLookup, this.mapper);
return localObject;
}
catch (ConversionException localConversionException)
{
Package localPackage = getClass().getPackage();
String str1;
if (localPackage != null)
str1 = localPackage.getImplementationVersion();
else
str1 = null;
String str2;
if (str1 != null)
str2 = str1;
else
str2 = "not available";
localConversionException.add("version", str2);
throw localConversionException;
}
}
示例2: getInstance
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public static CustomObjectOutputStream getInstance(DataHolder paramDataHolder, StreamCallback paramStreamCallback)
{
try
{
CustomObjectOutputStream localCustomObjectOutputStream1 = (CustomObjectOutputStream)paramDataHolder.get(DATA_HOLDER_KEY);
CustomObjectOutputStream localCustomObjectOutputStream2 = localCustomObjectOutputStream1;
if (localCustomObjectOutputStream1 == null)
{
localCustomObjectOutputStream2 = new CustomObjectOutputStream(paramStreamCallback);
paramDataHolder.put(DATA_HOLDER_KEY, localCustomObjectOutputStream2);
}
else
{
localCustomObjectOutputStream2.pushCallback(paramStreamCallback);
}
return localCustomObjectOutputStream2;
}
catch (IOException localIOException)
{
throw new ConversionException("Cannot create CustomObjectStream", localIOException);
}
finally
{
}
}
示例3: getInstance
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public static CustomObjectInputStream getInstance(DataHolder paramDataHolder, StreamCallback paramStreamCallback, ClassLoaderReference paramClassLoaderReference)
{
try
{
CustomObjectInputStream localCustomObjectInputStream1 = (CustomObjectInputStream)paramDataHolder.get(DATA_HOLDER_KEY);
CustomObjectInputStream localCustomObjectInputStream2 = localCustomObjectInputStream1;
if (localCustomObjectInputStream1 == null)
{
localCustomObjectInputStream2 = new CustomObjectInputStream(paramStreamCallback, paramClassLoaderReference);
paramDataHolder.put(DATA_HOLDER_KEY, localCustomObjectInputStream2);
}
else
{
localCustomObjectInputStream2.pushCallback(paramStreamCallback);
}
return localCustomObjectInputStream2;
}
catch (IOException localIOException)
{
throw new ConversionException("Cannot create CustomObjectStream", localIOException);
}
finally
{
}
}
示例4: readXmlFile
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <O> O readXmlFile(final TemporaryFileHandle file, String path, final XStream xstream, O rootObject,
DataHolder dataHolder)
{
try( Reader reader = new UnicodeReader(fileSystemService.read(file, path), Constants.UTF8) )
{
return (O) xstream.unmarshal(xppDriver.createReader(reader), rootObject, dataHolder);
}
catch( IOException re )
{
LOGGER.error("Error reading: " + file.getAbsolutePath());
throw new RuntimeException(re);
}
}
示例5: unmarshal
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
/**
* Deserialize an object from a hierarchical data structure (such as XML).
*
* @param root If present, the passed in object will have its fields populated, as opposed to XStream creating a new
* instance. 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!
* @param dataHolder Extra data you can use to pass to your converters. Use this as you want. If not present,
* XStream shall create one lazily as needed.
* @throws XStreamException if the object cannot be deserialized
*/
public <T> T unmarshal(final HierarchicalStreamReader reader, final T root, final DataHolder dataHolder) {
try {
@SuppressWarnings("unchecked")
final T t = (T)marshallingStrategy.unmarshal(root, reader, dataHolder, converterLookup, mapper);
return t;
} catch (final ConversionException e) {
final Package pkg = getClass().getPackage();
final String version = pkg != null ? pkg.getImplementationVersion() : null;
e.add("version", version != null ? version : "not available");
throw e;
}
}
示例6: start
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public Object start(final DataHolder dataHolder) {
this.dataHolder = dataHolder;
final Class<?> type = HierarchicalStreams.readClassType(reader, mapper);
final Object result = convertAnother(null, type);
for (final Runnable runnable : validationList) {
runnable.run();
}
return result;
}
示例7: getInstance
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public static synchronized CustomObjectOutputStream getInstance(final DataHolder whereFrom,
final StreamCallback callback) {
try {
CustomObjectOutputStream result = (CustomObjectOutputStream)whereFrom.get(DATA_HOLDER_KEY);
if (result == null) {
result = new CustomObjectOutputStream(callback);
whereFrom.put(DATA_HOLDER_KEY, result);
} else {
result.pushCallback(callback);
}
return result;
} catch (final IOException e) {
throw new ConversionException("Cannot create CustomObjectStream", e);
}
}
示例8: getInstance
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public static synchronized CustomObjectInputStream getInstance(final DataHolder whereFrom,
final CustomObjectInputStream.StreamCallback callback, final ClassLoaderReference classLoaderReference) {
try {
CustomObjectInputStream result = (CustomObjectInputStream)whereFrom.get(DATA_HOLDER_KEY);
if (result == null) {
result = new CustomObjectInputStream(callback, classLoaderReference);
whereFrom.put(DATA_HOLDER_KEY, result);
} else {
result.pushCallback(callback);
}
return result;
} catch (final IOException e) {
throw new ConversionException("Cannot create CustomObjectStream", e);
}
}
示例9: start
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public void start(final Object item, final DataHolder dataHolder) {
this.dataHolder = dataHolder;
if (item == null) {
writer.startNode(mapper.serializedClass(null));
writer.endNode();
} else {
ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedClass(item.getClass()), item
.getClass());
convertAnother(item);
writer.endNode();
}
}
示例10: marshalOutputStream
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public void marshalOutputStream(Object graph, OutputStream outputStream, DataHolder dataHolder)
throws XmlMappingException, IOException {
if (this.streamDriver != null) {
doMarshal(graph, this.streamDriver.createWriter(outputStream), dataHolder);
}
else {
marshalWriter(graph, new OutputStreamWriter(outputStream, this.encoding), dataHolder);
}
}
示例11: marshalWriter
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public void marshalWriter(Object graph, Writer writer, DataHolder dataHolder)
throws XmlMappingException, IOException {
if (this.streamDriver != null) {
doMarshal(graph, this.streamDriver.createWriter(writer), dataHolder);
}
else {
doMarshal(graph, new CompactWriter(writer), dataHolder);
}
}
示例12: unmarshalInputStream
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public Object unmarshalInputStream(InputStream inputStream, 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);
}
}
示例13: doUnmarshal
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
/**
* Unmarshals the given graph to the given XStream HierarchicalStreamWriter.
* Converts exceptions using {@link #convertXStreamException}.
*/
private Object doUnmarshal(HierarchicalStreamReader streamReader, DataHolder dataHolder) {
try {
return getXStream().unmarshal(streamReader, null, dataHolder);
}
catch (Exception ex) {
throw convertXStreamException(ex, false);
}
}
示例14: saveSampleResult
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
/**
* 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');
}
示例15: loadTestResults
import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
/**
* 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();
}