|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object eap.fits.FitsData
Represents the data part of a FITS HDU. The data are stored internally as a byte array, and this class provides I/O streams for reading and writing formatted data in that array. This way the user has random access to the data, but does not need to parse the entire HDU if they are only interested in a small part of it. The problem with this approach is that it can require a large amount of memory, and it may be impossible to read particularly large FITS files. At some point I should modify this class to keep the raw storage on disk. However, there are many uses (e.g. in an Applet), where you may not be allowed to write to a local disk, so I'm not sure how useful that would be in practice.
This class does not understand the structure
of the data. Therefore this class is amost never instantiated. Instead,
you should typically use FitsImageData
or FitsBinTableData
.
Field Summary | |
protected byte[] |
data
the internal data array |
protected DataInputStream |
interpreter
used for reading formatted data from the internal data array |
protected boolean |
isComplete
flag indicating if all the data bytes have been read |
static int |
PADDING
value to use when padding out partial blocks. |
protected DataOutputStream |
setter
for writing formatted values into the internal data array |
protected int |
valid_bytes
the number of bytes which have been read from a data source |
Constructor Summary | |
FitsData(FitsHeader header)
Create a data object with the correct size for the given header. |
|
FitsData(int size)
Creates a data object with the internal data array initialized to hold the given number of bytes. |
Method Summary | |
protected int |
available()
returns the number of bytes remaining in the raw data array between the current position and the end of the array. |
int |
blockCount()
returns the number of blocks (including partial blocks) in the data |
static FitsData |
createFrom(FitsHeader header)
This is a factory method to produce a FitsData object of the appropriate type corresponding to a given header |
protected byte[] |
data()
returns the raw data array |
void |
goToByte(long new_position)
reposition the data reader and writer streams to a given offset in the raw data array. |
void |
incrementValidBytes(int new_bytes)
adjust the number of valid bytes by a given increment. |
boolean |
isComplete()
returns true if the data array has been completely read. |
void |
setValidBytes(int valid_bytes)
update the number of bytes which have been set in the data array. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int PADDING
protected byte[] data
protected int valid_bytes
protected boolean isComplete
protected DataInputStream interpreter
protected DataOutputStream setter
Constructor Detail |
public FitsData(int size)
size
- the number of bytes in the data, not including padding.public FitsData(FitsHeader header) throws eap.fits.FitsCardException
createFrom(FitsHeader)
if you want to create a data object
of the appropriate type
header
- - the header to use to derive the size of the data.
FitsCardException
- if the header is not properly formed.createFrom(FitsHeader)
Method Detail |
public int blockCount()
protected byte[] data()
public void setValidBytes(int valid_bytes) throws FitsException
FitsFile
to indicate
the fraction of the raw data array which has been read from a data source.
This method should not be called by the general user.
valid_bytes
- the new number of valid bytes in the raw data array
FitsException
- never, however subclasses may do so.FitsFile.getHDU(int, int)
public void incrementValidBytes(int new_bytes) throws FitsException
new_bytes
- the change in the number of valid bytes
FitsException
- never, however subclasses may do so.setValidBytes(int)
public boolean isComplete()
FitsFile.getHDU(int, int)
was called with the
FitsFile.NEED_DATA_LATER
hint.
public static FitsData createFrom(FitsHeader header) throws FitsException
header
- the header specifying the size and type of the data
FitsException
- if the header was malformed.public void goToByte(long new_position)
protected int available()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |