public class INumber
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.regex.Pattern |
DECIMAL_PAT
Pattern for findNumb() that finds decimal numbers.
|
static int |
DECIMAL_PAT_WHICH
Which-paren-is-value for decimal pat
|
static java.util.regex.Pattern |
LEFT_PAT
Pattern for findNumb() that finds decimal numbers
on the left-end of a string -- "\\A\\s*([0-9]+)"
|
static int |
LEFT_PAT_WHICH
Which-paren-is-value for leftPat
|
static int |
NUMB_ARABIC |
static int |
NUMB_DIGITS |
static int |
NUMB_LETTER |
static int |
NUMB_MARKER |
static int |
NUMB_NOTE |
static int |
NUMB_NOTE_NUM |
static int |
NUMB_NOTE_PAGE |
static int |
NUMB_NUMBER |
static java.util.regex.Pattern |
NUMB_PAT
A pattern to parse an INumber value.
|
static int |
NUMB_PRE |
static int |
NUMB_ROMAN |
static java.util.regex.Pattern |
RIGHT_PAT
Pattern for findNumb() that finds decimal numbers
on the right-end of a string -- "(.*[^0-9])?([0-9]+)\\s\*\z"
|
static int |
RIGHT_PAT_WHICH
Which-paren-is-value for rightPat
|
static java.util.regex.Pattern |
ROMAN_PAT
Pattern for findNumb() that finds roman numbers.
|
static int |
ROMAN_PAT_WHICH
Which-paren-is-value for romanPat
|
Constructor and Description |
---|
INumber()
Returns an INumber for 0, with no prefix.
|
INumber(INumber src)
Construct an INumber duplicating the argument.
|
INumber(java.lang.String pref)
Returns an INumber for 0, with the given prefix.
|
Modifier and Type | Method and Description |
---|---|
static void |
arabicToInt(java.lang.String arabic,
INumber nVal)
Convert a value in arabic digits to an int.
|
static INumber |
checkSign(INumber v)
If prefix is solely a minus sign, change sign of value
|
INumber |
decr()
Decrement the retained value by 1.
|
static INumber |
findNumb(java.lang.String text,
java.util.regex.Pattern pat,
int which)
Find a number within a string according to a supplied pattern.
|
static INumber |
findNumb(java.lang.String text,
java.lang.String pat,
int which)
Like findNumb, but pattern is a String.
|
char |
getFormat()
The following numeric formats are supported:
1 - 1, 2, 3, ...
|
java.lang.String |
getFormatName()
The following numeric formats are supported:
1 - 1, 2, 3, ...
|
java.lang.String |
getPrefix() |
int |
getVal() |
java.lang.String |
getValText() |
INumber |
incr()
Increment the retained value by 1.
|
static INumber |
parseNumb(java.lang.String text)
Parse a string to generate an INumber value.
|
static INumber |
parseNumb(java.lang.String text,
boolean singleIsRoman)
Parse a String to generate an INumber value.
|
static int |
romanToInt(java.lang.String r) |
void |
setPrefix(java.lang.String prefix) |
static java.lang.String |
toArabic(int val,
char one)
Convert an integer value to a string of arabic digits.
|
static java.lang.String |
toRoman(int i) |
java.lang.String |
toString()
Convert value to a number string.
|
java.lang.String |
value()
Convert value to a number string, without prefix.
|
public static final java.util.regex.Pattern NUMB_PAT
public static final int NUMB_MARKER
public static final int NUMB_PRE
public static final int NUMB_NUMBER
public static final int NUMB_DIGITS
public static final int NUMB_ARABIC
public static final int NUMB_ROMAN
public static final int NUMB_LETTER
public static final int NUMB_NOTE
public static final int NUMB_NOTE_PAGE
public static final int NUMB_NOTE_NUM
public static final java.util.regex.Pattern DECIMAL_PAT
public static final int DECIMAL_PAT_WHICH
public static final java.util.regex.Pattern LEFT_PAT
public static final int LEFT_PAT_WHICH
public static final java.util.regex.Pattern RIGHT_PAT
public static final int RIGHT_PAT_WHICH
public static final java.util.regex.Pattern ROMAN_PAT
public static final int ROMAN_PAT_WHICH
public INumber()
public INumber(java.lang.String pref)
pref
- The prefixpublic INumber(INumber src)
src
- The INumber to copypublic java.lang.String getPrefix()
public void setPrefix(java.lang.String prefix)
prefix
- the prefix to setpublic int getVal()
public java.lang.String getValText()
public char getFormat()
public java.lang.String getFormatName()
public static INumber findNumb(java.lang.String text, java.lang.String pat, int which)
text
- Text to be parsedpat
- Pattern to matchwhich
- Index of the paren in the pattern which brackets the number to parsefindNumb(String, Pattern, int)
public static INumber findNumb(java.lang.String text, java.util.regex.Pattern pat, int which)
text
- The String to be searched.
It is searched from left to right,
so the leftmost instance of the pattern is reported.pat
- A Pattern object describing the number.
The numeric portion must be surrounded with parentheses.which
- Index of the left paren in pat which corresponds to
the number. Left parens are numbered from left to right,
starting with ONE.public static INumber parseNumb(java.lang.String text)
text
- The string to parse.public static INumber parseNumb(java.lang.String text, boolean singleIsRoman)
text
- The string to parse.singleIsRoman
- true if a single mdclxvi is
to be considered a roman numeral; otherwise it is a letter.public static INumber checkSign(INumber v)
v
- The INumber valuepublic INumber incr()
public INumber decr()
public java.lang.String value()
public java.lang.String toString()
toString
in class java.lang.Object
public static void arabicToInt(java.lang.String arabic, INumber nVal)
arabic
- The string of arabic digits. Leftmost is high-order digit.nVal
- A destination to store the integer.public static java.lang.String toArabic(int val, char one)
val
- The integer to encode.one
- The character to encode digit one (1). For Arabic digits
this should be ١; for Indian digits it should be ۱public static java.lang.String toRoman(int i)
public static int romanToInt(java.lang.String r)