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.tools.benchmark.Product;
15:
16: import java.io.OutputStream;
17: import java.io.InputStream;
18: import java.io.ObjectOutputStream;
19: import java.io.ObjectInputStream;
20:
21: /**
22: * Standard Java Object Serialization product.
23: *
24: * @author Joe Walnes
25: * @see com.thoughtworks.xstream.tools.benchmark.Harness
26: * @see Product
27: * @see ObjectOutputStream
28: * @see ObjectInputStream
29: */
30: public class JavaObjectSerialization implements Product {
31:
32: public void serialize(Object object, OutputStream output)
33: throws Exception {
34: ObjectOutputStream objectOutputStream = new ObjectOutputStream(
35: output);
36: objectOutputStream.writeObject(object);
37: }
38:
39: public Object deserialize(InputStream input) throws Exception {
40: ObjectInputStream objectInputStream = new ObjectInputStream(
41: input);
42: return objectInputStream.readObject();
43: }
44:
45: public String toString() {
46: return "Java object serialization";
47: }
48:
49: }
|