|
|||||||||
| 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 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(Double d1,
Double d2)
Compares two Double objects for sorting purposes. |
static Double |
flexibleDoubleValue(Object stringValue)
Flexible conversion of a string into a Double. |
String |
formatObject(Object object,
int precision,
Locale locale)
Returns a string representation of the given object in the given locale with the given precision. |
static double |
getDoubleValue(Object object)
Returns a double value derived from the given object in
the default locale. |
static double |
getDoubleValue(Object object,
Locale locale)
Returns a double value derived from the given object in
the default locale. |
static String |
getStringValue(double value)
Returns a formatted string for the given double in the
default locale. |
static String |
getStringValue(Double object)
Returns a formatted string for the given Double in the
default locale. |
static String |
getStringValue(double value,
int precision)
Returns a formatted string for the given double in the
default locale. |
static String |
getStringValue(Double object,
int precision)
Returns a formatted string for the given Double in the
default locale. |
static String |
getStringValue(double value,
int minPrecision,
int maxPrecision)
Returns a formatted string for the given double in the
default locale. |
static String |
getStringValue(double value,
int minPrecision,
int maxPrecision,
Locale locale)
Returns a formatted string for the given double in the
given locale. |
static String |
getStringValue(Double object,
int minPrecision,
int maxPrecision,
Locale locale)
Returns a formatted string for the given Double in the
given locale. |
static String |
getStringValue(double value,
int minPrecision,
int maxPrecision,
String pattern,
Locale locale)
Returns a formatted string for the given double in the
given locale. |
static String |
getStringValue(Double object,
int minPrecision,
int maxPrecision,
String pattern,
Locale locale)
Returns a formatted string for the given Double in the
given locale. |
static String |
getStringValue(double value,
int minPrecision,
int maxPrecision,
String pattern,
Locale locale,
boolean trim)
Returns a formatted string for the given double in the
given locale. |
static String |
getStringValue(double value,
int precision,
Locale locale)
Returns a formatted string for the given double in the
given locale. |
static String |
getStringValue(Double object,
int precision,
Locale locale)
Returns a formatted string for the given Double in the
given locale. |
static String |
getStringValue(double value,
Locale locale)
Returns a formatted string for the given double in the
given locale. |
static String |
getStringValue(Double object,
Locale locale)
Returns a formatted string for the given Double in the
given locale. |
Object |
getValue(Object object,
Locale locale)
Returns a new Double derived from the given object in the
given locale. |
static double |
parseDouble(String string)
Tries to parse the given string as a double in the
default locale. |
static double |
parseDouble(String string,
Locale locale)
Tries to parse the given string as a double in the given
locale. |
static double |
parseDouble(String string,
String pattern,
Locale locale)
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, 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 DoubleFormatter()
DoubleFormatter.
| Method Detail |
|---|
public static String getStringValue(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 null
public static String getStringValue(Double object,
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 null
public static String getStringValue(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 null
public static String getStringValue(Double object,
int precision,
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 null
public static String getStringValue(Double object,
int minPrecision,
int maxPrecision,
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 null
public static String getStringValue(Double object,
int minPrecision,
int maxPrecision,
String pattern,
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 nullDecimalFormatpublic static 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 String getStringValue(double value,
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 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 String getStringValue(double value,
int precision,
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 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 String getStringValue(double value,
int minPrecision,
int maxPrecision,
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 String getStringValue(double value,
int minPrecision,
int maxPrecision,
String pattern,
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
doubleDecimalFormat
public static String getStringValue(double value,
int minPrecision,
int maxPrecision,
String pattern,
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.
doubleDecimalFormat
public static double parseDouble(String string)
throws ParseException
double in the
default locale.
string - the string to parse as a double
double value derived from the string
ParseException - if the string cannot be parsed as a
double
public static double parseDouble(String string,
Locale locale)
throws ParseException
double in the given
locale. The locale parameter must be non-null.
string - the string to parse as a doublelocale - the Locale to use for parsing
double value derived from the string
ParseException - if the string cannot be parsed as an
double
public static double parseDouble(String string,
String pattern,
Locale locale)
throws ParseException
double in the given
locale. The locale parameter must be non-null.
string - the string to parse as a doublepattern - the DecimalFormat pattern to use for parsinglocale - the Locale to use for parsing
double value derived from the string
ParseException - if the string cannot be parsed as an
doubleDecimalFormatpublic static double getDoubleValue(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 object
public static double getDoubleValue(Object object,
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 object
public static int compareDoubles(Double d1,
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 ordered
public 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 Double flexibleDoubleValue(Object stringValue)
public String formatObject(Object object,
int precision,
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 Object getValue(Object object,
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 Formatterobject - the object to convert to a Doublelocale - 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 | ||||||||