|
|||||||||
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.DoubleFormatter
public class DoubleFormatter
DoubleFormatter
is a subclass of Formatter
which
is responsible for formatting, parsing, and comparing double
values and/or Double
objects.
Field Summary | |
---|---|
static java.lang.String |
ClassName
Our Java class name. |
Fields inherited from interface ariba.util.core.Compare |
---|
EqualTo, GreaterThan, LessThan |
Constructor Summary | |
---|---|
DoubleFormatter()
Creates a new DoubleFormatter . |
Method Summary | |
---|---|
static int |
compareDoubles(double d1,
double d2)
Compares two double values for sorting purposes. |
static int |
compareDoubles(java.lang.Double d1,
java.lang.Double d2)
Compares two Double objects for sorting purposes. |
static java.lang.Double |
flexibleDoubleValue(java.lang.Object stringValue)
Flexible conversion of a string into a Double. |
java.lang.String |
formatObject(java.lang.Object object,
int precision,
java.util.Locale locale)
Returns a string representation of the given object in the given locale with the given precision. |
static java.lang.String |
getCanonicalPercentSign()
|
static double |
getDoubleValue(java.lang.Object object)
Returns a double value derived from the given object in
the default locale. |
static double |
getDoubleValue(java.lang.Object object,
java.util.Locale locale)
Returns a double value derived from the given object in
the default locale. |
static java.lang.String |
getLocalizedPercentSign(java.util.Locale locale)
|
static java.lang.String |
getStringValue(double value)
Returns a formatted string for the given double in the
default locale. |
static java.lang.String |
getStringValue(java.lang.Double object)
Returns a formatted string for the given Double in the
default locale. |
static java.lang.String |
getStringValue(double value,
int precision)
Returns a formatted string for the given double in the
default locale. |
static java.lang.String |
getStringValue(java.lang.Double object,
int precision)
Returns a formatted string for the given Double in the
default locale. |
static java.lang.String |
getStringValue(double value,
int minPrecision,
int maxPrecision)
Returns a formatted string for the given double in the
default locale. |
static java.lang.String |
getStringValue(double value,
int minPrecision,
int maxPrecision,
java.util.Locale locale)
Returns a formatted string for the given double in the
given locale . |
static java.lang.String |
getStringValue(java.lang.Double object,
int minPrecision,
int maxPrecision,
java.util.Locale locale)
Returns a formatted string for the given Double in the
given locale. |
static java.lang.String |
getStringValue(double value,
int minPrecision,
int maxPrecision,
java.lang.String pattern,
java.util.Locale locale)
Returns a formatted string for the given double in the
given locale . |
static java.lang.String |
getStringValue(java.lang.Double object,
int minPrecision,
int maxPrecision,
java.lang.String pattern,
java.util.Locale locale)
Returns a formatted string for the given Double in the
given locale. |
static java.lang.String |
getStringValue(double value,
int minPrecision,
int maxPrecision,
java.lang.String pattern,
java.util.Locale locale,
boolean trim)
Returns a formatted string for the given double in the
given locale . |
static java.lang.String |
getStringValue(double value,
int precision,
java.util.Locale locale)
Returns a formatted string for the given double in the
given locale. |
static java.lang.String |
getStringValue(java.lang.Double object,
int precision,
java.util.Locale locale)
Returns a formatted string for the given Double in the
given locale. |
static java.lang.String |
getStringValue(double value,
java.util.Locale locale)
Returns a formatted string for the given double in the
given locale. |
static java.lang.String |
getStringValue(java.lang.Double object,
java.util.Locale locale)
Returns a formatted string for the given Double in the
given locale. |
java.lang.Object |
getValue(java.lang.Object object,
java.util.Locale locale)
Returns a new Double derived from the given object in the
given locale. |
static double |
parseDouble(java.lang.String string)
Tries to parse the given string as a double in the
default locale. |
static double |
parseDouble(java.lang.String string,
java.util.Locale locale)
Tries to parse the given string as a double in the given
locale. |
static double |
parseDouble(java.lang.String string,
java.util.Locale locale,
boolean strict)
Tries to parse the given string as a double in the given
locale. |
static double |
parseDouble(java.lang.String string,
java.lang.String pattern,
java.util.Locale locale)
Tries to parse the given string as a double in the given
locale. |
static double |
parseDouble(java.lang.String string,
java.lang.String pattern,
java.util.Locale locale,
boolean strict)
Tries to parse the given string as a double in the given
locale. |
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, makeParseException, makeParseExceptionMessage, makeParseExceptionMessage, 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 java.lang.String ClassName
Constructor Detail |
---|
public DoubleFormatter()
DoubleFormatter
.
Method Detail |
---|
public static java.lang.String getStringValue(java.lang.Double object)
Double
in the
default locale. By default, a precision of zero is used.
object
- the Double
to format into a string
Double
,
or empty string if the Double
is nullpublic static java.lang.String getStringValue(java.lang.Double object, java.util.Locale locale)
Double
in the
given locale. By default, a precision of zero is used. The
locale
parameter must be non-null.
object
- the Double
to format into a stringlocale
- the Locale
to use for formatting
Double
,
or empty string if the Double
is nullpublic static java.lang.String getStringValue(java.lang.Double object, int precision)
Double
in the
default locale. The precision
parameter is used to
determine how many fractional digits are shown.
object
- the Double
to format into a stringprecision
- the number of fractional digits to show
Double
,
or empty string if the Double
is nullpublic static java.lang.String getStringValue(java.lang.Double object, int precision, java.util.Locale locale)
Double
in the
given locale. The precision
parameter is used to
determine how many fractional digits are shown. The
locale
parameter must be non-null.
object
- the Double
to format into a stringprecision
- the number of fractional digits to showlocale
- the Locale
to use for formatting
Double
,
or empty string if the Double
is nullpublic static java.lang.String getStringValue(java.lang.Double object, int minPrecision, int maxPrecision, java.util.Locale locale)
Double
in the
given locale. The precision
parameter is used to
determine how many fractional digits are shown. The
locale
parameter must be non-null.
object
- the Double
to format into a stringminPrecision
- the minimum number of fractional digits to showmaxPrecision
- the maximum number of fractional digits to showlocale
- the Locale
to use for formatting
Double
,
or empty string if the Double
is nullpublic static java.lang.String getStringValue(java.lang.Double object, int minPrecision, int maxPrecision, java.lang.String pattern, java.util.Locale locale)
Double
in the
given locale. The precision
parameter is used to
determine how many fractional digits are shown. The
locale
parameter must be non-null.
object
- the Double
to format into a stringminPrecision
- the minimum number of fractional digits to showmaxPrecision
- the maximum number of fractional digits to showpattern
- the DecimalFormat pattern to use for formattinglocale
- the Locale
to use for formatting
Double
,
or empty string if the Double
is nullDecimalFormat
public static java.lang.String getStringValue(double value)
double
in the
default locale. By default, a precision of zero is used.
value
- the double
to format into a string
double
public static java.lang.String getStringValue(double value, java.util.Locale locale)
double
in the
given locale. By default, a precision of zero is used. The
locale
parameter must be non-null.
value
- the double
to format into a stringlocale
- the Locale
to use for formatting
double
public static java.lang.String getStringValue(double value, int precision)
double
in the
default locale. The precision
parameter is used to
determine how many fractional digits are shown.
value
- the double
to format into a stringprecision
- the number of fractional digits to show
double
public static java.lang.String getStringValue(double value, int precision, java.util.Locale locale)
double
in the
given locale. The precision
parameter is used to
determine how many fractional digits are shown. The
locale
parameter must be non-null.
value
- the double
to format into a stringprecision
- the number of fractional digits to showlocale
- the Locale
to use for formatting
double
public static java.lang.String getStringValue(double value, int minPrecision, int maxPrecision)
double
in the
default locale.
value
- the double
to format into a stringminPrecision
- the minimum number of fractional digits to showmaxPrecision
- the maximum number of fractional digits to show
double
public static java.lang.String getStringValue(double value, int minPrecision, int maxPrecision, java.util.Locale locale)
double
in the
given locale
.
value
- the double
to format into a stringminPrecision
- the minimum number of fractional digits to showmaxPrecision
- the maximum number of fractional digits to showlocale
- the Locale
to use for formatting
double
public static java.lang.String getStringValue(double value, int minPrecision, int maxPrecision, java.lang.String pattern, java.util.Locale locale)
double
in the
given locale
.
value
- the double
to format into a stringminPrecision
- the minimum number of fractional digits to showmaxPrecision
- the maximum number of fractional digits to showpattern
- the DecimalFormat pattern to use for formattinglocale
- the Locale
to use for formatting
double
DecimalFormat
public static java.lang.String getStringValue(double value, int minPrecision, int maxPrecision, java.lang.String pattern, java.util.Locale locale, boolean trim)
double
in the
given locale
.
value
- the double
to format into a stringminPrecision
- the minimum number of fractional digits to showmaxPrecision
- the maximum number of fractional digits to showpattern
- the DecimalFormat pattern to use for formattinglocale
- the Locale
to use for formattingtrim
- true if leading and trailing zeros should be removed.
double
DecimalFormat
public static double parseDouble(java.lang.String string) throws java.text.ParseException
double
in the
default locale.
string
- the string to parse as a double
double
value derived from the string
java.text.ParseException
- if the string cannot be parsed as a
double
public static double parseDouble(java.lang.String string, java.util.Locale locale) throws java.text.ParseException
double
in the given
locale. The locale
parameter must be non-null.
string
- the string to parse as a double
locale
- the Locale
to use for parsing
double
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
double
public static double parseDouble(java.lang.String string, java.util.Locale locale, boolean strict) throws java.text.ParseException
double
in the given
locale. The locale
parameter must be non-null.
string
- the string to parse as a double
locale
- the Locale
to use for parsing
double
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
double
public static double parseDouble(java.lang.String string, java.lang.String pattern, java.util.Locale locale) throws java.text.ParseException
double
in the given
locale. The locale
parameter must be non-null.
string
- the string to parse as a double
pattern
- the DecimalFormat pattern to use for parsinglocale
- the Locale
to use for parsing
double
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
double
DecimalFormat
public static double parseDouble(java.lang.String string, java.lang.String pattern, java.util.Locale locale, boolean strict) throws java.text.ParseException
double
in the given
locale. The locale
parameter must be non-null.
string
- the string to parse as a double
pattern
- the DecimalFormat pattern to use for parsinglocale
- the Locale
to use for parsing
double
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
double
DecimalFormat
public static java.lang.String getLocalizedPercentSign(java.util.Locale locale)
public static java.lang.String getCanonicalPercentSign()
public static double getDoubleValue(java.lang.Object object)
double
value derived from the given object in
the default locale. If the object is not a Double
, it is
converted to a string and parsed. Returns 0.0
if the
object can't be converted to a double
.
object
- the object to convert to an double
value
double
derived from the given objectpublic static double getDoubleValue(java.lang.Object object, java.util.Locale locale)
double
value derived from the given object in
the default locale. If the object is not a Double
, it is
converted to a string and parsed. Returns 0.0
if the
object can't be converted to a double
.
object
- the object to convert to an double
valuelocale
- the Locale
to use for conversion
double
derived from the given objectpublic static int compareDoubles(java.lang.Double d1, java.lang.Double d2)
Double
objects for sorting purposes. Returns
an int
value which is less than, equal to, or greater
than zero depending on whether the first object sorts before, the
same, or after the second object.
d1
- the first Double
to compared2
- the second Double
to compare
int
value which determines how the two objects
should be orderedpublic static int compareDoubles(double d1, double d2)
double
values for sorting purposes. Returns
an int
value which is less than, equal to, or greater
than zero depending on whether the first value sorts before, the
same, or after the second value.
d1
- the first double
to compared2
- the second double
to compare
int
value which determines how the two values
should be orderedpublic static java.lang.Double flexibleDoubleValue(java.lang.Object stringValue)
public java.lang.String formatObject(java.lang.Object object, int precision, java.util.Locale locale)
Double
.
object
- the Double
to format into a stringprecision
- the number of fractional digits to showlocale
- the Locale
to use for formatting
Double
public java.lang.Object getValue(java.lang.Object object, java.util.Locale locale)
Double
derived from the given object in the
given locale. If the object is not a Double
, it is
converted to a string and parsed. Returns null if the object can't be
parsed as a Double
.
getValue
in class Formatter
object
- the object to convert to a Double
locale
- the Locale
to use for conversion (unused)
Double
derived from the given object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |