1. /*
  2. * @(#)TruncatedFileException.java 1.8 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. /* ********************************************************************
  8. **********************************************************************
  9. **********************************************************************
  10. *** COPYRIGHT (c) Eastman Kodak Company, 1997 ***
  11. *** As an unpublished work pursuant to Title 17 of the United ***
  12. *** States Code. All rights reserved. ***
  13. **********************************************************************
  14. **********************************************************************
  15. **********************************************************************/
  16. package com.sun.image.codec.jpeg;
  17. import java.awt.image.Raster;
  18. import java.awt.image.BufferedImage;
  19. /**
  20. * Signals that a truncated file was detected. This object contains
  21. * the Raster/BufferedImage that has the partially decoded image data
  22. * in it. There is no indication of the portion of the Raster that
  23. * may or may not be good.
  24. * <p>
  25. * Note that the classes in the com.sun.image.codec.jpeg package are not
  26. * part of the core Java APIs. They are a part of Sun's JDK and JRE
  27. * distributions. Although other licensees may choose to distribute these
  28. * classes, developers cannot depend on their availability in non-Sun
  29. * implementations. We expect that equivalent functionality will eventually
  30. * be available in a core API or standard extension.
  31. * <p>
  32. *
  33. * @author Thomas DeWeese
  34. * @see JPEGImageDecoder
  35. * @since JDK1.2
  36. */
  37. public
  38. class TruncatedFileException extends RuntimeException {
  39. private Raster ras = null;
  40. private BufferedImage bi = null;
  41. /**
  42. * Constructs a <code>TruncatedFileException/code> with the
  43. * partially decoded BufferedImage.
  44. *
  45. * @param bi the partially decoded BufferedImage (may be null).
  46. * @since JDK1.2
  47. */
  48. public TruncatedFileException(BufferedImage bi) {
  49. super("Premature end of input file");
  50. this.bi = bi;
  51. this.ras = bi.getData();
  52. }
  53. /**
  54. * Constructs an <code>TruncatedFileException</code> with the
  55. * partially decoded Raster
  56. *
  57. * @param ras the partially decoded Raster (may be null).
  58. * @since JDK1.2
  59. */
  60. public TruncatedFileException(Raster ras) {
  61. super("Premature end of input file");
  62. this.ras = ras;
  63. }
  64. /** Allows access to the raster that was in the progress of being
  65. * decoded may be null, it is likely to be only partially filled
  66. * with image data.
  67. * @since JDK1.2
  68. */
  69. public Raster getRaster() { return ras; }
  70. /** Allows access to the BufferedImage that was in the progress of
  71. * being decoded, this may be null, it is likely to be only
  72. * partially filled with image data.
  73. * @since JDK1.2
  74. */
  75. public BufferedImage getBufferedImage() { return bi; }
  76. }