|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcds.astro.Astroformat
cds.astro.Parsing
public class Parsing
This class interprets text and is able to convert to numbers, or find a symbol in a list of symbols. Numbers can use ...×10+/-exp as well as ...e+/-exp notation; numbers may also be expressed in sexagesimal.
This class returns, for the most recently analyzed number:
Field Summary | |
---|---|
char[] |
a
The text as an array of chars |
static int |
DEBUG
Debugging level |
static int |
ERROR
The last (sexagesimal) parsing has a component greater than 60 |
java.lang.String |
error_message
Error message, if any (only in parseComplex) |
int |
length
The length of the array, can be shorter than the actual size |
static int |
OK
The status of the last parsing operation is OK |
int |
pos
The current position in the array |
static int |
WARNING
The last (sexagesimal) parsing has minutes or seconds equal to 60. |
Fields inherited from class cds.astro.Astroformat |
---|
DATE, DATE_alpha, DATE_COMP, DATE_DIFF, DATE_DMY, DATE_DY, DATE_MDY, DATE_MY, DATE_MYD, DATE_YD, DATE_YM, DATE_YMD, DECIMAL, EFORMAT, FACTOR, month_list, nulls, SEXA1d, SEXA1h, SEXA1o, SEXA2, SEXA2c, SEXA2d, SEXA2h, SEXA2o, SEXA3, SEXA3c, SEXA3d, SEXA3h, SEXA3o, SIGN_EDIT, TRUNCATE, ZERO_FILL |
Constructor Summary | |
---|---|
Parsing(java.lang.String s)
Create a Parsing unit from a string |
|
Parsing(java.lang.String s,
int offset)
Create a Parsing unit from a string + offset |
Method Summary | |
---|---|
void |
advance(int n)
Move (forward / backward) in the Parsing piece |
char |
currentChar()
Get the current char |
int |
decimals()
Retrieves the number of decimals of the last parsed number. |
int |
digits()
Retrieves the number of significant digits of the last parsed number. |
java.lang.String |
form()
Retrieves the 'format' of the last parsed number as a string. |
int |
format()
Retrieves the 'format' of the last parsed number. |
java.lang.String |
getMessage()
About the last parsed number: get the error message |
void |
gobbleSpaces()
Skip the spaces in the Parsing unit |
boolean |
inError()
About the last parsed number: was it in error ? |
boolean |
isAngle()
About the last parsed number: was it expressed as angle (° or d) |
boolean |
isDate()
About the last parsed number: was it expressed as a date ? |
boolean |
isDays()
About the last parsed number: does it represent days (date_diff) ? |
boolean |
isSexa()
About the last parsed number: was it sexagesimal ? |
boolean |
isTime()
About the last parsed number: was it expressed as time (hms) ? |
int |
lookup(char[] tSymbol)
Try to match a Character from a list. |
int |
lookup(java.lang.String[] tSymbol)
Try to match a Symbol in the current text. |
int |
lookup(java.lang.String[] tSymbol,
int len)
Try to match a Symbol in a defined piece of the text. |
int |
lookupIgnoreCase(java.lang.String[] tSymbol)
Try to match a Symbol in the current text, case insensitive. |
boolean |
match(char c)
Verify we're starting by a specific character |
boolean |
match(java.lang.String text)
Verify we're starting by a specific string. |
int |
matchingBracket()
From current position assumed to contain a parenthesis or bracket, return the location of the corresponding parenthesis. |
int |
matchingQuote()
From current position assumed to contain a Quote (' " or `) return location of the matching quote. |
int |
parseArray(double[] vec)
Interpret an array (several numbers). |
double |
parseComplex(java.lang.String pic)
Interpret some Complex number (date, sexagesimal). |
int |
parseDate()
Interpret a Date. |
double |
parseDecimal()
Interpret a real number as (+/-)num.decimals. |
double |
parseDouble()
Interpret a real number as (+/-)numE+/-pow. |
double |
parseFactor()
Interpret a real number as (+/-)numx10+pow OR (+/-)numE+pow. |
int |
parseInt()
Try to match an Integer Number. |
long |
parseLong()
Try to match a Long Integer Number. |
boolean |
parseNaN()
Try to match one of the possible NaN representations. |
int |
parsePositiveInt()
Try to match a Positive Integer Number. |
double |
parseSexa()
Interpret a sexagesimal number. |
int |
parseWithError(double[] vec)
Interpret a number + Error. |
void |
set(int n)
Force the position within the Parsing piece |
void |
set(java.lang.String text)
Install a new text in the Parsing |
int |
status()
Retrieves the status (OK, WARNING, ERROR) of last (sexagesimal) parsing. |
java.lang.String |
toString()
View the Parsing as a String |
java.lang.String |
toString(int len)
View a part of the Parsing as a String. |
Methods inherited from class cds.astro.Astroformat |
---|
acceptAsNaN, explain, explainComplex, isAngle, isDate, isDays, isSexa, isTime, setNaN |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public char[] a
public int length
public int pos
public java.lang.String error_message
public static final int OK
public static final int WARNING
public static final int ERROR
public static int DEBUG
Constructor Detail |
---|
public Parsing(java.lang.String s)
s
- the text to parsepublic Parsing(java.lang.String s, int offset)
s
- the text to parseMethod Detail |
---|
public final void set(int n)
n
- the position -- if necessary, adjusted between 0 and lengthpublic final void set(java.lang.String text)
text
- the string to parsepublic final void advance(int n)
n
- the value of the steppublic final char currentChar()
public final void gobbleSpaces()
public final int lookup(char[] tSymbol)
tSymbol
- table of Symbols
public final boolean match(char c)
c
- the character to match, possibly preceded by blanks.
public final boolean match(java.lang.String text)
text
- the string that should be there.
public final int lookup(java.lang.String[] tSymbol, int len)
tSymbol
- table of Symbolslen
- exact length of text to match
public final int lookup(java.lang.String[] tSymbol)
tSymbol
- a table of Symbols
public final int lookupIgnoreCase(java.lang.String[] tSymbol)
tSymbol
- table of Symbols
public final int matchingBracket()
public final int matchingQuote()
public final boolean parseNaN()
public final int parsePositiveInt()
public final int parseInt()
public final long parseLong()
public final double parseDecimal()
public final double parseDouble()
public final double parseFactor()
public final double parseSexa()
public final int parseDate()
public final double parseComplex(java.lang.String pic) throws java.text.ParseException
pic
- "picture" which specifies the format of the input.
Letters are Y y (years) M (month) D (day) h (hour) m (minutes)
s (seconds) d (degrees) f (fractions), and punctuations like
: (colon) / (slash), etc. Y and y have slightly
different meanings when the century is omitted (2-digit years):
YY have their offset in 1900, while yy assumes
dates between 1950 and 2049: e.g. 01 means
1901 with Y and 2001 with y
The text must follow exactly the "picture" when the components are specified with several letters. For instance, a picture YYYY-MM-DD indicates that a conforming text must be made of 4 digits representing the year, followed by a dash, 2 digits representing the month, a dash, and 2 digits representing the day -- while Y-M-D accept a variable number of digits in each of the components: "2006-7-5" would conform to the latter "picture", but not to the "YYYY-MM-DD" one.
Astroformat.isDate(int)
, Astroformat.isTime(int)
,
Astroformat.isDate(int)
, Astroformat.isDays(int)
specify the actual interpretation done in the parsing.
java.text.ParseException
- for invalid picture or non-conforming data.
The error_message of the exception starts by:public final int decimals()
public final int digits()
public final int format()
Astroformat
public final java.lang.String form()
public final boolean isSexa()
public final boolean isDate()
public final boolean isDays()
public final boolean isTime()
public final boolean isAngle()
public final boolean inError()
public final int status()
public final java.lang.String getMessage()
public int parseArray(double[] vec)
vec
- Array containing on output the values parsed.
public int parseWithError(double[] vec)
vec
- Array containing value PositiveError NegativeError
public final java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String toString(int len)
len
- Length to keep (truncated if necessary)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |