001    /*
002     * $Id: BinarySerializer.java,v 1.1 2013/11/30 15:34:49 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    /**
026     * This is the default serializer which uses the default mechanism proved by
027     * the JDK. For this reason the serialized object must be {@link Serializable}.
028     *
029     * @author oliver
030     * @since 1.4 (30.11.2013)
031     */
032    public final class BinarySerializer extends AbstractSerializer {
033    
034        /**
035         * Creates the {@link ObjectInputStream} that deserializes a stream of
036         * objects from an InputStream using the default mechnism of Java.
037         * For this reason the serialized objects must be {@link Serializable}.
038         *
039         * @param in the input stream
040         * @return the object input stream
041         * @throws IOException Signals that an I/O exception has occurred.
042         */
043        @Override
044        public ObjectInputStream createObjectInputStream(final InputStream in)
045                throws IOException {
046            return new ObjectInputStream(in);
047        }
048    
049        /**
050         * Creates the {@link ObjectOutputStream} that serializees a stream of
051         * objects to the {@link OutputStream} using the default mechnism of Java.
052         * For this reason the serialized objects must be {@link Serializable}.
053         *
054         * @param out the out
055         * @return the object output stream
056         * @throws IOException Signals that an I/O exception has occurred.
057         * @see AbstractSerializer#createObjectOutputStream(java.io.OutputStream)
058         */
059        @Override
060        public ObjectOutputStream createObjectOutputStream(final OutputStream out) throws IOException {
061            return new ObjectOutputStream(out);
062        }
063    
064    }
065