|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.me.nxg.unity.UnitParser
public class UnitParser
A parser for unit strings. The parser will parse a single string.
There are a number of different parsers available:
http://cdsweb.u-strasbg.fr/doc/catstd-3.2.htx
See the uk.me.nxg.unity
package documentation for fuller discussion of the grammars.
Nested Class Summary | |
---|---|
static class |
UnitParser.Lexeme
A single lexeme. |
Field Summary | |
---|---|
static String |
CDS
Indicates the parser for CDS-format strings |
static String |
FITS
Indicates the parser for FITS-format strings |
static String |
LATEX
Indicates the formatter (not parser) for LaTeX/siunitx output |
static String |
OGIP
Indicates the parser for OGIP-format strings |
Constructor Summary | |
---|---|
UnitParser(String parserType,
String unitString)
Create a new unit parser. |
Method Summary | |
---|---|
UnitParser.Lexeme |
getLexeme()
Return successive lexemes from the input. |
UnitExpr |
getParsed()
Retrieve the parsed result |
static Set<String> |
getParserTypes()
Indicate the set of available parsers. |
static boolean |
isKnownParser(String parser)
Indicates whether the argument is the name of a known parser. |
static void |
main(String[] args)
The library main program, for exploring the library's functionality. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String FITS
public static final String OGIP
public static final String CDS
public static final String LATEX
Constructor Detail |
---|
public UnitParser(String parserType, String unitString) throws UnitParserException
getParserTypes()
, or can alternatively be specified using the
class's constant field values FITS
,
OGIP
or CDS
.
parserType
- one of the known parser typesunitString
- the string to be parsed
UnitParserException
- if no parser can be created (typically because the required syntax is unknown)Method Detail |
---|
public UnitExpr getParsed() throws UnitParserException
UnitParserException
- if the parse failspublic static Set<String> getParserTypes()
SyntaxFactory.createParser(java.lang.String, java.io.Reader)
public static boolean isKnownParser(String parser)
parser
- the string name of a parser (eg "fits")
getParserTypes()
public UnitParser.Lexeme getLexeme()
public static void main(String[] args)
Usage:
UnitParser [-isyntax] [-osyntax] [-v] unit-expression
Parse and redisplay the string expression given as argument.
The -i
and -o
flags specify the
input and output syntaxes.
UnitParser -S
List the set of available syntaxes
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |