|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnom.tam.fits.Header
public class Header
This class describes methods to access and manipulate the header for a FITS HDU.
Constructor Summary | |
---|---|
Header()
Create a Header with no card images. |
|
Header(BufferedDataInputStream is)
Create a header and populate it from the input stream |
|
Header(java.lang.String[] newCards)
Create a header and initialize it with a vector of strings. |
Method Summary | |
---|---|
void |
addBooleanValue(java.lang.String key,
boolean val,
java.lang.String comment)
Add or replace a key with the given boolean value and comment. |
void |
addDoubleValue(java.lang.String key,
double val,
java.lang.String comment)
Add or replace a key with the given double value and comment. |
void |
addFloatValue(java.lang.String key,
float val,
java.lang.String comment)
Add or replace a key with the given float value and comment. |
void |
addIntValue(java.lang.String key,
int val,
java.lang.String comment)
Add or replace a key with the given int value and comment. |
protected void |
addLine(HeaderCard fcard)
Add a card image to the header after the mark if set. |
protected void |
addLine(java.lang.String card)
Add a card image to the header after the mark if set. |
void |
addLongValue(java.lang.String key,
long val,
java.lang.String comment)
Add or replace a key with the given long value and comment. |
void |
addStringValue(java.lang.String key,
java.lang.String val,
java.lang.String comment)
Add or replace a key with the given string value and comment. |
boolean |
containsKey(java.lang.String key)
Tests if the specified keyword is present in this table. |
void |
deleteKey(java.lang.String key)
Delete the card associated with the given key. |
protected void |
dumpHeader(java.io.PrintStream ps)
Dump the header to a given stream. |
protected HeaderCard |
findCard(java.lang.String key)
Find the card associated with a given key. |
java.lang.String |
findKey(java.lang.String key)
Find the card associated with a given key. |
static java.lang.String |
formatFields(java.lang.String key,
java.lang.String val,
java.lang.String comment)
Format the key, value and comment fields for the FITS data. |
boolean |
getBooleanValue(java.lang.String key)
Get the boolean value associated with the given key. |
boolean |
getBooleanValue(java.lang.String key,
boolean dft)
Get the boolean value associated with the given key. |
java.lang.String |
getCard(int n)
Get the n'th card image in the header |
double |
getDoubleValue(java.lang.String key)
Get the double value associated with the given key. |
double |
getDoubleValue(java.lang.String key,
double dft)
Get the double value associated with the given key. |
float |
getFloatValue(java.lang.String key)
Get the float value associated with the given key. |
float |
getFloatValue(java.lang.String key,
float dft)
Get the float value associated with the given key. |
int |
getIntValue(java.lang.String key)
Get the int value associated with the given key. |
int |
getIntValue(java.lang.String key,
int dft)
Get the value associated with the key as an int. |
java.lang.String |
getKey(int n)
Get the n'th key in the header. |
long |
getLongValue(java.lang.String key)
Get the long value associated with the given key. |
long |
getLongValue(java.lang.String key,
long dft)
Get the long value associated with the given key. |
int |
getMark()
Get the current mark. |
java.lang.String |
getStringValue(java.lang.String key)
Get the String value associated with the given key. |
int |
headerSize()
Return the size of the header data including padding. |
protected boolean |
imageToPrimary()
See if the current header is for an an array and if so turn it into a primary array. |
void |
insertCard(java.lang.String card)
Insert or add a card to the header. |
void |
insertComment(java.lang.String value)
Add a COMMENT line. |
void |
insertCommentStyle(java.lang.String header,
java.lang.String value)
Add a line to the header using the COMMENT style, i.e., no '=' in column 9. |
void |
insertHistory(java.lang.String value)
Add a HISTORY line. |
boolean |
isValidHeader()
Is this a valid header. |
boolean |
markSet()
Is the mark set? |
int |
paddedDataSize()
Return the size of the data including any needed padding. |
void |
pointToData(Data o)
Create keywords such that this Header describes the given data. |
protected void |
pointToImage(java.lang.Object o)
Create keywords such that this header describes the given image data. |
protected boolean |
primaryToImage()
See if the current header is an array and if so turn it into an IMAGE extension. |
void |
read(BufferedDataInputStream dis)
Read a stream for header data. |
static Header |
readHeader(BufferedDataInputStream dis)
Create a header by reading the information from the input stream. |
void |
removeCardAt(int i)
Remove the card at the given index. |
void |
replaceCard(java.lang.String key,
java.lang.String val,
java.lang.String comment)
Add or replace a key using the preformatted value. |
void |
setMark(int newMark)
Set the mark to the given value. |
int |
size()
|
int |
trueDataSize()
Calculate the unpadded size of the data segment from the header information. |
void |
unsetMark()
Unset the mark. |
void |
write(BufferedDataOutputStream dos)
Write the current header (including any needed padding) to the output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Header()
public Header(BufferedDataInputStream is) throws TruncatedFileException, java.io.IOException
is
- The input stream where header information is expected.
TruncatedFileException
java.io.IOException
public Header(java.lang.String[] newCards)
newCards
- Card images to be placed in the header.Method Detail |
---|
public int size()
public int trueDataSize()
public int paddedDataSize()
public int headerSize()
public boolean isValidHeader()
true
for a valid header,
false
otherwise.public java.lang.String getCard(int n)
null
if the n'th card
does not exist.public java.lang.String getKey(int n)
null
if the n'th key
does not exist.public long getLongValue(java.lang.String key, long dft)
long
value associated with the given key.
key
- The header key.dft
- The default value to be returned if the key cannot be found.
public double getDoubleValue(java.lang.String key, double dft)
double
value associated with the given key.
key
- The header key.dft
- The default value to return if the key cannot be found.
public boolean getBooleanValue(java.lang.String key, boolean dft)
boolean
value associated with the given key.
key
- The header key.dft
- The value to be returned if the key cannot be found
or if the parameter does not seem to be a boolean.
public long getLongValue(java.lang.String key)
long
value associated with the given key.
key
- The header key.
public double getDoubleValue(java.lang.String key)
double
value associated with the given key.
key
- The header key.
public boolean getBooleanValue(java.lang.String key)
boolean
value associated with the given key.
The
- header key.
public int getIntValue(java.lang.String key, int dft)
key
- The header key.dft
- The value to be returned if the key is not found.public int getIntValue(java.lang.String key)
int
value associated with the given key.
key
- The header key.
public float getFloatValue(java.lang.String key, float dft)
float
value associated with the given key.
key
- The header key.dft
- The value to be returned if the key is not found.public float getFloatValue(java.lang.String key)
float
value associated with the given key.
key
- The header key.
public java.lang.String getStringValue(java.lang.String key)
String
value associated with the given key.
key
- The header key.
protected void addLine(HeaderCard fcard)
fcard
- The card to be added.protected void addLine(java.lang.String card) throws HeaderCardException
card
- The card to be added.
HeaderCardException
- If the card is not valid.public static Header readHeader(BufferedDataInputStream dis) throws TruncatedFileException, java.io.IOException
dis
- The input stream to read the data from.
null
if there was a problem with the header;
otherwise return the header read from the input stream.
TruncatedFileException
java.io.IOException
public void read(BufferedDataInputStream dis) throws TruncatedFileException, java.io.IOException
dis
- The input stream to read the data from.
TruncatedFileException
java.io.IOException
protected HeaderCard findCard(java.lang.String key)
key
- The header key.
null
if the keyword could not be found;
return the HeaderCard object otherwise.public java.lang.String findKey(java.lang.String key)
key
- The header key.
null
if the keyword could not be found;
return the card image otherwise.public void write(BufferedDataOutputStream dos) throws FitsException
dos
- The output stream to which the data is to be written.
FitsException
- if the header could not be written.public void addBooleanValue(java.lang.String key, boolean val, java.lang.String comment) throws HeaderCardException
key
- The header key.val
- The boolean value.comment
- A comment to append to the card.
HeaderCardException
- If the parameters cannot build a
valid FITS card.public void addFloatValue(java.lang.String key, float val, java.lang.String comment) throws HeaderCardException
key
- The header key.val
- The float value.comment
- A comment to append to the card.
HeaderCardException
- If the parameters cannot build a
valid FITS card.public void addDoubleValue(java.lang.String key, double val, java.lang.String comment) throws HeaderCardException
key
- The header key.val
- The double value.comment
- A comment to append to the card.
HeaderCardException
- If the parameters cannot build a
valid FITS card.public void addStringValue(java.lang.String key, java.lang.String val, java.lang.String comment) throws HeaderCardException
key
- The header key.val
- The string value.comment
- A comment to append to the card.
HeaderCardException
- If the parameters cannot build a
valid FITS card.public void replaceCard(java.lang.String key, java.lang.String val, java.lang.String comment) throws HeaderCardException
key
- The header key.val
- The string which will follow the "= " on the
card. This routine is called by the various
addXXXValue routines after they have formatted the
value as a string.comment
- A comment to append to the card.
HeaderCardException
- If the parameters cannot build a
valid FITS card.public void addIntValue(java.lang.String key, int val, java.lang.String comment) throws HeaderCardException
key
- The header key.val
- The int value.comment
- A comment to append to the card.
HeaderCardException
- If the parameters cannot build a
valid FITS card.public void addLongValue(java.lang.String key, long val, java.lang.String comment) throws HeaderCardException
key
- The header key.val
- The long value.comment
- A comment to append to the card.
HeaderCardException
- If the parameters cannot build a
valid FITS card.public static java.lang.String formatFields(java.lang.String key, java.lang.String val, java.lang.String comment) throws HeaderCardException
key
- The header keyword.val
- The value associated with the key expressed as a string.comment
- A comment to put on the field.
HeaderCardException
- If the parameters cannot build a
valid FITS card.public void insertCard(java.lang.String card)
card
- The card to be inserted.public void insertCommentStyle(java.lang.String header, java.lang.String value) throws HeaderCardException
header
- The comment style header.value
- A string to follow the header.
HeaderCardException
- If the parameters cannot build a
valid FITS card.public void insertComment(java.lang.String value) throws HeaderCardException
value
- The comment.
HeaderCardException
- If the parameter is not a
valid FITS comment.public void insertHistory(java.lang.String value) throws HeaderCardException
value
- The history record.
HeaderCardException
- If the parameter is not a
valid FITS comment.public boolean markSet()
true
if the mark is set.public int getMark()
public void setMark(int newMark)
The
- index of the card the mark is to be set to.public void unsetMark()
public void deleteKey(java.lang.String key)
key
- The header key.public void removeCardAt(int i)
i
- The index of the card to be removed.public final boolean containsKey(java.lang.String key)
key
- the keyword to be found.
true if the specified keyword is present in this
table; false otherwise.
public void pointToData(Data o) throws FitsException
o
- The data object to be described.
FitsException
- if the data was not valid for this header.protected void pointToImage(java.lang.Object o) throws FitsException
o
- The image to be described.
FitsException
- if the object does not contain
valid image data.protected boolean primaryToImage()
protected boolean imageToPrimary()
protected void dumpHeader(java.io.PrintStream ps)
ps
- the stream to which the card images are dumped.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |