001 /*
002 * $Id: XStreamSerializer.java,v 1.1 2013/11/30 14:28:19 oboehm Exp $
003 *
004 * Copyright (c) 2013 by Oliver Boehm
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 *
018 * (c)reated 30.11.2013 by oliver (ob@oasd.de)
019 */
020
021 package patterntesting.runtime.io;
022
023 import java.io.*;
024
025 import com.thoughtworks.xstream.XStream;
026
027 /**
028 * This is a thin wrapper around the {@link XStream} class and xstream
029 * library.
030 *
031 * @author oliver
032 * @since 1.4 (30.11.2013)
033 */
034 public final class XStreamSerializer extends AbstractSerializer {
035
036 private static final XStream xstream = new XStream();
037
038 /**
039 * Creates the {@link ObjectInputStream} that deserializes a stream of
040 * objects from an InputStream using XStream.
041 *
042 * @param in the input stream
043 * @return the object input stream
044 * @throws IOException Signals that an I/O exception has occurred.
045 */
046 @Override
047 public ObjectInputStream createObjectInputStream(final InputStream in)
048 throws IOException {
049 return xstream.createObjectInputStream(in);
050 }
051
052 /**
053 * Creates the {@link ObjectOutputStream} that serializees a stream of
054 * objects to the {@link OutputStream} using {@link XStream}.
055 *
056 * @param out the out
057 * @return the object output stream
058 * @throws IOException Signals that an I/O exception has occurred.
059 * @see AbstractSerializer#createObjectOutputStream(java.io.OutputStream)
060 */
061 @Override
062 public ObjectOutputStream createObjectOutputStream(final OutputStream out) throws IOException {
063 return xstream.createObjectOutputStream(out);
064 }
065
066 }
067