Class FitsHeaderCardParser

java.lang.Object
nom.tam.fits.utilities.FitsHeaderCardParser

public final class FitsHeaderCardParser extends Object
A helper utility class to parse header cards for there value (especially strings) and comments.
  • Field Details

    • KEYWORD_PATTERN

      private static final Pattern KEYWORD_PATTERN
      pattern to match FITS keywords, specially to parse hirarchical keywords.
    • STRING_PATTERN

      private static final Pattern 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

      private static String deleteQuotes(String quotedString)
      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

      private static String extractComment(String stringCard, int startPosition)
      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 card
      startPosition - the start point for the scan
      Returns:
      the not empty comment or null if no comment was found.
    • parseCardKey

      public static String parseCardKey(String card)
      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

      public static FitsHeaderCardParser.ParsedValue parseCardValue(String card)
      Parse the card for a value and comment. Quoted string values are unquoted and the FitsHeaderCardParser.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

      private static FitsHeaderCardParser.ParsedValue parseStringValue(String card)
      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.