visad.data.units
Class UnitParser

java.lang.Object
  extended by visad.data.units.UnitParser
All Implemented Interfaces:
UnitParserConstants
Direct Known Subclasses:
UnitParser

public class UnitParser
extends Object
implements UnitParserConstants

A class for parsing string unit specifications. Instances are thread-compatible but not thread-safe.


Field Summary
 Token jj_nt
          Next token.
protected static long julianDayOrigin
          The Julian day number of the (artificial) time origin.
protected static Unit SECOND
          The canonical time unit.
 Token token
          Current token.
 UnitParserTokenManager token_source
          Generated Token Manager.
protected static UnitsDB unitsDB
          The units database.
 
Fields inherited from interface visad.data.units.UnitParserConstants
COLON, DEFAULT, DIVIDE, EOF, LB, LETTER, LG, LN, LPAREN, MINUS, NAME, PERIOD, PLUS, RAISE, REAL_EXP, RPAREN, SHIFT, SIGN, SP, STAR, SYMBOL, T, tokenImage, UINT, UTC
 
Constructor Summary
UnitParser(InputStream stream)
          Constructor with InputStream.
UnitParser(InputStream stream, String encoding)
          Constructor with InputStream and supplied encoding
UnitParser(Reader stream)
          Constructor.
UnitParser(UnitParserTokenManager tm)
          Constructor with generated Token Manager.
 
Method Summary
 Unit basicExpr()
           
 Calendar clockExpr(Calendar calendar)
           
 Calendar dateExpr()
           
 void disable_tracing()
          Disable tracing.
 void enable_tracing()
          Enable tracing.
static double encodeTimestamp(int year, int month, int day, int hour, int minute, float second, int zone)
          Encode a timestamp as a double value in units of seconds.
 ParseException generateParseException()
          Generate ParseException.
 Token getNextToken()
          Get the next Token.
 Token getToken(int index)
          Get the specific Token.
 int integer()
           
static long julianDay(int year, int month, int day)
          Compute the Julian day number of a date.
 Unit logExpr()
           
static void main(String[] args)
          Test this class.
 double number()
           
 Unit parse(String spec)
          Parses a string unit specification.
 Unit powerExpr()
           
 Unit productExpr()
           
 double real()
           
 void ReInit(InputStream stream)
          Reinitialise.
 void ReInit(InputStream stream, String encoding)
          Reinitialise.
 void ReInit(Reader stream)
          Reinitialise.
 void ReInit(UnitParserTokenManager tm)
          Reinitialise.
 Unit shiftExpr()
           
 int sign()
           
 double tenFactor()
           
 double timeOriginExpr()
           
 Unit unitIdentifier()
           
 Unit unitSpec()
           
 double unsignedDecimal()
           
 int unsignedInteger()
           
 Calendar zoneExpr(Calendar calendar)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unitsDB

protected static UnitsDB unitsDB
The units database.


SECOND

protected static final Unit SECOND
The canonical time unit.


julianDayOrigin

protected static final long julianDayOrigin
The Julian day number of the (artificial) time origin.


token_source

public UnitParserTokenManager token_source
Generated Token Manager.


token

public Token token
Current token.


jj_nt

public Token jj_nt
Next token.

Constructor Detail

UnitParser

public UnitParser(InputStream stream)
Constructor with InputStream.


UnitParser

public UnitParser(InputStream stream,
                  String encoding)
Constructor with InputStream and supplied encoding


UnitParser

public UnitParser(Reader stream)
Constructor.


UnitParser

public UnitParser(UnitParserTokenManager tm)
Constructor with generated Token Manager.

Method Detail

julianDay

public static long julianDay(int year,
                             int month,
                             int day)
Compute the Julian day number of a date.


encodeTimestamp

public static double encodeTimestamp(int year,
                                     int month,
                                     int day,
                                     int hour,
                                     int minute,
                                     float second,
                                     int zone)
Encode a timestamp as a double value in units of seconds.


parse

public Unit parse(String spec)
           throws ParseException,
                  UnitException
Parses a string unit specification.

Parameters:
spec - The unit specification.
Returns:
A Unit corresponding to spec.
Throws:
NullPointerException - if spec is null.
ParseException - if a parsing error occurred.
UnitException - if the string specifies an invalid unit operation.

main

public static void main(String[] args)
                 throws Exception
Test this class.

Throws:
Exception

unitSpec

public final Unit unitSpec()
                    throws ParseException,
                           UnitException
Throws:
ParseException
UnitException

shiftExpr

public final Unit shiftExpr()
                     throws ParseException,
                            UnitException
Throws:
ParseException
UnitException

productExpr

public final Unit productExpr()
                       throws ParseException,
                              UnitException
Throws:
ParseException
UnitException

powerExpr

public final Unit powerExpr()
                     throws ParseException,
                            UnitException
Throws:
ParseException
UnitException

basicExpr

public final Unit basicExpr()
                     throws ParseException,
                            UnitException
Throws:
ParseException
UnitException

unitIdentifier

public final Unit unitIdentifier()
                          throws ParseException
Throws:
ParseException

logExpr

public final Unit logExpr()
                   throws ParseException,
                          UnitException
Throws:
ParseException
UnitException

number

public final double number()
                    throws ParseException
Throws:
ParseException

real

public final double real()
                  throws ParseException
Throws:
ParseException

sign

public final int sign()
               throws ParseException
Throws:
ParseException

unsignedDecimal

public final double unsignedDecimal()
                             throws ParseException
Throws:
ParseException

tenFactor

public final double tenFactor()
                       throws ParseException
Throws:
ParseException

integer

public final int integer()
                  throws ParseException
Throws:
ParseException

unsignedInteger

public final int unsignedInteger()
                          throws ParseException
Throws:
ParseException

timeOriginExpr

public final double timeOriginExpr()
                            throws ParseException
Throws:
ParseException

dateExpr

public final Calendar dateExpr()
                        throws ParseException
Throws:
ParseException

clockExpr

public final Calendar clockExpr(Calendar calendar)
                         throws ParseException
Throws:
ParseException

zoneExpr

public final Calendar zoneExpr(Calendar calendar)
                        throws ParseException
Throws:
ParseException

ReInit

public void ReInit(InputStream stream)
Reinitialise.


ReInit

public void ReInit(InputStream stream,
                   String encoding)
Reinitialise.


ReInit

public void ReInit(Reader stream)
Reinitialise.


ReInit

public void ReInit(UnitParserTokenManager tm)
Reinitialise.


getNextToken

public final Token getNextToken()
Get the next Token.


getToken

public final Token getToken(int index)
Get the specific Token.


generateParseException

public ParseException generateParseException()
Generate ParseException.


enable_tracing

public final void enable_tracing()
Enable tracing.


disable_tracing

public final void disable_tracing()
Disable tracing.