Package ipsk.text

Class NaturalNumberFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class NaturalNumberFormat
    extends java.text.NumberFormat
    Text format for natural numbers.
    Author:
    klausj
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.text.NumberFormat

        java.text.NumberFormat.Field
    • Field Summary

      • Fields inherited from class java.text.NumberFormat

        FRACTION_FIELD, INTEGER_FIELD
    • Constructor Summary

      Constructors 
      Constructor Description
      NaturalNumberFormat​(int digitCount)
      Create natural number format.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.StringBuffer format​(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)  
      java.lang.StringBuffer format​(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)  
      java.lang.Number parse​(java.lang.String source, java.text.ParsePosition parsePosition)  
      • Methods inherited from class java.text.Format

        format, formatToCharacterIterator, parseObject
      • Methods inherited from class java.text.NumberFormat

        clone, equals, format, format, format, getAvailableLocales, getCurrency, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, getRoundingMode, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly, setRoundingMode
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NaturalNumberFormat

        public NaturalNumberFormat​(int digitCount)
        Create natural number format. Similar to class DecimalFormat but accepts only natural numbers. The parser is strict and accepts only strings containing only number characters and the same length as the specified number of digits. Examples: nnFmt=NaturalNumberFormat(4) nnFmt.format(47); => "0047" nnFmt.parse("0048"); => 48 nnFmt.parse("00048"); throws ParserException !
        Parameters:
        digitCount - number of digits
    • Method Detail

      • format

        public java.lang.StringBuffer format​(double number,
                                             java.lang.StringBuffer toAppendTo,
                                             java.text.FieldPosition pos)
        Specified by:
        format in class java.text.NumberFormat
      • format

        public java.lang.StringBuffer format​(long number,
                                             java.lang.StringBuffer toAppendTo,
                                             java.text.FieldPosition pos)
        Specified by:
        format in class java.text.NumberFormat
      • parse

        public java.lang.Number parse​(java.lang.String source,
                                      java.text.ParsePosition parsePosition)
        Specified by:
        parse in class java.text.NumberFormat