public class IntegerFormatter extends InternalFormat.Formatter
Modifier and Type | Class and Description |
---|---|
static class |
IntegerFormatter.Traditional
A minor variation on
IntegerFormatter to handle "traditional" %-formatting. |
Modifier and Type | Field and Description |
---|---|
static InternalFormat.Spec |
BIN
Format specification used by bin().
|
static InternalFormat.Spec |
HEX
Format specification used by hex().
|
static InternalFormat.Spec |
OCT
Format specification used by oct().
|
Constructor and Description |
---|
IntegerFormatter(InternalFormat.Spec spec)
Construct the formatter from a specification, allocating a buffer internally for the result.
|
IntegerFormatter(java.lang.StringBuilder result,
InternalFormat.Spec spec)
Construct the formatter from a client-supplied buffer, to which the result will be appended,
and a specification.
|
Modifier and Type | Method and Description |
---|---|
IntegerFormatter |
append(char c) |
IntegerFormatter |
append(java.lang.CharSequence csq) |
IntegerFormatter |
append(java.lang.CharSequence csq,
int start,
int end) |
static PyString |
bin(PyObject number)
Convert the object to binary according to the conventions of Python built-in
bin() . |
IntegerFormatter |
format(java.math.BigInteger value)
Format a
BigInteger , which is the implementation type of Jython long ,
according to the specification represented by this IntegerFormatter . |
IntegerFormatter |
format(int value)
Format an integer according to the specification represented by this
IntegerFormatter . |
static PyString |
formatNumber(PyObject number,
InternalFormat.Spec spec)
Convert the object according to the conventions of Python built-in
hex() , or
oct() . |
alignmentNotAllowed, alternateFormNotAllowed, alternateFormNotAllowed, getPyResult, getResult, isBytes, notAllowed, notAllowed, pad, precisionNotAllowed, precisionTooLarge, setBytes, setStart, signNotAllowed, toString, unknownFormat, zeroPaddingNotAllowed
public static final InternalFormat.Spec BIN
public static final InternalFormat.Spec OCT
public static final InternalFormat.Spec HEX
public IntegerFormatter(java.lang.StringBuilder result, InternalFormat.Spec spec)
InternalFormat.Formatter.mark
to the end of the buffer.result
- destination bufferspec
- parsed conversion specificationpublic IntegerFormatter(InternalFormat.Spec spec)
spec
- parsed conversion specificationpublic IntegerFormatter append(char c)
append
in interface java.lang.Appendable
append
in class InternalFormat.Formatter
public IntegerFormatter append(java.lang.CharSequence csq)
append
in interface java.lang.Appendable
append
in class InternalFormat.Formatter
public IntegerFormatter append(java.lang.CharSequence csq, int start, int end) throws java.lang.IndexOutOfBoundsException
append
in interface java.lang.Appendable
append
in class InternalFormat.Formatter
java.lang.IndexOutOfBoundsException
public IntegerFormatter format(java.math.BigInteger value)
BigInteger
, which is the implementation type of Jython long
,
according to the specification represented by this IntegerFormatter
. The
conversion type, and flags for grouping or base prefix are dealt with here. At the point this
is used, we know the InternalFormat.Formatter.spec
is one of the integer types.value
- to convertpublic IntegerFormatter format(int value)
IntegerFormatter
. The conversion type, and flags for grouping or base prefix are
dealt with here. At the point this is used, we know the InternalFormat.Formatter.spec
is one of the integer
types.value
- to convertpublic static PyString bin(PyObject number)
bin()
. The object's __index__ method is called, and is responsible for raising
the appropriate error (which the base PyObject.__index__()
does).number
- to convertpublic static PyString formatNumber(PyObject number, InternalFormat.Spec spec)
hex()
, or
oct()
. The object's __index__
method is called, and is responsible
for raising the appropriate error (which the base PyObject.__index__()
does).number
- to convert