com.jstatcom.parser
Class TSDateParser

java.lang.Object
  extended by com.jstatcom.parser.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:

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.

Author:
Markus Kraetzig
See Also:
TSDate

Field Summary
 Token jj_nt
           
 boolean lookingAhead
           
 Token token
           
 TSDateParserTokenManager token_source
           
 
Fields inherited from interface com.jstatcom.parser.TSDateParserConstants
DEFAULT, DELIM, DIGIT, EOF, EOL, HALFYEAR1, HALFYEAR2, INTEGER, MINUS, MONTH, QUARTER, tokenImage
 
Constructor Summary
TSDateParser()
          Default constructor.
TSDateParser(java.io.InputStream stream)
           
TSDateParser(java.io.Reader stream)
           
TSDateParser(TSDateParserTokenManager tm)
           
 
Method Summary
 void disable_tracing()
           
 void enable_tracing()
           
 ParseException generateParseException()
           
 Token getNextToken()
           
 Token getToken(int index)
           
static void main(java.lang.String[] args)
           
 TSDate parseString(java.lang.String inputString, int subPeriodicity)
          Reinitializes this engine and parses an input String.
 void ReInit(java.io.InputStream stream)
           
 void ReInit(java.io.Reader stream)
           
 void ReInit(TSDateParserTokenManager tm)
           
 int toeval(int subPeriodicity)
           
 void tsdate(int subPeriodicity)
          Possible date formats.
 void tsdefault()
          Default 1960 1/4.
 void tshalfyearly()
          Half-Yearly 1960 II.
 void tsmonthly()
          Monthly 1960 M11.
 void tsquarterly()
          Quarterly 1960 Q3.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public TSDateParserTokenManager token_source

token

public Token token

jj_nt

public Token jj_nt

lookingAhead

public boolean lookingAhead
Constructor Detail

TSDateParser

public TSDateParser()
Default constructor.


TSDateParser

public TSDateParser(TSDateParserTokenManager tm)

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)

main

public static void main(java.lang.String[] args)
                 throws ParseException
Throws:
ParseException

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(TSDateParserTokenManager tm)

ReInit

public void ReInit(java.io.InputStream stream)

ReInit

public void ReInit(java.io.Reader stream)

toeval

public final int toeval(int subPeriodicity)
                 throws ParseException
Throws:
ParseException

tsdate

public final void tsdate(int subPeriodicity)
                  throws ParseException
Possible date formats.

Throws:
ParseException

tsdefault

public final void tsdefault()
                     throws ParseException
Default 1960 1/4.

Throws:
ParseException

tshalfyearly

public final void tshalfyearly()
                        throws ParseException
Half-Yearly 1960 II.

Throws:
ParseException

tsmonthly

public final void tsmonthly()
                     throws ParseException
Monthly 1960 M11.

Throws:
ParseException

tsquarterly

public final void tsquarterly()
                       throws ParseException
Quarterly 1960 Q3.

Throws:
ParseException