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