Package uk.ac.starlink.fits
Class CardFactory
- java.lang.Object
-
- uk.ac.starlink.fits.CardFactory
-
public class CardFactory extends java.lang.ObjectCreates FITS CardImages suitable for writing to a FITS header. Different factory instances are available with variant options for header construction.Attempts to construct illegal FITS headers will generally provoke RuntimeExceptions.
- Since:
- 4 Mar 2022
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCardFactory.ConfigCardFactory configuration.
-
Field Summary
Fields Modifier and Type Field Description static CardFactoryCLASSICInstance with silent value trimming and no HIERARCH.static CardFactoryDEFAULTDefault instance.static CardImageEND_CARDCardImage for terminating header ("END").static CardFactoryHIERARCHInstance with value trimming and HIERARCH support.static CardFactorySTRICTInstance with no value trimming and no HIERARCH.
-
Constructor Summary
Constructors Constructor Description CardFactory(CardFactory.Config config)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CardImagecreateCommentCard(java.lang.String txt)Constructs a COMMENT card with the given comment.CardImagecreateIntegerCard(java.lang.String key, long value, java.lang.String comment)Constructs a key-value card with integer content.CardImagecreateLiteralCard(java.lang.String key, java.lang.String literal, java.lang.String comment)Constructs a key-value card with given literal text for the value part.CardImagecreateLogicalCard(java.lang.String key, boolean value, java.lang.String comment)Constructs a key-value card with logical contentCardImagecreatePlainCard(java.lang.String txt)Constructs a card containing the given exact text.CardImagecreateRealCard(java.lang.String key, double value, java.lang.String comment)Constructs a key-value card with floating point content.CardImagecreateStringCard(java.lang.String key, java.lang.String value, java.lang.String comment)Constructs a key-value card with string content.CardFactory.ConfiggetConfig()Returns the configuration state of this factory.
-
-
-
Field Detail
-
CLASSIC
public static final CardFactory CLASSIC
Instance with silent value trimming and no HIERARCH.
-
HIERARCH
public static final CardFactory HIERARCH
Instance with value trimming and HIERARCH support.
-
STRICT
public static final CardFactory STRICT
Instance with no value trimming and no HIERARCH.
-
DEFAULT
public static final CardFactory DEFAULT
Default instance.
-
END_CARD
public static final CardImage END_CARD
CardImage for terminating header ("END").
-
-
Constructor Detail
-
CardFactory
public CardFactory(CardFactory.Config config)
Constructor.- Parameters:
config- factory configuration
-
-
Method Detail
-
getConfig
public CardFactory.Config getConfig()
Returns the configuration state of this factory.- Returns:
- config object
-
createPlainCard
public CardImage createPlainCard(java.lang.String txt)
Constructs a card containing the given exact text. It is padded with spaces if necessary.- Parameters:
txt- literal card content, <=80 characters- Returns:
- new card
-
createCommentCard
public CardImage createCommentCard(java.lang.String txt)
Constructs a COMMENT card with the given comment. May be trimmed if too long according to policy.- Parameters:
txt- comment text- Returns:
- new card
-
createStringCard
public CardImage createStringCard(java.lang.String key, java.lang.String value, java.lang.String comment)
Constructs a key-value card with string content. The value may be trimmed if too long according to policy.- Parameters:
key- header keywordvalue- header valuecomment- comment text, or null- Returns:
- new card
-
createIntegerCard
public CardImage createIntegerCard(java.lang.String key, long value, java.lang.String comment)
Constructs a key-value card with integer content.- Parameters:
key- header keywordvalue- header valuecomment- comment text, or null- Returns:
- new card
-
createRealCard
public CardImage createRealCard(java.lang.String key, double value, java.lang.String comment)
Constructs a key-value card with floating point content.- Parameters:
key- header keywordvalue- header valuecomment- comment text, or null- Returns:
- new card
-
createLogicalCard
public CardImage createLogicalCard(java.lang.String key, boolean value, java.lang.String comment)
Constructs a key-value card with logical content- Parameters:
key- header keywordvalue- header valuecomment- comment text, or null- Returns:
- new card
-
createLiteralCard
public CardImage createLiteralCard(java.lang.String key, java.lang.String literal, java.lang.String comment)
Constructs a key-value card with given literal text for the value part. No additional quoting or escaping is performed on the provided string, but it may be trimmed in a string-sensitive way according to policy.- Parameters:
key- header keywordliteral- formatted value textcomment- comment text, or null- Returns:
- new card
-
-