|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.as400.ui.framework.java.DataFormatter com.ibm.as400.ui.framework.java.PercentFormatter
public class PercentFormatter extends DataFormatter
Formatter for exchanging percentage values between
DataBean
s and user interface components.
PercentFormatter
formats numbers and displays as percentages
according to current locale, and parses strings of percentage information into values.
If parsing is unsuccessful, an IllegalUserDataException
is thrown.
Percentage values are stored such that they are 1/100th of the percent displayed. (e.g. 0.47 is displayed as 47%; 47% is returned as 0.47).
PercentFormatter
has a minimum and maximum number of fraction digits
used during formatting. These are optionally set in the constructor, or with the
setMinimumFractionDigits
and setMaximumFractionDigits
methods.
The default is to show no fraction digits.
DataBean
,
IllegalUserDataException
Constructor and Description |
---|
PercentFormatter()
Constructs a PercentFormatter . |
PercentFormatter(int minimumFractionDigits,
int maximumFractionDigits)
Constructs a PercentFormatter . |
Modifier and Type | Method and Description |
---|---|
String |
format(double dNum)
Formats a double value to a string containing a percentage. |
String |
format(long lNum)
Formats a long value to a string containing a percentage. |
String |
format(Object obj)
Formats an Object based on the min- and maxFractionDigits set for the PercentFormatter. |
int |
getMaximumFractionDigits()
Gets the maximum number of digits that appear in the fraction. |
int |
getMinimumFractionDigits()
Gets the minimum number of digits that appear in the fraction. |
Object |
parse(String source)
Parses a string to produce an object. |
void |
setMaximumFractionDigits(int digits)
Sets the maximum number of digits that appear in the fraction. |
void |
setMinimumFractionDigits(int digits)
Sets the minimum number of digits that appear in the fraction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PercentFormatter()
PercentFormatter
. This constructor defaults to not showing any fractional
digits.
public PercentFormatter(int minimumFractionDigits, int maximumFractionDigits)
PercentFormatter
. This constructor allows both minimum and maximum
fraction digits to be specified.
If minimumFractionDigits is greater than the maximumFractionDigits, the
minimumFractionDigits is used for both values.
minimumFractionDigits
- the minimum number of fraction digits to appearmaximumFractionDigits
- the maximum number of fraction digits to appearMethod Detail |
---|
public Object parse(String source) throws IllegalUserDataException
parse
in class DataFormatter
source
- the string to be parsedIllegalUserDataException
public String format(double dNum)
dNum
- the double value to formatpublic String format(long lNum)
lNum
- the long value to formatpublic String format(Object obj)
Number
.
format
in class DataFormatter
obj
- a valid Double
, Float
, Integer
, or Long
object cast as an Object.public void setMinimumFractionDigits(int digits)
digits
- the minimum number of digits in the fraction. Must be 0 or greater.public void setMaximumFractionDigits(int digits)
digits
- the maximum number of digits in the fraction. Must be 0 or greater.public int getMaximumFractionDigits()
public int getMinimumFractionDigits()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |