|
|||||||||
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.IntegerFormatter
public class IntegerFormatter
IntegerFormatter
is a subclass of Formatter
which is responsible for formatting, parsing, and comparing
int
values and/or Integer
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 | |
---|---|
IntegerFormatter()
Creates a new IntegerFormatter . |
Method Summary | |
---|---|
static int |
compareIntegers(java.lang.Integer i1,
java.lang.Integer i2)
Compares two Integer objects for sorting purposes. |
static int |
compareInts(int i1,
int i2)
Compares two int values for sorting purposes. |
int |
compareObjects(java.lang.Object o1,
java.lang.Object o2,
java.util.Locale locale)
Compares two objects for sorting purposes in the given locale. |
static int |
getIntValue(java.lang.Object object)
Returns an int value derived from the given object in the
default locale. |
static java.lang.String |
getStringValue(int integer)
Returns a formatted string for the given int value in the
default locale. |
static java.lang.String |
getStringValue(java.lang.Integer object)
Returns a formatted string for the given Integer in the
default locale. |
static java.lang.String |
getStringValue(java.lang.Integer object,
java.util.Locale locale)
Returns a formatted string for the given Integer in the
given locale. |
static java.lang.String |
getStringValue(java.lang.Integer object,
java.util.Locale locale,
boolean useGrouping)
Returns a formatted string for the given Integer in the
given locale. |
static java.lang.String |
getStringValue(java.lang.Integer object,
java.util.Locale locale,
java.lang.String pattern)
Returns a formatted string for the given Integer in the
given locale. |
static java.lang.String |
getStringValue(java.lang.Integer object,
java.util.Locale locale,
java.lang.String pattern,
boolean useGrouping)
Returns a formatted string for the given Integer in the
given locale. |
static java.lang.String |
getStringValue(int integer,
java.util.Locale locale)
Returns a formatted string for the given int value in the
given locale. |
static java.lang.String |
getStringValue(int integer,
java.util.Locale locale,
boolean useGrouping)
Returns a formatted string for the given int value in the
given locale. |
static java.lang.String |
getStringValue(int integer,
java.util.Locale locale,
java.lang.String pattern)
Returns a formatted string for the given int value in the
given locale. |
static java.lang.String |
getStringValue(int integer,
java.util.Locale locale,
java.lang.String pattern,
boolean useGrouping)
Returns a formatted string for the given int value in the
given locale. |
java.lang.Object |
getValue(java.lang.Object object,
java.util.Locale locale)
Returns a new Integer derived from the given object in
the given locale. |
static int |
parseInt(char[] chars,
int offset,
int scan)
Tries to parse the given character array as an int in the
default locale. |
static int |
parseInt(char[] chars,
int offset,
int scan,
int base)
Tries to parse the given character array as an int in the
given base . |
static int |
parseInt(java.lang.String string)
Tries to parse the given string as an integer in the default locale. |
static int |
parseInt(java.lang.String string,
int base)
Tries to parse the given string as an int in the
specified base . |
static int |
parseInt(java.lang.String string,
java.util.Locale locale)
Tries to parse the given string as an integer in the given locale . |
static int |
parseInt(java.lang.String string,
java.util.Locale locale,
java.lang.String pattern,
boolean useGrouping)
Tries to parse the given string as an integer in the given locale . |
static int |
parseInt(java.lang.String string,
java.util.Locale locale,
java.lang.String pattern,
boolean useGrouping,
boolean allowOverflow)
Tries to parse the given string as an integer in the given locale . |
static int |
parseInt(java.lang.String string,
java.util.Locale locale,
java.lang.String pattern,
boolean useGrouping,
boolean allowOverflow,
boolean strictParsing,
int minValue,
int maxValue)
Tries to parse the given string as an integer in the given locale . |
static int |
parseIntNoOverflow(java.lang.String string)
Tries to parse the given string as an integer in the default locale. |
static int |
parseIntNoOverflow(java.lang.String string,
java.util.Locale locale)
Tries to parse the given string as an integer in the specified locale. |
static int |
parseIntWithDefault(java.lang.String string,
int defaultValue)
Convenience method for parsing a string into an integer in the given base. |
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 IntegerFormatter()
IntegerFormatter
.
Method Detail |
---|
public static java.lang.String getStringValue(java.lang.Integer object)
Integer
in the
default locale.
object
- the Integer
to format into a string
Integer
public static java.lang.String getStringValue(java.lang.Integer object, java.util.Locale locale)
Integer
in the
given locale. The locale
parameter must be non-null.
object
- the Integer
to format into a stringlocale
- the Locale
to use for formatting
Integer
,
or empty string if the Integer
is nullpublic static java.lang.String getStringValue(java.lang.Integer object, java.util.Locale locale, java.lang.String pattern)
Integer
in the
given locale. The locale
parameter must be non-null.
object
- the Integer
to format into a stringlocale
- the Locale
to use for formattingpattern
- the DecimalFormat pattern to use for formatting
Integer
,
or empty string if the Integer
is nullDecimalFormat
public static java.lang.String getStringValue(java.lang.Integer object, java.util.Locale locale, boolean useGrouping)
Integer
in the
given locale. The locale
parameter must be non-null.
object
- the Integer
to format into a stringlocale
- the Locale
to use for formattinguseGrouping
- whether grouping characters should be used
Integer
,
or empty string if the Integer
is nullpublic static java.lang.String getStringValue(java.lang.Integer object, java.util.Locale locale, java.lang.String pattern, boolean useGrouping)
Integer
in the
given locale. The locale
parameter must be non-null.
object
- the Integer
to format into a stringlocale
- the Locale
to use for formattingpattern
- the DecimalFormat pattern to use for formattinguseGrouping
- whether grouping characters should be used
Integer
,
or empty string if the Integer
is nullDecimalFormat
public static java.lang.String getStringValue(int integer)
int
value in the
default locale.
integer
- the int
value to format into a string
int
public static java.lang.String getStringValue(int integer, java.util.Locale locale)
int
value in the
given locale. The locale
parameter must be non-null.
integer
- the int
value to format into a stringlocale
- the Locale
to use for formatting
int
public static java.lang.String getStringValue(int integer, java.util.Locale locale, java.lang.String pattern)
int
value in the
given locale. The locale
parameter must be non-null.
integer
- the int
value to format into a stringlocale
- the Locale
to use for formattingpattern
- the DecimalFormat pattern to use for formatting
int
DecimalFormat
public static java.lang.String getStringValue(int integer, java.util.Locale locale, boolean useGrouping)
int
value in the
given locale. The locale
parameter must be non-null.
integer
- the int
value to format into a stringlocale
- the Locale
to use for formattinguseGrouping
- whether grouping characters should be used
int
public static java.lang.String getStringValue(int integer, java.util.Locale locale, java.lang.String pattern, boolean useGrouping)
int
value in the
given locale. The locale
parameter must be non-null.
integer
- the int
value to format into a stringlocale
- the Locale
to use for formattingpattern
- the DecimalFormat pattern to use for formattinguseGrouping
- whether grouping characters should be used
int
DecimalFormat
public static int parseInt(java.lang.String string) throws java.text.ParseException
string
- the string to parse as an int
int
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
int
public static int parseIntNoOverflow(java.lang.String string) throws java.text.ParseException
string
- the string to parse as an int
int
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
int
or if the string causes an overflow / underflow
when parsed.public static int parseIntNoOverflow(java.lang.String string, java.util.Locale locale) throws java.text.ParseException
string
- the string to parse as an int
locale
- the locale to use for parsing.
int
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
int
or if the string causes an overflow / underflow
when parsed.public static int parseInt(java.lang.String string, java.util.Locale locale) throws java.text.ParseException
locale
.
string
- the string to parse as an int
locale
- the Locale
to use for parsing
int
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
int
public static int parseInt(java.lang.String string, java.util.Locale locale, java.lang.String pattern, boolean useGrouping) throws java.text.ParseException
locale
.
string
- the string to parse as an int
locale
- the Locale
to use for parsingpattern
- the DecimalFormat pattern to use for parsinguseGrouping
- whether grouping characters should be used
int
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
int
DecimalFormat
public static int parseInt(java.lang.String string, java.util.Locale locale, java.lang.String pattern, boolean useGrouping, boolean allowOverflow) throws java.text.ParseException
locale
.
string
- the string to parse as an int
locale
- the Locale
to use for parsingpattern
- the DecimalFormat pattern to use for parsinguseGrouping
- whether grouping characters should be usedallowOverflow
- if false, then thows ParseException if value is < Integer.MIN_VALUE or
Integer.MAX_VALUE > val
int
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
int
DecimalFormat
public static int parseInt(java.lang.String string, java.util.Locale locale, java.lang.String pattern, boolean useGrouping, boolean allowOverflow, boolean strictParsing, int minValue, int maxValue) throws java.text.ParseException
locale
.
string
- the string to parse as an int
locale
- the Locale
to use for parsingpattern
- the DecimalFormat pattern to use for parsinguseGrouping
- whether grouping characters should be usedallowOverflow
- if false, then thows ParseException if value is < Integer.MIN_VALUE or
Integer.MAX_VALUE > valstrictParsing
- if true, then throws ParseException if only a portion of the string was
evaluated to an integer. Example: "12 T" would evaluate to 12 if
strictParsing is false, but with the flag on, an exception would be thrownminValue
- the minimum valid integer value allowedmaxValue
- the maximum valid integer value allowed
int
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
int
DecimalFormat
public static int parseInt(char[] chars, int offset, int scan) throws java.text.ParseException
int
in the
default locale. The offset
and scan
parameters determine where in the character array to begin parsing,
and how many characters to use.
chars
- the character array to parse as an int
offset
- the index of the first character in the array to usescan
- the number of characters from the array to use
int
value derived from the array
java.text.ParseException
- if the character array cannot be parsed
as an int
public static int parseInt(java.lang.String string, int base) throws java.text.ParseException
int
in the
specified base
.
string
- the string to parse as an int
base
- the numeric base to use for parsing
int
value derived from the string
java.text.ParseException
- if the string cannot be parsed as an
int
in the specified basepublic static int parseInt(char[] chars, int offset, int scan, int base) throws java.text.ParseException
int
in the
given base
. The offset
and
scan
parameters determine where in the character array to
begin parsing, and how many characters to use.
chars
- the character array to parse as an int
offset
- the index of the first character in the array to usescan
- the number of characters from the array to usebase
- the numeric base to use for parsing
int
value derived from the array
java.text.ParseException
- if the character array cannot be parsed
as an int
in the specified basepublic static final int parseIntWithDefault(java.lang.String string, int defaultValue)
string
- a string representation of an IntegerdefaultValue
- the value to return if the string can not
be parsed
parseInt(String)
public static int getIntValue(java.lang.Object object)
int
value derived from the given object in the
default locale. If the object is not an Integer
, it is
converted to a string and parsed. Returns zero if the object can't be
converted to an int
.
object
- the object to convert to an int
value
int
derived from the given objectpublic static int compareIntegers(java.lang.Integer i1, java.lang.Integer i2)
Integer
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.
i1
- the first Integer
to comparei2
- the second Integer
to compare
int
value which determines how the two objects
should be orderedpublic static int compareInts(int i1, int i2)
int
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.
i1
- the first int
value to comparei2
- the second int
value to compare
int
value which determines how the two values
should be orderedpublic java.lang.Object getValue(java.lang.Object object, java.util.Locale locale)
Integer
derived from the given object in
the given locale. If the object is not an Integer
, it is
converted to a string and parsed. Returns null if the object can't be
parsed as a Integer
. The locale
parameter
is currently unused.
getValue
in class Formatter
object
- the object to convert to an Integer
locale
- the Locale
to use for conversion (unused)
Integer
derived from the given objectpublic int compareObjects(java.lang.Object o1, java.lang.Object o2, java.util.Locale locale)
Integer
objects. Returns a
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. The locale
parameter is currently unused.
o1
- the first Integer
to compareo2
- the second Integer
to comparelocale
- the Locale
to use for comparison (unused)
int
value which determines how the two
objects should be ordered
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |