gnu.text
Class IntegerFormat

java.lang.Object
  extended by java.text.Format
      extended by gnu.text.ReportFormat
          extended by gnu.text.IntegerFormat
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
IntegerFormat

public class IntegerFormat
extends ReportFormat

Handle formatting of integers. Used to implement the Common Lisp ~D (Decimal), ~X (Hexadecimal), ~O (Octal), ~B (Binary), and ~R (Radix) Common Lisp formats operators.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
 int base
           
 int commaChar
           
 int commaInterval
           
 int flags
           
static int MIN_DIGITS
          The minWidth is minimum number of digits, not minimum total width.
 int minWidth
          Minimal width of the result, includiing sign, commas, etc.
static int PAD_RIGHT
           
 int padChar
          The padding characters, by default ' '.
static int SHOW_BASE
          Add "0x" (hex) or "0" (octal) prefix.
static int SHOW_GROUPS
          Do groups (for example thousands, using commas).
static int SHOW_PLUS
          If value is non-negative, emit a '+'.
static int SHOW_SPACE
          If value is non-negative, emit an initial ' '.
static int UPPERCASE
           
 
Fields inherited from class gnu.text.ReportFormat
PARAM_FROM_COUNT, PARAM_FROM_LIST, PARAM_UNSPECIFIED
 
Constructor Summary
IntegerFormat()
           
 
Method Summary
 java.lang.String convertToIntegerString(java.lang.Object x, int radix)
           
 int format(java.lang.Object[] args, int start, java.io.Writer dst, java.text.FieldPosition fpos)
          Format an array of arguments, and write out the result.
 int format(java.lang.Object arg, int start, java.io.Writer dst, java.text.FieldPosition fpos)
           
 
Methods inherited from class gnu.text.ReportFormat
format, format, format, format, getParam, getParam, getParam, nextArg, parseObject, print, print, result, resultCode
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

base

public int base

minWidth

public int minWidth
Minimal width of the result, includiing sign, commas, etc. However, if the MIN_DIGITS flag is given, it's the minimum number of digits instead. This is used for printf-style "precision".


padChar

public int padChar
The padding characters, by default ' '.


commaChar

public int commaChar

commaInterval

public int commaInterval

flags

public int flags

SHOW_GROUPS

public static final int SHOW_GROUPS
Do groups (for example thousands, using commas).

See Also:
Constant Field Values

SHOW_PLUS

public static final int SHOW_PLUS
If value is non-negative, emit a '+'.

See Also:
Constant Field Values

SHOW_SPACE

public static final int SHOW_SPACE
If value is non-negative, emit an initial ' '.

See Also:
Constant Field Values

SHOW_BASE

public static final int SHOW_BASE
Add "0x" (hex) or "0" (octal) prefix.

See Also:
Constant Field Values

PAD_RIGHT

public static final int PAD_RIGHT
See Also:
Constant Field Values

UPPERCASE

public static final int UPPERCASE
See Also:
Constant Field Values

MIN_DIGITS

public static final int MIN_DIGITS
The minWidth is minimum number of digits, not minimum total width.

See Also:
Constant Field Values
Constructor Detail

IntegerFormat

public IntegerFormat()
Method Detail

format

public int format(java.lang.Object[] args,
                  int start,
                  java.io.Writer dst,
                  java.text.FieldPosition fpos)
           throws java.io.IOException
Description copied from class: ReportFormat
Format an array of arguments, and write out the result.

Specified by:
format in class ReportFormat
Parameters:
args - the objects to be formatted
start - the index (in args) of the argument to start with
dst - where to write the result
Returns:
an integer result(resultCode, nextArg), where nextArg is the index following the last argument processed, and code is a result code (normally 0, or negative if early termintation)
Throws:
java.io.IOException

format

public int format(java.lang.Object arg,
                  int start,
                  java.io.Writer dst,
                  java.text.FieldPosition fpos)
           throws java.io.IOException
Overrides:
format in class ReportFormat
Throws:
java.io.IOException

convertToIntegerString

public java.lang.String convertToIntegerString(java.lang.Object x,
                                               int radix)