Documentation of 'com.jstatcom.parser.TSDateParser' Java class
TSDateParser
com.jstatcom.parser

Class TSDateParser

  • All Implemented Interfaces:
    TSDateParserConstants


    public class TSDateParser
    extends java.lang.Object
    implements TSDateParserConstants
    Parser that assembles TSDate objects from an input string, for example

    1960
    1960.1
    1960 I
    1960 1/4
    1960 Q4
    1960 m11

    The following rules apply for parsing:

    • XX x"/"y, for example 1960 1/1 is recognized for arbitrary sub periodicities with mainPeriod=XX, subPeriod=x, subPeriodicity=y
    • XX ["M","m"]x, for example 1960 M1 is recognized as mainPeriod=XX, subPeriod=x, subPeriodicity=12 (monthly)
    • XX ["Q","q"]x, for example 1960 Q1 is recognized as mainPeriod=XX, subPeriod=x, subPeriodicity=4 (quarterly)
    • XX ["I", "II"], for example 1960 I is recognized as mainPeriod=XX, subPeriod=1 or 2, subPeriodicity=2 (half yearly)
    • XX , for example 1960 is recognized as mainPeriod=XX, subPeriod=1, subPeriodicity=1 (yearly)
    • XX.x , for example 1960.1 is recognized as mainPeriod=XX, subPeriod=x, subPeriodicity=subPeriodicity (needs to be set as argument)

    You can use the parser via the parseString(input, subPeriodicity) method. Whenever the information about the sub periodicity is contained in the input string, it is used and the explicit argument is ignored. But it is needed for dates coded as XX.x , because there is no way to retrieve the sub periodicity from that format, although it is often used and convenient.

    The parser is completely defined in a javacc grammar definition file and can be regenerated whenever necessary.
    See Also:
    TSDate
    • Constructor Detail

      • TSDateParser

        public TSDateParser()
        Default constructor.
      • TSDateParser

        public TSDateParser(java.io.InputStream stream)
      • TSDateParser

        public TSDateParser(java.io.Reader stream)
    • Method Detail

      • disable_tracing

        public final void disable_tracing()
      • enable_tracing

        public final void enable_tracing()
      • generateParseException

        public final ParseException generateParseException()
      • getNextToken

        public final Token getNextToken()
      • getToken

        public final Token getToken(int index)
      • parseString

        public TSDate parseString(java.lang.String inputString,
                                  int subPeriodicity)
                           throws ParseException,
                                  TokenMgrError,
                                  java.lang.IllegalArgumentException
        Reinitializes this engine and parses an input String.
        Parameters:
        inputString - the String to parse
        subPeriodicity - defines number of sub periods for the parser run, the argument is ignored if the inputString contains this information, if set to <1, then the string must contain the sub periodicity
        Returns:
        TSDate object if parser and assembly where successful
        Throws:
        java.lang.IllegalArgumentException - if TSDate assembly failed due to wrong arguments
        ParseException - if parsing failed, contains error description
        TokenMgrError - if tokenizing failed, contains error description
      • ReInit

        public void ReInit(java.io.InputStream stream)
      • ReInit

        public void ReInit(java.io.Reader stream)

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.