• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DataHolder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.thoughtworks.xstream.converters.DataHolder的典型用法代码示例。如果您正苦于以下问题:Java DataHolder类的具体用法?Java DataHolder怎么用?Java DataHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataHolder类属于com.thoughtworks.xstream.converters包,在下文中一共展示了DataHolder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:25,代码来源:XStream.java


示例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
  {
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:26,代码来源:CustomObjectOutputStream.java


示例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
  {
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:26,代码来源:CustomObjectInputStream.java


示例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);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:XmlHelper.java


示例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;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:XStream.java


示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:TreeUnmarshaller.java


示例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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:CustomObjectOutputStream.java


示例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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:CustomObjectInputStream.java


示例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();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:TreeMarshaller.java


示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:XStreamMarshaller.java


示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:XStreamMarshaller.java


示例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);
       }
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:XStreamMarshaller.java


示例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);
    }
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:XStreamMarshaller.java


示例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');
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:21,代码来源:SaveService.java


示例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();
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:18,代码来源:SaveService.java


示例16: 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;
    }
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:24,代码来源:XStream.java


示例17: createObjectOutputStream

import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
/**
 * Creates an ObjectOutputStream that serializes a stream of objects to the writer using XStream.
 *
 * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String)
 * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
 * @since 1.4.10
 */
@SuppressWarnings("resource")
public ObjectOutputStream createObjectOutputStream(final HierarchicalStreamWriter writer, final String rootNodeName,
        final DataHolder dataHolder) throws IOException {
    final StatefulWriter statefulWriter = new StatefulWriter(writer);
    statefulWriter.startNode(rootNodeName, null);
    return new CustomObjectOutputStream(new CustomObjectOutputStream.StreamCallback() {
        @Override
        public void writeToStream(final Object object) {
            marshal(object, statefulWriter, dataHolder);
        }

        @Override
        public void writeFieldsToStream(final Map<String, Object> fields) throws NotActiveException {
            throw new NotActiveException("not in call to writeObject");
        }

        @Override
        public void defaultWriteObject() throws NotActiveException {
            throw new NotActiveException("not in call to writeObject");
        }

        @Override
        public void flush() {
            statefulWriter.flush();
        }

        @Override
        public void close() {
            if (statefulWriter.state() != StatefulWriter.STATE_CLOSED) {
                statefulWriter.endNode();
                statefulWriter.close();
            }
        }
    });
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:43,代码来源:XStream.java


示例18: createObjectInputStream

import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
/**
 * Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream.
 *
 * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String)
 * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
 * @since 1.4.10
 */
public ObjectInputStream createObjectInputStream(final HierarchicalStreamReader reader, final DataHolder dataHolder)
        throws IOException {
    return new CustomObjectInputStream(new CustomObjectInputStream.StreamCallback() {
        @Override
        public Object readFromStream() throws EOFException {
            if (!reader.hasMoreChildren()) {
                throw new EOFException();
            }
            reader.moveDown();
            final Object result = unmarshal(reader, dataHolder);
            reader.moveUp();
            return result;
        }

        @Override
        public Map<String, Object> readFieldsFromStream() throws IOException {
            throw new NotActiveException("not in call to readObject");
        }

        @Override
        public void defaultReadObject() throws NotActiveException {
            throw new NotActiveException("not in call to readObject");
        }

        @Override
        public void registerValidation(final ObjectInputValidation validation, final int priority)
                throws NotActiveException {
            throw new NotActiveException("stream inactive");
        }

        @Override
        public void close() {
            reader.close();
        }
    }, classLoaderReference);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:44,代码来源:XStream.java


示例19: marshal

import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public void marshal(HierarchicalStreamWriter writer, Object obj,
    ConverterLookup converterLookup, Mapper mapper, DataHolder dataHolder) {
    if (marshaller == null) {
        marshaller = new ReferenceByIdMarshaller(writer, converterLookup, mapper);
    }
    marshaller.start(obj, dataHolder);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:8,代码来源:MultipleObjectsInOneStreamTest.java


示例20: unmarshal

import com.thoughtworks.xstream.converters.DataHolder; //导入依赖的package包/类
public Object unmarshal(Object root, HierarchicalStreamReader reader,
    DataHolder dataHolder, ConverterLookup converterLookup, Mapper mapper) {
    if (unmarshaller == null) {
        unmarshaller = new ReferenceByIdUnmarshaller(
            root, reader, converterLookup, mapper);
    }
    return unmarshaller.start(dataHolder);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:9,代码来源:MultipleObjectsInOneStreamTest.java



注:本文中的com.thoughtworks.xstream.converters.DataHolder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OperationProto类代码示例发布时间:2022-05-22
下一篇:
Java AutoSavingCache类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap