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