gnu.text

Class IntegerFormat

Known Direct 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.

Field Summary

static int
MIN_DIGITS
The minWidth is minimum number of digits, not minimum total width.
static int
PAD_RIGHT
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
int
base
int
commaChar
int
commaInterval
int
flags
int
minWidth
Minimal width of the result, includiing sign, commas, etc.
int
padChar
The padding characters, by default ' '.

Fields inherited from class gnu.text.ReportFormat

PARAM_FROM_COUNT, PARAM_FROM_LIST, PARAM_UNSPECIFIED

Constructor Summary

IntegerFormat()

Method Summary

String
convertToIntegerString(Object x, int radix)
int
format(Object arg, int start, Writer dst, FieldPosition fpos)
int
format(Object[] args, int start, Writer dst, FieldPosition fpos)
Format an array of arguments, and write out the result.

Methods inherited from class gnu.text.ReportFormat

format, format, format, format, format, format, getParam, getParam, getParam, nextArg, parseObject, print, result, resultCode

Field Details

MIN_DIGITS

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

PAD_RIGHT

public static final int PAD_RIGHT
Field Value:
16

SHOW_BASE

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

SHOW_GROUPS

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

SHOW_PLUS

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

SHOW_SPACE

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

UPPERCASE

public static final int UPPERCASE
Field Value:
32

base

public int base

commaChar

public int commaChar

commaInterval

public int commaInterval

flags

public int flags

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 ' '.

Constructor Details

IntegerFormat

public IntegerFormat()

Method Details

convertToIntegerString

public String convertToIntegerString(Object x,
                                     int radix)

format

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

format

public int format(Object[] args,
                  int start,
                  Writer dst,
                  FieldPosition fpos)
            throws java.io.IOException
Format an array of arguments, and write out the result.
Overrides:
format in interface 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)