Package nom.tam.fits
Class HeaderCard
java.lang.Object
nom.tam.fits.HeaderCard
- All Implemented Interfaces:
CursorValue<String>
This class describes methods to access and manipulate the individual cards
for a FITS Header.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
Maximum length of a FITS keyword fieldstatic final int
the start and end quotes of the string and the ampasant to continue the string.static final int
Maximum length of a FITS long string value field.static final int
if a commend needs the be specified 2 extra chars are needed to start the commentstatic final int
Maximum length of a FITS string value field.static final int
Maximum length of a FITS value field. -
Constructor Summary
ConstructorsConstructorDescriptionHeaderCard
(String key, boolean value, String comment) Create a HeaderCard from its component partsHeaderCard
(String key, double value, int precision, String comment) Create a HeaderCard from its component partsHeaderCard
(String key, double value, String comment) Create a HeaderCard from its component partsHeaderCard
(String key, float value, int precision, String comment) Create a HeaderCard from its component partsHeaderCard
(String key, float value, String comment) Create a HeaderCard from its component partsHeaderCard
(String key, int value, String comment) Create a HeaderCard from its component partsHeaderCard
(String key, long value, String comment) Create a HeaderCard from its component partsHeaderCard
(String key, String comment, boolean nullable) Create a comment style card.HeaderCard
(String key, String value, String comment) Create a HeaderCard from its component partsHeaderCard
(String key, String value, String comment, boolean nullable) Create a HeaderCard from its component partsHeaderCard
(String key, BigDecimal value, String comment) Create a HeaderCard from its component partsHeaderCard
(String key, BigInteger value, String comment) Create a HeaderCard from its component partsHeaderCard
(ArrayDataInput dis) -
Method Summary
Modifier and TypeMethodDescriptionint
cardSize()
copy()
static HeaderCard
getKey()
getValue()
<T> T
boolean
boolean
protected static HeaderCard
saveNewHeaderCard
(String key, String comment, boolean isString) This method is only used internally when it is sure that the creation of the card is granted not to throw an exceptionvoid
setComment
(String comment) set the comment of a card.setValue
(boolean update) Set the value for this card.setValue
(double update) Set the value for this card.setValue
(double update, int precision) Set the value for this card.setValue
(float update) Set the value for this card.setValue
(float update, int precision) Set the value for this card.setValue
(int update) Set the value for this card.setValue
(long update) Set the value for this card.Set the value for this card.setValue
(BigDecimal update) Set the value for this card.toString()
Return the modulo 80 character card image, the toString tries to preserve as much as possible of the comment value by reducing the alignment of the Strings if the comment is longer and if longString is enabled the string can be split into one more card to have more space for the comment.protected String
toString
(FitsFactory.FitsSettings settings) Same astoString()
just with a prefetched settings objectClass
<?>
-
Field Details
-
FITS_HEADER_CARD_SIZE
public static final int FITS_HEADER_CARD_SIZE- See Also:
-
MAX_KEYWORD_LENGTH
public static final int MAX_KEYWORD_LENGTHMaximum length of a FITS keyword field- See Also:
-
MAX_LONG_STRING_CONTINUE_OVERHEAD
public static final int MAX_LONG_STRING_CONTINUE_OVERHEADthe start and end quotes of the string and the ampasant to continue the string.- See Also:
-
MAX_LONG_STRING_VALUE_LENGTH
public static final int MAX_LONG_STRING_VALUE_LENGTHMaximum length of a FITS long string value field. the & for the continuation needs one char.- See Also:
-
MAX_LONG_STRING_VALUE_WITH_COMMENT_LENGTH
public static final int MAX_LONG_STRING_VALUE_WITH_COMMENT_LENGTHif a commend needs the be specified 2 extra chars are needed to start the comment- See Also:
-
MAX_STRING_VALUE_LENGTH
public static final int MAX_STRING_VALUE_LENGTHMaximum length of a FITS string value field.- See Also:
-
MAX_VALUE_LENGTH
public static final int MAX_VALUE_LENGTHMaximum length of a FITS value field.- See Also:
-
-
Constructor Details
-
HeaderCard
- Throws:
TruncatedFileException
IOException
-
HeaderCard
- Throws:
TruncatedFileException
IOException
-
HeaderCard
Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')comment
- comment- Throws:
HeaderCardException
- for any invalid keyword
-
HeaderCard
Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')comment
- comment- Throws:
HeaderCardException
- for any invalid keyword
-
HeaderCard
Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')comment
- comment- Throws:
HeaderCardException
- for any invalid keyword
-
HeaderCard
public HeaderCard(String key, double value, int precision, String comment) throws HeaderCardException Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')precision
- Number of decimal places (fixed format).comment
- comment- Throws:
HeaderCardException
- for any invalid keyword
-
HeaderCard
Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')comment
- comment- Throws:
HeaderCardException
- for any invalid keyword
-
HeaderCard
public HeaderCard(String key, float value, int precision, String comment) throws HeaderCardException Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')precision
- Number of decimal places (fixed format).comment
- comment- Throws:
HeaderCardException
- for any invalid keyword
-
HeaderCard
Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')comment
- comment- Throws:
HeaderCardException
- for any invalid keyword
-
HeaderCard
Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')comment
- comment- Throws:
HeaderCardException
- for any invalid keyword
-
HeaderCard
Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')comment
- comment- Throws:
HeaderCardException
- for any invalid keyword
-
HeaderCard
Create a comment style card. This constructor builds a card which has no value. This may be either a comment style card in which case the nullable field should be false, or a value field which has a null value, in which case the nullable field should be true.- Parameters:
key
- The key for the comment or nullable field.comment
- The commentnullable
- Is this a nullable field or a comment-style card?- Throws:
HeaderCardException
- for any invalid keyword or value
-
HeaderCard
Create a HeaderCard from its component parts- Parameters:
key
- keyword (null for a comment)value
- value (null for a comment or keyword without an '=')comment
- comment- Throws:
HeaderCardException
- for any invalid keyword or value
-
HeaderCard
public HeaderCard(String key, String value, String comment, boolean nullable) throws HeaderCardException Create a HeaderCard from its component parts- Parameters:
key
- Keyword (null for a COMMENT)value
- Valuecomment
- Commentnullable
- Is this a nullable value card?- Throws:
HeaderCardException
- for any invalid keyword or value
-
-
Method Details
-
create
- Parameters:
card
- the 80 character card image- Returns:
- a created HeaderCard from a FITS card string.
-
saveNewHeaderCard
This method is only used internally when it is sure that the creation of the card is granted not to throw an exception- Parameters:
key
- the key for the cardcomment
- the comment for the cardisString
- is this a string value card?- Returns:
- the new HeaderCard
-
cardSize
public int cardSize()- Returns:
- the size of the card in blocks of 80 bytes. So normally every card will return 1. only long stings can return more than one.
-
copy
- Throws:
HeaderCardException
-
getComment
- Returns:
- the comment from this card
-
getKey
- Specified by:
getKey
in interfaceCursorValue<String>
- Returns:
- the keyword from this card
-
getValue
- Returns:
- the value from this card
-
getValue
- Type Parameters:
T
- the type of the requested class- Parameters:
clazz
- the requested class of the valuedefaultValue
- the value if the card was not present.- Returns:
- the value from this card as a specific type
-
isKeyValuePair
public boolean isKeyValuePair()- Returns:
- Is this a key/value card?
-
isStringValue
public boolean isStringValue()- Returns:
- if this card contain does a string value?
-
setComment
set the comment of a card.- Parameters:
comment
- the comment to set.
-
setValue
Set the value for this card.- Parameters:
update
- the new value to set- Returns:
- the HeaderCard itself
-
setValue
Set the value for this card.- Parameters:
update
- the new value to set- Returns:
- the HeaderCard itself
-
setValue
Set the value for this card.- Parameters:
update
- the new value to set- Returns:
- the HeaderCard itself
-
setValue
Set the value for this card.- Parameters:
update
- the new value to setprecision
- the number of decimal places to show- Returns:
- the HeaderCard itself
-
setValue
Set the value for this card.- Parameters:
update
- the new value to set- Returns:
- the HeaderCard itself
-
setValue
Set the value for this card.- Parameters:
update
- the new value to setprecision
- the number of decimal places to show- Returns:
- the HeaderCard itself
-
setValue
Set the value for this card.- Parameters:
update
- the new value to set- Returns:
- the HeaderCard itself
-
setValue
Set the value for this card.- Parameters:
update
- the new value to set- Returns:
- the HeaderCard itself
-
setValue
Set the value for this card.- Parameters:
update
- the new value to set- Returns:
- the HeaderCard itself
-
toString
Return the modulo 80 character card image, the toString tries to preserve as much as possible of the comment value by reducing the alignment of the Strings if the comment is longer and if longString is enabled the string can be split into one more card to have more space for the comment. -
toString
Same astoString()
just with a prefetched settings object- Parameters:
settings
- the settings to use for writing the header card- Returns:
- the string representing the card.
-
valueType
- Returns:
- the type of the value.
-