Class FitsHeaderCardParser


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

      Fields 
      Modifier and Type Field Description
      private static java.util.regex.Pattern KEYWORD_PATTERN
      pattern to match FITS keywords, specially to parse hirarchical keywords.
      private static java.util.regex.Pattern STRING_PATTERN
      pattern to match a quoted string where 2 quotes are used to escape a single quote inside the string.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FitsHeaderCardParser()
      utility class will not be instantiated.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String deleteQuotes​(java.lang.String quotedString)
      delete the start and trailing quote from the sting and replace all (escaped)double quotes with a single quote.
      private static java.lang.String extractComment​(java.lang.String stringCard, int startPosition)
      get the not empty comment string from the end of the card.
      static java.lang.String parseCardKey​(java.lang.String card)
      parse a fits keyword from a card and return it as a dot separated list.
      static FitsHeaderCardParser.ParsedValue parseCardValue​(java.lang.String card)
      Parse the card for a value and comment.
      private static FitsHeaderCardParser.ParsedValue parseStringValue​(java.lang.String card)
      lets see if there is a quoted sting in the card.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • KEYWORD_PATTERN

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

        private static final java.util.regex.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 Detail

      • FitsHeaderCardParser

        private FitsHeaderCardParser()
        utility class will not be instantiated.
    • Method Detail

      • deleteQuotes

        private static java.lang.String deleteQuotes​(java.lang.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 java.lang.String extractComment​(java.lang.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 java.lang.String parseCardKey​(java.lang.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​(java.lang.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​(java.lang.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.