public class Header extends Object implements FitsElement
Constructor and Description |
---|
Header()
Create an empty header
|
Header(ArrayDataInput is)
Create a header and populate it from the input stream
|
Header(Data o)
Create a header which points to the
given data object.
|
Header(String[] newCards)
Create a header and initialize it with a vector of strings.
|
Modifier and Type | Method and Description |
---|---|
void |
addLine(HeaderCard fcard)
Add a card image to the header.
|
protected void |
addLine(String card)
Add a card image to the header.
|
void |
addValue(String key,
boolean val,
String comment)
Add or replace a key with the given boolean value and comment.
|
void |
addValue(String key,
double val,
String comment)
Add or replace a key with the given double value and comment.
|
void |
addValue(String key,
long val,
String comment)
Add or replace a key with the given long value and comment.
|
void |
addValue(String key,
String val,
String comment)
Add or replace a key with the given string value and comment.
|
boolean |
containsKey(String key)
Tests if the specified keyword is present in this table.
|
void |
deleteKey(String key)
Delete the card associated with the given key.
|
protected void |
dumpHeader(PrintStream ps)
Print the header to a given stream.
|
HeaderCard |
findCard(String key)
Find the card associated with a given key.
|
String |
findKey(String key)
Find the card associated with a given key.
|
boolean |
getBooleanValue(String key)
Get the
boolean value associated with the given key. |
boolean |
getBooleanValue(String key,
boolean dft)
Get the
boolean value associated with the given key. |
String |
getCard(int n)
Deprecated.
An iterator should be used for sequential
access to the header.
|
long |
getDataSize()
Return the size of the data including any needed padding.
|
double |
getDoubleValue(String key)
Get the
double value associated with the given key. |
double |
getDoubleValue(String key,
double dft)
Get the
double value associated with the given key. |
long |
getFileOffset()
Get the offset of this header
|
float |
getFloatValue(String key)
Get the
float value associated with the given key. |
float |
getFloatValue(String key,
float dft)
Get the
float value associated with the given key. |
int |
getIntValue(String key)
Get the
int value associated with the given key. |
int |
getIntValue(String key,
int dft)
Get the value associated with the key as an int.
|
String |
getKey(int n)
Deprecated.
An iterator should be used for sequential
access to the header.
|
long |
getLongValue(String key)
Get the
long value associated with the given key. |
long |
getLongValue(String key,
long dft)
Get the
long value associated with the given key. |
int |
getNumberOfCards()
Find the number of cards in the header
|
long |
getSize()
Get the size of the header in bytes
|
String |
getStringValue(String key)
Get the
String value associated with the given key. |
void |
insertComment(String value)
Add a COMMENT line.
|
void |
insertCommentStyle(String header,
String value)
Add a line to the header using the COMMENT style, i.e., no '='
in column 9.
|
void |
insertHistory(String value)
Add a HISTORY line.
|
Cursor |
iterator()
Get an iterator over the header cards
|
Data |
makeData()
Create the data element corresponding to the current header
|
void |
pointToData(Data o)
Deprecated.
Use the appropriate Header constructor.
|
void |
read(ArrayDataInput dis)
Read a stream for header data.
|
static Header |
readHeader(ArrayDataInput dis)
Create a header by reading the information from the input stream.
|
void |
removeCard(String key)
Add or replace a key using the preformatted value.
|
void |
rewrite()
Rewrite the header.
|
boolean |
rewriteable()
Can the header be rewritten without rewriting the entire file?
|
void |
setBitpix(int val)
Set the BITPIX value for the header.
|
void |
setHeaderSorter(Comparator<String> headerSorter)
Matches a method introduced in v1.15.2 of nom.tam.fits,
so this method can be called harmlessly in that or this version.
|
void |
setNaxes(int val)
Set the value of the NAXIS keyword
|
void |
setNaxis(int axis,
int dim)
Set the dimension for a given axis.
|
void |
setSimple(boolean val)
Set the SIMPLE keyword to the given value.
|
void |
setXtension(String val)
Set the XTENSION keyword to the given value.
|
int |
size()
Deprecated.
see numberOfCards(). The units
of the size of the header may be unclear.
|
void |
write(ArrayDataOutput dos)
Write the current header (including any needed padding) to the
output stream.
|
public Header()
public Header(ArrayDataInput is) throws TruncatedFileException, IOException
is
- The input stream where header information is expected.TruncatedFileException
IOException
public Header(String[] newCards)
cards
- Card images to be placed in the header.public Header(Data o) throws FitsException
o
- The data object to be described.FitsException
- if the data was not valid for this header.public Data makeData() throws FitsException
FitsException
public int getNumberOfCards()
public Cursor iterator()
public long getFileOffset()
getFileOffset
in interface FitsElement
public long getDataSize()
public long getSize()
getSize
in interface FitsElement
public HeaderCard findCard(String key)
key
- The header key.null
if the keyword could not be found;
return the HeaderCard object otherwise.public int getIntValue(String key, int dft)
key
- The header key.dft
- The value to be returned if the key is not found.public int getIntValue(String key)
int
value associated with the given key.key
- The header key.public long getLongValue(String key)
long
value associated with the given key.key
- The header key.public long getLongValue(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 float getFloatValue(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(String key)
float
value associated with the given key.key
- The header key.public double getDoubleValue(String key)
double
value associated with the given key.key
- The header key.public double getDoubleValue(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(String key)
boolean
value associated with the given key.The
- header key.public boolean getBooleanValue(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 String getStringValue(String key)
String
value associated with the given key.key
- The header key.public void addLine(HeaderCard fcard)
fcard
- The card to be added.protected void addLine(String card) throws HeaderCardException
card
- The card to be added.HeaderCardException
- If the card is not valid.public static Header readHeader(ArrayDataInput dis) throws TruncatedFileException, 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
IOException
public void read(ArrayDataInput dis) throws TruncatedFileException, IOException
read
in interface FitsElement
dis
- The input stream to read the data from.TruncatedFileException
IOException
public String findKey(String key)
key
- The header key.null
if the keyword could not be found;
return the card image otherwise.public void write(ArrayDataOutput dos) throws FitsException
write
in interface FitsElement
dos
- The output stream to which the data is to be written.FitsException
- if the header could not be written.public void rewrite() throws FitsException, IOException
rewrite
in interface FitsElement
FitsException
IOException
public boolean rewriteable()
rewriteable
in interface FitsElement
public void addValue(String key, boolean val, 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 addValue(String key, double val, 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 addValue(String key, String val, 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 addValue(String key, long val, 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 void removeCard(String key) 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 insertCommentStyle(String header, String value)
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(String value) throws HeaderCardException
value
- The comment.HeaderCardException
- If the parameter is not a
valid FITS comment.public void insertHistory(String value) throws HeaderCardException
value
- The history record.HeaderCardException
- If the parameter is not a
valid FITS comment.public void deleteKey(String key)
key
- The header key.public final boolean containsKey(String key)
key
- the keyword to be found.true if the specified keyword is present in this
table; false otherwise.
public void setSimple(boolean val)
val
- The boolean value -- Should be true for FITS data.public void setXtension(String val)
val
- The name of the extension. "IMAGE" and "BINTABLE" are supported.public void setBitpix(int val)
val.
- The following values are permitted by FITS conventions:
public void setNaxes(int val)
val
- The dimensionality of the data.public void setNaxis(int axis, int dim)
axis
- The axis being set.dim
- The dimensionprotected void dumpHeader(PrintStream ps)
ps
- the stream to which the card images are dumped.public int size()
public String getCard(int n)
null
if the n'th card
does not exist.public String getKey(int n)
null
if the n'th key
does not exist.public void pointToData(Data o) throws FitsException
o
- The data object to be described.FitsException
- if the data was not valid for this header.public void setHeaderSorter(Comparator<String> headerSorter)
headerSorter
- must be nullIllegalArgumentException
- for non-null headerSorterCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.