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     *  &nbsp;&nbsp;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     *  &nbsp;&nbsp;v.addElement (ob);
030     *  &nbsp;&nbsp;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             * ID for serialization.
043             */
044            private static final long serialVersionUID = -8778730715626619060L;
045    
046            /**
047         * Create a new StreamMarker.
048         */
049        public StreamMarker() {
050            super();
051        }
052    
053        /**
054         * Give a string representation of this object.
055         *
056         * @override Never
057         */
058        public final String toString() {
059            return "[StreamMarker used to mark positions in Streams.]";
060        }
061    }