|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectariba.util.formatter.Formatter
ariba.util.formatter.DecimalFormatterCommon
ariba.util.formatter.BigDecimalFormatter
public class BigDecimalFormatter
Responsible for formatting, parsing, and comparing BigDecimal values.
| Field Summary | |
|---|---|
static String |
ClassName
Our Java class name. |
| Fields inherited from interface ariba.util.core.Compare |
|---|
EqualTo, GreaterThan, LessThan |
| Constructor Summary | |
|---|---|
BigDecimalFormatter()
Creates a new BigDecimalFormatter. |
|
| Method Summary | |
|---|---|
static boolean |
canParseBigDecimalValue(Object object)
Returns whether this object can be parsed as a BigDecimal using
the default locale. |
static boolean |
canParseBigDecimalValue(Object object,
Locale locale)
Returns wheteher this object can be parsed as a BigDecimal using
the default locale. |
static int |
compareBigDecimals(BigDecimal bd1,
BigDecimal bd2)
Compares two BigDecimals and returns 1, 0, or -1 if bd1 is greater, equal, or less than bd2. |
static BigDecimal |
getBigDecimalValue(double value)
Returns a BigDecimal for this object. |
static BigDecimal |
getBigDecimalValue(Object object)
Returns a BigDecimal for this object using the default
locale. |
static BigDecimal |
getBigDecimalValue(Object object,
Locale locale)
Returns a BigDecimal for this object using this
locale. |
static DecimalFormatSymbols |
getDecimalFormatSymbol()
Get the decimal format for the default locale. |
static DecimalFormatSymbols |
getDecimalFormatSymbol(Locale locale)
Get the decimal format for this locale |
static String |
getStringValue(BigDecimal object)
Returns a formatted string for the given BigDecimal object in the default locale. |
static String |
getStringValue(BigDecimal value,
int scale)
Returns a formatted string for this BigDecimal value
using this scale to determine how many fractional digits
are shown. |
static String |
getStringValue(BigDecimal value,
int scale,
Locale locale)
Returns a formatted string for this BigDecimal value
using this scale to determine how many fractional digits
are shown. |
static String |
getStringValue(BigDecimal value,
int scale,
Locale locale,
DecimalFormat fmt)
Returns a formatted string for this value using
this scale to determine how many fractional digits are
shown. |
static String |
getStringValue(BigDecimal value,
int scale,
Locale locale,
String pattern)
Returns a formatted string for this BigDecimal value
using this scale to determine how many fractional digits
are shown. |
static String |
getStringValue(BigDecimal object,
Locale locale)
Returns a formatted string for this BigDecimal object in
this locale. |
Object |
getValue(Object object,
Locale locale)
Returns a BigDecimal for this object using this
locale. |
static boolean |
hasDecimal(BigDecimal amount)
Returns true if the amount has a fractional
component. |
static int |
numDecimalDigits(BigDecimal bd)
Returns the number of digits in the decimal part of the number. |
static int |
numWholeDigits(BigDecimal bd)
Returns the number of digits in the whole part of the number. |
static BigDecimal |
parseBigDecimal(String string)
Parses this string as a BigDecimal in the
default locale. |
static DecimalParseInfo |
parseBigDecimal(String string,
DecimalFormat fmt)
Parse the string parameter and return a
DecimalParseInfo that returns information gleaned
from parse such as the BigDecimal number
corresponding to the string, the number of decimal places,
etc. |
static BigDecimal |
parseBigDecimal(String string,
Locale locale)
Parses this string as a BigDecimal in this
locale. |
static BigDecimal |
parseBigDecimal(String string,
Locale locale,
String pattern)
Parses this string as a BigDecimal in this
locale. |
static DecimalParseInfo |
parseBigDecimalInfo(String string,
Locale locale)
Parses this string as a BigDecimal in this
locale, returning a DecimalParseInfo
object describing the parse. |
static BigDecimal |
reciprocal(BigDecimal value)
Returns the reciprocal of this value. |
static BigDecimal |
round(BigDecimal amount,
int scale)
Rounds the amount to the number of decimal places
specified by scale and returns the new amount. |
static BigDecimal |
roundCeiling(BigDecimal amount,
int scale)
Rounds the money amount toward positive infinity, to the number of decimal places specified by scale
and returns the new amount. |
| Methods inherited from class ariba.util.formatter.DecimalFormatterCommon |
|---|
trimString, trimString |
| Methods inherited from class ariba.util.formatter.Formatter |
|---|
canFormatNulls, compare, compare, equal, equal, getFormat, getFormat, getFormatterClassForType, getFormatterForObject, getFormatterForType, getLocale, getStringValue, getStringValue, getValue, handlesNulls, isBidirectional, makeParseException, makeParseException, objectsAreEqual, objectsAreEqual, parse, parse, parseString, parseString, quickCompare, quickCompare, quickCompareValue, registerFormatter |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ClassName
| Constructor Detail |
|---|
public BigDecimalFormatter()
BigDecimalFormatter.
| Method Detail |
|---|
public static String getStringValue(BigDecimal object)
object in the default locale.
object - The BigDecimal used to generate the string value
public static String getStringValue(BigDecimal object,
Locale locale)
object in
this locale. Trailing decimal zeros are removed from the
string.
object - BigDecimal to convert to a string valuelocale - Locale to use to format the string
BigDecimal
public static String getStringValue(BigDecimal value,
int scale)
value
using this scale to determine how many fractional digits
are shown. Uses the formatter's default locale.
value - BigDecimal to convert to a string valuescale - The number of decimal places to create in the string value
BigDecimal
public static String getStringValue(BigDecimal value,
int scale,
Locale locale)
value
using this scale to determine how many fractional digits
are shown. Uses the default pattern for this locale.
value - BigDecimal to convert to a string valuescale - The number of decimal places to create in the string valuelocale - Locale to use to format the string
BigDecimal
public static String getStringValue(BigDecimal value,
int scale,
Locale locale,
String pattern)
value
using this scale to determine how many fractional digits
are shown. Uses the default pattern for this locale.
value - BigDecimal to convert to a string valuescale - The number of decimal places to create in the string valuelocale - Locale to use to format the stringpattern - the DecimalFormat pattern to use for formatting
BigDecimalDecimalFormat
public static String getStringValue(BigDecimal value,
int scale,
Locale locale,
DecimalFormat fmt)
value using
this scale to determine how many fractional digits are
shown. Uses the DecimalFormat passed in to format the number.
value - BigDecimal to convert to a string value.scale - The number of decimal places to create in the string value.locale - Locale to use to format the string.fmt - The DecimalFormat to use for fetching localized
symbols.
BigDecimal.
public static BigDecimal parseBigDecimal(String string)
throws ParseException
string as a BigDecimal in the
default locale.
string - The string to be parsed
ParseException
public static BigDecimal parseBigDecimal(String string,
Locale locale)
throws ParseException
string as a BigDecimal in this
locale.
First converts the number string into a "canonical" number string
which is acceptable to the BigDecimal(string) constructor. It then
calls this constructor and returns a new BigDecimal.
If the parse cannot be performed successfully, the parser throws
a ParseException.
string - The string to parse.locale - The locale to use to get localized number and currency
symbols such as the decimal separator.
BigDecimal corresponding to the
string parameter.
ParseException
public static BigDecimal parseBigDecimal(String string,
Locale locale,
String pattern)
throws ParseException
string as a BigDecimal in this
locale.
First converts the number string into a "canonical" number string
which is acceptable to the BigDecimal(string) constructor. It then
calls this constructor and returns a new BigDecimal.
If the parse cannot be performed successfully, the parser throws
a ParseException.
string - The string to parse.locale - The locale to use to get localized number and currency
symbols such as the decimal separator.pattern - The DecimalFormat pattern to use for parsing
BigDecimal corresponding to the
string parameter.
ParseExceptionDecimalFormat
public static DecimalParseInfo parseBigDecimalInfo(String string,
Locale locale)
throws ParseException
string as a BigDecimal in this
locale, returning a DecimalParseInfo
object describing the parse.
The BigDecimal result can be accessed through the number
public member on DecimalParseInfo
If the parse cannot be performed successfully, the parser throws
a ParseException.
string - The string to parse.locale - The locale to use to get localized number and currency
symbols such as the decimal separator.
DecimalParseInfo object corresponding
to the string parameter.
ParseException
public static DecimalParseInfo parseBigDecimal(String string,
DecimalFormat fmt)
throws ParseException
string parameter and return a
DecimalParseInfo that returns information gleaned
from parse such as the BigDecimal number
corresponding to the string, the number of decimal places,
etc.
If the parse cannot be performed successfully, the parser throws
a ParseException.
string - The string to parse.fmt - The DecimalFormat to use for fetching localized
symbols.
BigDecimal corresponding to the
string parameter.
ParseExceptionpublic static BigDecimal getBigDecimalValue(Object object)
object using the default
locale. If object is not a BigDecimal, the object is converted
to a string and parsed. If there is a problem parsing the string, or
the value is null, we return zero as a default value.
object - If object is not a BigDecimal, the object is converted to a string and parsed.
public static BigDecimal getBigDecimalValue(Object object,
Locale locale)
object using this
locale. If object is not a BigDecimal, the object is
converted to a string and parsed. If there is a problem parsing the
string, or the value is null, we return zero as a default value.
object - The object to convert to a BigDecimal.locale - Locale to use to parse the
object if necessary.
BigDecimal corresponding to the
object parameter.public static boolean canParseBigDecimalValue(Object object)
object can be parsed as a BigDecimal using
the default locale. If object is not a BigDecimal, the object is
converted to a string and parsed. If there is a problem parsing the string, we
return false.
object - If object is not a BigDecimal, the object is converted to a string and parsed.
public static boolean canParseBigDecimalValue(Object object,
Locale locale)
object can be parsed as a BigDecimal using
the default locale. If object is not a BigDecimal, the object is
converted to a string and parsed. If there is a problem parsing the string, we
return false.
object - If object is not a BigDecimal, the object is converted to a string and parsed.locale - Locale to use to parse the
object if necessary.
public static BigDecimal getBigDecimalValue(double value)
object. If object is
not a BigDecimal, the object is converted to a string and parsed. If
there is a problem parsing the string, or the value is null, we return
zero as a default value.
value - a double for which a BigDecimal is returned
public Object getValue(Object object,
Locale locale)
object using this
locale. The meat of this method is implemented
in bigDecimalValue(object, locale).
getValue in class Formatterobject - The object to convert to a BigDecimal.locale - Locale to use to parse the
object if necessary.
BigDecimal corresponding to the
object parameter.public static BigDecimal reciprocal(BigDecimal value)
value BigDecimal
must have the desired scale of the result.
value - the input BigDecimal
public static BigDecimal round(BigDecimal amount,
int scale)
amount to the number of decimal places
specified by scale and returns the new amount.
If the amount is already rounded to scale
or has fewer decimal places than scale, we simply
return the amount.
amount - The number to round.scale - The number of decimal places to round to.
BigDecimal.
public static BigDecimal roundCeiling(BigDecimal amount,
int scale)
scale
and returns the new amount.
amount - The BigDecimal inputscale - The number of decimal places to round the input
public static DecimalFormatSymbols getDecimalFormatSymbol()
public static DecimalFormatSymbols getDecimalFormatSymbol(Locale locale)
locale - the locale to use when returning the decimal format
public static boolean hasDecimal(BigDecimal amount)
true if the amount has a fractional
component.
amount - The BigDecimal input
public static int numDecimalDigits(BigDecimal bd)
bd - The BigDecimal input
public static int numWholeDigits(BigDecimal bd)
bd - The BigDecimal being input
public static int compareBigDecimals(BigDecimal bd1,
BigDecimal bd2)
bd1 - BigDecimal used in comparisionbd2 - BigDecimal used in comparision
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||