01: /*
02: * Copyright (C) 2006 Joe Walnes.
03: * Copyright (C) 2006, 2007 XStream Committers.
04: * All rights reserved.
05: *
06: * The software in this package is published under the terms of the BSD
07: * style license a copy of which has been included with this distribution in
08: * the LICENSE.txt file.
09: *
10: * Created on 15. July 2006 by Joe Walnes
11: */
12: package com.thoughtworks.xstream.tools.benchmark.products;
13:
14: import com.thoughtworks.xstream.XStream;
15: import com.thoughtworks.xstream.io.xml.XppDriver;
16: import com.thoughtworks.xstream.tools.benchmark.Product;
17:
18: import java.io.InputStream;
19: import java.io.OutputStream;
20:
21: /**
22: * Uses XStream with the XPP driver for parsing XML.
23: *
24: * @author Joe Walnes
25: * @see com.thoughtworks.xstream.tools.benchmark.Harness
26: * @see Product
27: * @see XStream
28: * @see XppDriver
29: */
30: public class XStreamXpp implements Product {
31:
32: private final XStream xstream;
33:
34: public XStreamXpp() {
35: this .xstream = new XStream(new XppDriver());
36: }
37:
38: public void serialize(Object object, OutputStream output)
39: throws Exception {
40: xstream.toXML(object, output);
41: }
42:
43: public Object deserialize(InputStream input) throws Exception {
44: return xstream.fromXML(input);
45: }
46:
47: public String toString() {
48: return "XStream (XML with XPP parser)";
49: }
50:
51: }
|