|
|||||||||
| 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 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(Integer i1,
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(Object o1,
Object o2,
Locale locale)
Compares two objects for sorting purposes in the given locale. |
static int |
getIntValue(Object object)
Returns an int value derived from the given object in the
default locale. |
static String |
getStringValue(int integer)
Returns a formatted string for the given int value in the
default locale. |
static String |
getStringValue(Integer object)
Returns a formatted string for the given Integer in the
default locale. |
static String |
getStringValue(Integer object,
Locale locale)
Returns a formatted string for the given Integer in the
given locale. |
static String |
getStringValue(Integer object,
Locale locale,
boolean useGrouping)
Returns a formatted string for the given Integer in the
given locale. |
static String |
getStringValue(Integer object,
Locale locale,
String pattern)
Returns a formatted string for the given Integer in the
given locale. |
static String |
getStringValue(Integer object,
Locale locale,
String pattern,
boolean useGrouping)
Returns a formatted string for the given Integer in the
given locale. |
static String |
getStringValue(int integer,
Locale locale)
Returns a formatted string for the given int value in the
given locale. |
static String |
getStringValue(int integer,
Locale locale,
boolean useGrouping)
Returns a formatted string for the given int value in the
given locale. |
static String |
getStringValue(int integer,
Locale locale,
String pattern)
Returns a formatted string for the given int value in the
given locale. |
static String |
getStringValue(int integer,
Locale locale,
String pattern,
boolean useGrouping)
Returns a formatted string for the given int value in the
given locale. |
Object |
getValue(Object object,
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(String string)
Tries to parse the given string as an integer in the default locale. |
static int |
parseInt(String string,
int base)
Tries to parse the given string as an int in the
specified base. |
static int |
parseInt(String string,
Locale locale)
Tries to parse the given string as an integer in the given locale. |
static int |
parseInt(String string,
Locale locale,
String pattern,
boolean useGrouping)
Tries to parse the given string as an integer in the given locale. |
static int |
parseInt(String string,
Locale locale,
String pattern,
boolean useGrouping,
boolean allowOverflow)
Tries to parse the given string as an integer in the given locale. |
static int |
parseInt(String string,
Locale locale,
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(String string)
Tries to parse the given string as an integer in the default locale. |
static int |
parseIntNoOverflow(String string,
Locale locale)
Tries to parse the given string as an integer in the specified locale. |
static int |
parseIntWithDefault(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, 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 IntegerFormatter()
IntegerFormatter.
| Method Detail |
|---|
public static String getStringValue(Integer object)
Integer in the
default locale.
object - the Integer to format into a string
Integer
public static String getStringValue(Integer object,
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 null
public static String getStringValue(Integer object,
Locale locale,
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 String getStringValue(Integer object,
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 null
public static String getStringValue(Integer object,
Locale locale,
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 nullDecimalFormatpublic static String getStringValue(int integer)
int value in the
default locale.
integer - the int value to format into a string
int
public static String getStringValue(int integer,
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 String getStringValue(int integer,
Locale locale,
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
intDecimalFormat
public static String getStringValue(int integer,
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 String getStringValue(int integer,
Locale locale,
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
intDecimalFormat
public static int parseInt(String string)
throws ParseException
string - the string to parse as an int
int value derived from the string
ParseException - if the string cannot be parsed as an
int
public static int parseIntNoOverflow(String string)
throws ParseException
string - the string to parse as an int
int value derived from the string
ParseException - if the string cannot be parsed as an
int or if the string causes an overflow / underflow
when parsed.
public static int parseIntNoOverflow(String string,
Locale locale)
throws ParseException
string - the string to parse as an intlocale - the locale to use for parsing.
int value derived from the string
ParseException - if the string cannot be parsed as an
int or if the string causes an overflow / underflow
when parsed.
public static int parseInt(String string,
Locale locale)
throws ParseException
locale.
string - the string to parse as an intlocale - the Locale to use for parsing
int value derived from the string
ParseException - if the string cannot be parsed as an
int
public static int parseInt(String string,
Locale locale,
String pattern,
boolean useGrouping)
throws ParseException
locale.
string - the string to parse as an intlocale - 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
ParseException - if the string cannot be parsed as an
intDecimalFormat
public static int parseInt(String string,
Locale locale,
String pattern,
boolean useGrouping,
boolean allowOverflow)
throws ParseException
locale.
string - the string to parse as an intlocale - 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
ParseException - if the string cannot be parsed as an
intDecimalFormat
public static int parseInt(String string,
Locale locale,
String pattern,
boolean useGrouping,
boolean allowOverflow,
boolean strictParsing,
int minValue,
int maxValue)
throws ParseException
locale.
string - the string to parse as an intlocale - 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
ParseException - if the string cannot be parsed as an
intDecimalFormat
public static int parseInt(char[] chars,
int offset,
int scan)
throws 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 intoffset - 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
ParseException - if the character array cannot be parsed
as an int
public static int parseInt(String string,
int base)
throws ParseException
int in the
specified base.
string - the string to parse as an intbase - the numeric base to use for parsing
int value derived from the string
ParseException - if the string cannot be parsed as an
int in the specified base
public static int parseInt(char[] chars,
int offset,
int scan,
int base)
throws 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 intoffset - 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
ParseException - if the character array cannot be parsed
as an int in the specified base
public static final int parseIntWithDefault(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(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 object
public static int compareIntegers(Integer i1,
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 ordered
public 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 ordered
public Object getValue(Object object,
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 Formatterobject - the object to convert to an Integerlocale - the Locale to use for conversion (unused)
Integer derived from the given object
public int compareObjects(Object o1,
Object o2,
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 | ||||||||