01: /*
02: *
03: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
04: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License version
08: * 2 only, as published by the Free Software Foundation.
09: *
10: * This program is distributed in the hope that it will be useful, but
11: * WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * General Public License version 2 for more details (a copy is
14: * included at /legal/license.txt).
15: *
16: * You should have received a copy of the GNU General Public License
17: * version 2 along with this work; if not, write to the Free Software
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
22: * Clara, CA 95054 or visit www.sun.com if you need additional
23: * information or have any questions.
24: */
25: package java.io;
26:
27: /**
28: * Exception indicating the failure of an object read operation due to
29: * unread primitive data, or the end of data belonging to a serialized
30: * object in the stream. This exception may be thrown in two cases:
31: *
32: * <ul>
33: * <li>An attempt was made to read an object when the next element in the
34: * stream is primitive data. In this case, the OptionalDataException's
35: * length field is set to the number of bytes of primitive data
36: * immediately readable from the stream, and the eof field is set to
37: * false.
38: *
39: * <li>An attempt was made to read past the end of data consumable by a
40: * class-defined readObject or readExternal method. In this case, the
41: * OptionalDataException's eof field is set to true, and the length field
42: * is set to 0.
43: * </ul>
44: *
45: * @author unascribed
46: * @version 1.21, 10/10/06
47: * @since JDK1.1
48: */
49: public class OptionalDataException extends ObjectStreamException {
50: /*
51: * Create an <code>OptionalDataException</code> with a length.
52: */
53: OptionalDataException(int len) {
54: eof = false;
55: length = len;
56: }
57:
58: /*
59: * Create an <code>OptionalDataException</code> signifing no
60: * more primitive data is available.
61: */
62: OptionalDataException(boolean end) {
63: length = 0;
64: eof = end;
65: }
66:
67: /**
68: * The number of bytes of primitive data available to be read
69: * in the current buffer.
70: *
71: * @serial
72: */
73: public int length;
74:
75: /**
76: * True if there is no more data in the buffered part of the stream.
77: *
78: * @serial
79: */
80: public boolean eof;
81: }
|