Package com.adobe.xfa.ut
Class LcNum
java.lang.Object
com.adobe.xfa.ut.LcNum
LcNum defines numeric objects
in support of XFA numeric picture patterns.
Numeric picture patterns are used to parse and format numeric strings. Here are the metasymbols that form valid text picture patterns:
- 9
- when output formatting, this is a single digit, or
a zero digit if the input is a space or empty;
when input parsing, this is a single digit. - Z
- when output formatting, this is a single digit, or
a space if the input is a zero digit, a space, or empty;
when input parsing, this is a single digit or space. - z
- when output formatting, this is a single digit or
nothing if the input is a zero digit, a space or empty;
when input parsing, this is a single digit, or nothing. - S
- a minus sign if negative, a plus sign if positive, or a space otherwise when input parsing; a minus sign if negative and a space otherwise when output formmatting.
- s
- a minus sign if negative, a plus sign if positive, or nothing otherwise when input parsing; a minus sign if negative and nothing otherwise when output formmatting.
- CR
- a credit symbol (CR) if negative, or (2) spaces otherwise.
- cr
- a credit symbol (CR) if negative, or nothing otherwise.
- DB
- a debit symbol (DB) if negative, or (2) spaces otherwise.
- db
- a debit symbol (db) if negative, or nothing otherwise.
- (
- a left parenthesis symbol if negative, or nothing otherwise.
- )
- a right parenthesis symbol if negative, or nothing otherwise.
- E
- an exponent symbol and exponent value.
- $
- a currency symbol of the ambient locale.
- $$
- an international currency name of the ambient locale.
- .
- a decimal radix symbol of the ambient locale.
- V
- a decimal radix symbol of the ambient locale, which may be implied when input parsing.
- v
- a decimal radix symbol of the ambient locale, which may be implied when input parsing and output formatting.
- ,
- a grouping separator symbol of the ambient locale.
LcNum to reformat a text string
import com.adobe.xfa.ut.LcNum;
...
LcNum num = new LcNum("007", "en_US");
if (num.isValid())
String s = text.format(".999$");
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAn arbitrarily limited maximal decimal precision: 15.static final StringLcNum pattern symbols: (%$,.)89BCDERSVZbcdrsvzt. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformat(String pat, IntegerHolder radixPos) Formats this LcNum object given a pattern string.static voidgetSymbolCount(String pic, IntegerHolder lead, IntegerHolder frac) Parse the picture and return the number of leading and fractional digits the picture implies.getText()Gets the parsed text.doublegetValue()Gets the parsed value.booleanisValid()Determines if this LcNum object is valid.booleanParses the given string according to the text pattern given.
-
Field Details
-
MAX_PRECISION
public static final int MAX_PRECISIONAn arbitrarily limited maximal decimal precision: 15.- See Also:
-
NUMERIC_PICTURE_SYMBOLS
LcNum pattern symbols: (%$,.)89BCDERSVZbcdrsvzt.- See Also:
-
-
Constructor Details
-
LcNum
Instantiates an LcNum object from the given text and in the locale given.- Parameters:
text- a text string.locale- a locale name. When empty, it will default to the current locale.
-
LcNum
Instantiates an LcNum object from the given text and pattern pattern and in the locale given.- Parameters:
text- a text string.pic- a numeric pattern pattern.locale- a locale name. When empty, it will default to the current locale.
-
-
Method Details
-
getText
Gets the parsed text.- Returns:
- the text associated with this object.
-
getValue
public double getValue()Gets the parsed value.- Returns:
- the number associated with this object.
-
isValid
public boolean isValid()Determines if this LcNum object is valid.- Returns:
- boolean true if valid, and false otherwise.
-
format
Formats this LcNum object given a pattern string.- Parameters:
pat- a pattern string.radixPos- the returned radix position within the formatted string if specified.- Returns:
- the text string formatted according to the given format string, upon success, and the empty string, upon error.
-
parse
Parses the given string according to the text pattern given.- Parameters:
sStr- the text string to parse.pat- a pattern string.- Returns:
- boolean true if successfully parsed, and false otherwise.
-
getSymbolCount
Parse the picture and return the number of leading and fractional digits the picture implies.- Parameters:
pic- - a picture pattern string.lead- - the number of lead digits.frac- - the number of fractional digits.
-