public class CardFactory extends Object
Attempts to construct illegal FITS headers will generally provoke RuntimeExceptions.
Modifier and Type | Class and Description |
---|---|
static interface |
CardFactory.Config
CardFactory configuration.
|
Modifier and Type | Field and Description |
---|---|
static CardFactory |
CLASSIC
Instance with value trimming, bad char replacement, no HIERARCH.
|
static CardFactory |
DEFAULT
Default instance (currently
CLASSIC ). |
static CardImage |
END_CARD
CardImage for terminating header ("END").
|
static CardFactory |
HIERARCH
Instance with value trimming, bad char replacement, and HIERARCH.
|
static CardFactory |
STRICT
Instance with no value trimming, bad char rejection, no HIERARCH.
|
Constructor and Description |
---|
CardFactory(CardFactory.Config config)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
CardImage |
createCommentCard(String txt)
Constructs a COMMENT card with the given comment.
|
CardImage |
createIntegerCard(String key,
long value,
String comment)
Constructs a key-value card with integer content.
|
CardImage |
createLiteralCard(String key,
String literal,
String comment)
Constructs a key-value card with given literal text for the value part.
|
CardImage |
createLogicalCard(String key,
boolean value,
String comment)
Constructs a key-value card with logical content.
|
CardImage |
createPlainCard(String txt)
Constructs a card containing the given exact text.
|
CardImage |
createRealCard(String key,
double value,
String comment)
Constructs a key-value card with floating point content.
|
CardImage |
createStringCard(String key,
String value,
String comment)
Constructs a key-value card with string content.
|
CardFactory.Config |
getConfig()
Returns the configuration state of this factory.
|
static String |
sanitiseAsError(String txt)
Utility string sanitisation function that throws an
IllegalArgumentException if any illegal characters are present.
|
static String |
sanitiseByReplacement(String txt,
char replaceChar)
Utility string sanitisation function that replaces illegal characters
by a given char.
|
public static final CardFactory CLASSIC
public static final CardFactory HIERARCH
public static final CardFactory STRICT
public static final CardFactory DEFAULT
CLASSIC
).public static final CardImage END_CARD
public CardFactory(CardFactory.Config config)
config
- factory configurationpublic CardFactory.Config getConfig()
public CardImage createPlainCard(String txt)
txt
- literal card content, <=80 characterspublic CardImage createCommentCard(String txt)
txt
- comment textpublic CardImage createStringCard(String key, String value, String comment)
key
- header keywordvalue
- header valuecomment
- comment text, or nullpublic CardImage createIntegerCard(String key, long value, String comment)
key
- header keywordvalue
- header valuecomment
- comment text, or nullpublic CardImage createRealCard(String key, double value, String comment)
key
- header keywordvalue
- header valuecomment
- comment text, or nullpublic CardImage createLogicalCard(String key, boolean value, String comment)
key
- header keywordvalue
- header valuecomment
- comment text, or nullpublic CardImage createLiteralCard(String key, String literal, String comment)
The key must contain only legal key characters, and the literal and comment must contain only legal header characters.
key
- header keywordliteral
- formatted value textcomment
- comment text, or nullIllegalArgumentException
- if inputs are not suitable for FITSpublic static String sanitiseByReplacement(String txt, char replaceChar)
txt
- input textreplaceChar
- character to replace non-FITS characterstxt
, but with non-FITS characters
replaced by replaceChar
public static String sanitiseAsError(String txt)
txt
- input textIllegalArgumentException
- if non-FITS characters are presentCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.