Class LcNum


  • public class LcNum
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_PRECISION
      An arbitrarily limited maximal decimal precision: 15.
      static java.lang.String NUMERIC_PICTURE_SYMBOLS
      LcNum pattern symbols: (%$,.)89BCDERSVZbcdrsvzt.
    • Constructor Summary

      Constructors 
      Constructor Description
      LcNum​(java.lang.String text, java.lang.String locale)
      Instantiates an LcNum object from the given text and in the locale given.
      LcNum​(java.lang.String text, java.lang.String pic, java.lang.String locale)
      Instantiates an LcNum object from the given text and pattern pattern and in the locale given.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String format​(java.lang.String pat, IntegerHolder radixPos)
      Formats this LcNum object given a pattern string.
      static void getSymbolCount​(java.lang.String pic, IntegerHolder lead, IntegerHolder frac)
      Parse the picture and return the number of leading and fractional digits the picture implies.
      java.lang.String getText()
      Gets the parsed text.
      double getValue()
      Gets the parsed value.
      boolean isValid()
      Determines if this LcNum object is valid.
      boolean parse​(java.lang.String sStr, java.lang.String pat)
      Parses the given string according to the text pattern given.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 java.lang.String NUMERIC_PICTURE_SYMBOLS
        LcNum pattern symbols: (%$,.)89BCDERSVZbcdrsvzt.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LcNum

        public LcNum​(java.lang.String text,
                     java.lang.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​(java.lang.String text,
                     java.lang.String pic,
                     java.lang.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 java.lang.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 java.lang.String format​(java.lang.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​(java.lang.String sStr,
                             java.lang.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​(java.lang.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.