|
sharkysoft.com | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sharkysoft.printf.engine.StringFormatter
com.sharkysoft.printf.engine.NumberFormatter
com.sharkysoft.printf.engine.IntegerFormatter
Formats integers.
An IntegerFormatter
formats integers. See
NumberFormatter
for a generalized discussion relating to this
class.
Example: Output the contents of integer array vals, one integer per line, right-
justified in a 25- character- wide field. Round each integer to 3 significant digits. int[] vals = {2000, 34, 32768}; IntegerFormatter formatter = new IntegerFormatter(); formatter.setFieldWidth(25); formatter.setPadChar(':'); // non-space chosen for emphasis formatter.setAlignment(AlignmentMode.gpRight); formatter.setSigDigits(3); for (int i = 0; i < vals.length; ++ i) System.out.println(formatter.format(vals[i]));This produces the following output:
:::::::::::::::::::::2000 :::::::::::::::::::::::34 ::::::::::::::::::::32800
The formatting properties for a given instance of this class can be updated at any time, and doing so changes the way that subsequent data is formatted. For a detailed description of all formatting properties, review the documentation below and in the superclass.
Field Summary | |
protected char |
mcPadDigit
Pad digit. |
protected int |
mnMinDigits
Minimum digits. |
Fields inherited from class com.sharkysoft.printf.engine.NumberFormatter |
mnRadix, mnSigDigits, msNegPrefix, msNegSuffix, msPosPrefix, msPosSuffix, msZeroPrefix, msZeroSuffix, mzUpperCase |
Fields inherited from class com.sharkysoft.printf.engine.StringFormatter |
mcPadChar, mnAlignment, mnCropping, mnFieldWidth |
Constructor Summary | |
IntegerFormatter()
Default constructor. |
Method Summary | |
java.lang.String |
format(java.math.BigInteger ipValue)
Renders value. |
java.lang.String |
format(int inValue)
Renders value. |
java.lang.String |
format(long ilValue)
Renders value. |
java.lang.String |
formatUnsigned(byte ibValue)
Renders unsigned value. |
java.lang.String |
formatUnsigned(int inValue)
Renders unsigned value. |
java.lang.String |
formatUnsigned(long ilValue)
Renders unsigned value. |
java.lang.String |
formatUnsigned(short iwValue)
Renders unsigned value. |
int |
getMinDigits()
Retrieves MinDigits property. |
char |
getPadDigit()
Retrieves PadDigit property. |
void |
setMinDigits(int inMinDigits)
Updates MinDigits property. |
void |
setPadDigit(char icPadDigit)
Updates PadDigit property. |
Methods inherited from class com.sharkysoft.printf.engine.NumberFormatter |
getNegPrefix, getNegSuffix, getPosPrefix, getPosSuffix, getRadix, getSigDigits, getUpperCase, getZeroPrefix, getZeroSuffix, setNegPrefix, setNegSuffix, setPosPrefix, setPosSuffix, setRadix, setSigDigits, setUpperCase, setZeroPrefix, setZeroSuffix |
Methods inherited from class com.sharkysoft.printf.engine.StringFormatter |
format, format, getAlignment, getCropping, getFieldWidth, getPadChar, setAlignment, setCropping, setFieldWidth, setPadChar, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected char mcPadDigit
Details: Property PadDigit
is the pad digit to use when
extra digits are required because of the MinDigits
property.
Default value: '0'.
getPadDigit()
,
setPadDigit(char)
protected int mnMinDigits
Details: Property MinDigits
is the minimum number of
digits to display in the formatted output. If the number isn't large
enough to fill all the digits, the padding digit will be used to fill out
the rest. If this property is 0, digits will only be displayed if the
value being rendered is non-zero. Default value: 1.
getMinDigits()
,
setMinDigits(int)
Constructor Detail |
public IntegerFormatter()
Method Detail |
public char getPadDigit()
mcPadDigit
public void setPadDigit(char icPadDigit)
icPadDigit
- new valuemcPadDigit
public int getMinDigits()
mnMinDigits
public void setMinDigits(int inMinDigits)
inMinDigits
- new valuemnMinDigits
public java.lang.String format(java.math.BigInteger ipValue)
Details: format
renders the given integer value into
a numeric string, formatted according to the criteria set forth in the
properties.
ipValue
- value to render
public final java.lang.String format(long ilValue)
Details: format
renders the given integer value into
a numeric string, formatted according to the criteria set forth in the
properties.
ilValue
- value to render
public final java.lang.String format(int inValue)
Details: format
renders the given integer value into
a numeric string, formatted according to the criteria set forth in the
properties.
inValue
- value to render
public final java.lang.String formatUnsigned(long ilValue)
Details: formatUnsigned
renders the given integer
value as a numeric string, formatted according to the criteria set forth in
the properties. The integer value is interpreted as an unsigned value.
ilValue
- value to render
public final java.lang.String formatUnsigned(int inValue)
Details: formatUnsigned
renders the given integer
value as a numeric string, formatted according to the criteria set forth in
the properties. The integer value is interpreted as an unsigned value.
inValue
- value to render
public final java.lang.String formatUnsigned(short iwValue)
Details: formatUnsigned
renders the given integer
value as a numeric string, formatted according to the criteria set forth in
the properties. The integer value is interpreted as an unsigned value.
iwValue
- value to render
public final java.lang.String formatUnsigned(byte ibValue)
Details: formatUnsigned
renders the given integer
value as a numeric string, formatted according to the criteria set forth in
the properties. The integer value is interpreted as an unsigned value.
ibValue
- value to render
|
sharkysoft.com | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997-2004 Sharkysoft (sharkysoft.com). All rights reserved.