Package nom.tam.fits.utilities
Class FitsHeaderCardParser
java.lang.Object
nom.tam.fits.utilities.FitsHeaderCardParser
A helper utility class to parse header cards for there value (especially
strings) and comments.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
value comment pair of the header card. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
utility class will not be instantiated. -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
deleteQuotes
(String quotedString) delete the start and trailing quote from the sting and replace all (escaped)double quotes with a single quote.private static String
extractComment
(String stringCard, int startPosition) get the not empty comment string from the end of the card.static String
parseCardKey
(String card) parse a fits keyword from a card and return it as a dot separated list.parseCardValue
(String card) Parse the card for a value and comment.private static FitsHeaderCardParser.ParsedValue
parseStringValue
(String card) lets see if there is a quoted sting in the card.
-
Field Details
-
KEYWORD_PATTERN
pattern to match FITS keywords, specially to parse hirarchical keywords. -
STRING_PATTERN
pattern to match a quoted string where 2 quotes are used to escape a single quote inside the string. Attention this patern ist optimized as specified in http://www.perlmonks.org/?node_id=607740
-
-
Constructor Details
-
FitsHeaderCardParser
private FitsHeaderCardParser()utility class will not be instantiated.
-
-
Method Details
-
deleteQuotes
delete the start and trailing quote from the sting and replace all (escaped)double quotes with a single quote. Then trim the trailing blanks.- Parameters:
quotedString
- the string to un-quote.- Returns:
- the unquoted string
-
extractComment
get the not empty comment string from the end of the card. start scanning from the end of the value.- Parameters:
stringCard
- the string representing the cardstartPosition
- the start point for the scan- Returns:
- the not empty comment or null if no comment was found.
-
parseCardKey
parse a fits keyword from a card and return it as a dot separated list.- Parameters:
card
- the card to parse.- Returns:
- dot separated key list
-
parseCardValue
Parse the card for a value and comment. Quoted string values are unquoted and theFitsHeaderCardParser.ParsedValue.isString
specifies if the value was a quoted string. non quoted values are trimmed.- Parameters:
card
- the card to parse.- Returns:
- a parsed card or null if no value could be detected.
-
parseStringValue
lets see if there is a quoted sting in the card.- Parameters:
card
- the card string to parse.- Returns:
- the parsed value with the unquoted string or null if no quoted string was found.
-