001    package util;
002    
003    import java.io.Serializable;
004    
005    /**
006     * An Object to mark positions in ObjectStreams.
007     *
008     * <p>You can use a StreamMarker to mark the end of a flow of objects of
009     * unknown class and unknown size. On reading you will then know exactly up to
010     * where you must read.<BR>
011     * E.g. to store some objects out of an enumeration and reread them into a
012     * vector you could use code similar to the following:
013     * <HR><PRE>
014     *  ...
015     *  Enumeration e = q.elements();
016     *  ObjectOutputStream o = new ObjectOutputStream (fileOutputStream);
017     *  while (e.hasMoreElements())
018     *    o.writeObject (e.nextElement());
019     *
020     *  // Set the Marker:
021     *  o.writeObject (new StreamMarker());
022     *
023     *  ...
024     *
025     *  Vector v = new Vector();
026     *  ObjectInputStream oi = new ObjectInputStream (fileInputStream);
027     *  Object ob = oi.readObject();
028     *  while (!(ob instanceof StreamMarker)) {
029     *    v.addElement (ob);
030     *    ob = oi.readObject();
031     *  }
032     *  ...
033     * </PRE></p>
034     *
035     * @author Steffen Zschaler
036     * @version 1.0
037     * @since v1.0
038     */
039    public final class StreamMarker extends Object implements Serializable {
040    
041        /**
042         * Create a new StreamMarker.
043         */
044        public StreamMarker() {
045            super();
046        }
047    
048        /**
049         * Give a string representation of this object.
050         *
051         * @override Never
052         */
053        public final String toString() {
054            return "[StreamMarker used to mark positions in Streams.]";
055        }
056    }