Class LcNum


  • public class LcNum
    extends Object
    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.
    Here's a snippet of code illustrating the use of 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 Detail

      • MAX_PRECISION

        public static final int MAX_PRECISION
        An arbitrarily limited maximal decimal precision: 15.
        See Also:
        Constant Field Values
      • NUMERIC_PICTURE_SYMBOLS

        public static final String NUMERIC_PICTURE_SYMBOLS
        LcNum pattern symbols: (%$,.)89BCDERSVZbcdrsvzt.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LcNum

        public LcNum​(String text,
                     String locale)
        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

        public LcNum​(String text,
                     String pic,
                     String locale)
        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 Detail

      • getText

        public String 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

        public String format​(String pat,
                             IntegerHolder radixPos)
        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

        public boolean parse​(String sStr,
                             String pat)
        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

        public static void getSymbolCount​(String pic,
                                          IntegerHolder lead,
                                          IntegerHolder frac)
        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.