1 /* 2 * @(#)OptionalDataException.java 1.18 04/01/12 3 * 4 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 package java.io; 8 9 /** 10 * Exception indicating the failure of an object read operation due to 11 * unread primitive data, or the end of data belonging to a serialized 12 * object in the stream. This exception may be thrown in two cases: 13 * 14 * <ul> 15 * <li>An attempt was made to read an object when the next element in the 16 * stream is primitive data. In this case, the OptionalDataException's 17 * length field is set to the number of bytes of primitive data 18 * immediately readable from the stream, and the eof field is set to 19 * false. 20 * 21 * <li>An attempt was made to read past the end of data consumable by a 22 * class-defined readObject or readExternal method. In this case, the 23 * OptionalDataException's eof field is set to true, and the length field 24 * is set to 0. 25 * </ul> 26 * 27 * @author unascribed 28 * @version 1.18, 01/12/04 29 * @since JDK1.1 30 */ 31 public class OptionalDataException extends ObjectStreamException { 32 /* 33 * Create an <code>OptionalDataException</code> with a length. 34 */ 35 OptionalDataException(int len) { 36 eof = false; 37 length = len; 38 } 39 40 /* 41 * Create an <code>OptionalDataException</code> signifying no 42 * more primitive data is available. 43 */ 44 OptionalDataException(boolean end) { 45 length = 0; 46 eof = end; 47 } 48 49 /** 50 * The number of bytes of primitive data available to be read 51 * in the current buffer. 52 * 53 * @serial 54 */ 55 public int length; 56 57 /** 58 * True if there is no more data in the buffered part of the stream. 59 * 60 * @serial 61 */ 62 public boolean eof; 63 } 64