visad.data.units
Class UnitParser
- java.lang.Object
-
- visad.data.units.UnitParser
-
- All Implemented Interfaces:
- UnitParserConstants
- Direct Known Subclasses:
- UnitParser
public class UnitParser extends java.lang.Object implements UnitParserConstants
A class for parsing string unit specifications. Instances are thread-compatible but not thread-safe.
-
-
Field Summary
Fields Modifier and Type Field and Description Tokenjj_ntNext token.TokentokenCurrent token.UnitParserTokenManagertoken_sourceGenerated Token Manager.
-
Constructor Summary
Constructors Constructor and Description UnitParser(java.io.InputStream stream)Constructor with InputStream.UnitParser(java.io.InputStream stream, java.lang.String encoding)Constructor with InputStream and supplied encodingUnitParser(java.io.Reader stream)Constructor.UnitParser(UnitParserTokenManager tm)Constructor with generated Token Manager.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description UnitbasicExpr()java.util.CalendarclockExpr(java.util.Calendar calendar)java.util.CalendardateExpr()voiddisable_tracing()Disable tracing.voidenable_tracing()Enable tracing.static doubleencodeTimestamp(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.ParseExceptiongenerateParseException()Generate ParseException.TokengetNextToken()Get the next Token.TokengetToken(int index)Get the specific Token.intinteger()static longjulianDay(int year, int month, int day)Compute the Julian day number of a date.UnitlogExpr()static voidmain(java.lang.String[] args)Test this class.doublenumber()Unitparse(java.lang.String spec)Parses a string unit specification.UnitpowerExpr()UnitproductExpr()doublereal()voidReInit(java.io.InputStream stream)Reinitialise.voidReInit(java.io.InputStream stream, java.lang.String encoding)Reinitialise.voidReInit(java.io.Reader stream)Reinitialise.voidReInit(UnitParserTokenManager tm)Reinitialise.UnitshiftExpr()intsign()doubletenFactor()doubletimeOriginExpr()UnitunitIdentifier()UnitunitSpec()doubleunsignedDecimal()intunsignedInteger()java.util.CalendarzoneExpr(java.util.Calendar calendar)
-
-
-
Field Detail
-
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(java.io.InputStream stream)
Constructor with InputStream.
-
UnitParser
public UnitParser(java.io.InputStream stream, java.lang.String encoding)Constructor with InputStream and supplied encoding
-
UnitParser
public UnitParser(java.io.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(java.lang.String spec) throws ParseException, UnitException
Parses a string unit specification.- Parameters:
spec- The unit specification.- Returns:
- A
Unitcorresponding tospec. - Throws:
java.lang.NullPointerException- ifspecisnull.ParseException- if a parsing error occurred.UnitException- if the string specifies an invalid unit operation.
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionTest this class.- Throws:
java.lang.Exception
-
unitSpec
public final Unit unitSpec() throws ParseException, UnitException
- Throws:
ParseExceptionUnitException
-
shiftExpr
public final Unit shiftExpr() throws ParseException, UnitException
- Throws:
ParseExceptionUnitException
-
productExpr
public final Unit productExpr() throws ParseException, UnitException
- Throws:
ParseExceptionUnitException
-
powerExpr
public final Unit powerExpr() throws ParseException, UnitException
- Throws:
ParseExceptionUnitException
-
basicExpr
public final Unit basicExpr() throws ParseException, UnitException
- Throws:
ParseExceptionUnitException
-
unitIdentifier
public final Unit unitIdentifier() throws ParseException
- Throws:
ParseException
-
logExpr
public final Unit logExpr() throws ParseException, UnitException
- Throws:
ParseExceptionUnitException
-
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 java.util.Calendar dateExpr() throws ParseException- Throws:
ParseException
-
clockExpr
public final java.util.Calendar clockExpr(java.util.Calendar calendar) throws ParseException- Throws:
ParseException
-
zoneExpr
public final java.util.Calendar zoneExpr(java.util.Calendar calendar) throws ParseException- Throws:
ParseException
-
ReInit
public void ReInit(java.io.InputStream stream)
Reinitialise.
-
ReInit
public void ReInit(java.io.InputStream stream, java.lang.String encoding)Reinitialise.
-
ReInit
public void ReInit(java.io.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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG