Don't treat inner classes as test classes with ant.
[fits.git] / src / nom / tam / fits / PaddingException.java
1 package nom.tam.fits;
2
3 /**
4  * This exception is thrown if an error is found 
5  * reading the padding following a valid FITS HDU.
6  * This padding is required by the FITS standard, but
7  * some FITS writes forego writing it.  To access such data
8  * users can use something like:
9  * 
10  * <code>
11  *     Fits f = new Fits("somefile");
12  *     try {
13  *          f.read();
14  *     } catch (PaddingException e) {
15  *          f.addHDU(e.getHDU());
16  *     }
17  * </code>
18  * to ensure that a truncated HDU is included in the FITS object.
19  * Generally the FITS file have already added any HDUs prior
20  * to the truncatd one.
21  */
22 public class PaddingException extends FitsException {
23
24     /** The HDU where the error happened.
25      */
26     private BasicHDU truncatedHDU;
27
28     /** 
29      * When the error is thrown, the data object being
30      * read must be supplied.  We initially create a dummy
31      * header for this.  If someone is reading the entire
32      * HDU, then they can trap the exception and set the header
33      * to the appropriate value.
34      */
35     public PaddingException(Data datum) throws FitsException {
36         truncatedHDU = FitsFactory.HDUFactory(datum.getKernel());
37         // We want to use the original Data object... so
38         truncatedHDU = FitsFactory.HDUFactory(truncatedHDU.getHeader(), datum);
39     }
40
41     public PaddingException(String msg, Data datum) throws FitsException {
42         super(msg);
43         truncatedHDU = FitsFactory.HDUFactory(datum.getKernel());
44         truncatedHDU = FitsFactory.HDUFactory(truncatedHDU.getHeader(), datum);
45     }
46
47     void updateHeader(Header hdr) throws FitsException {
48         truncatedHDU = FitsFactory.HDUFactory(hdr, truncatedHDU.getData());
49     }
50
51     public BasicHDU getTruncatedHDU() {
52         return truncatedHDU;
53     }
54 }