ariba.util.formatter
Class LongFormatter

java.lang.Object
  extended by ariba.util.formatter.Formatter
      extended by ariba.util.formatter.LongFormatter
All Implemented Interfaces:
Compare, StringParser

public class LongFormatter
extends Formatter

LongFormatter is a subclass of Formatter which is responsible for formatting, parsing, and comparing long values and/or Long 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
LongFormatter()
          Creates a new LongFormatter.
 
Method Summary
static int compareLongs(long l1, long l2)
          Compares two long values for sorting purposes.
static int compareLongs(java.lang.Long l1, java.lang.Long l2)
          Compares two Long objects for sorting purposes.
static long getLongValue(java.lang.Object object)
          Returns a long value derived from the given object in the default locale.
static java.lang.String getStringValue(long value)
          Returns a formatted string for the given long value in the default locale.
static java.lang.String getStringValue(java.lang.Long object)
          Returns a formatted string for the given Long in the default locale.
static java.lang.String getStringValue(long value, java.util.Locale locale)
          Returns a formatted string for the given long value in the given locale.
static java.lang.String getStringValue(java.lang.Long object, java.util.Locale locale)
          Returns a formatted string for the given Long in the given locale.
static java.lang.String getStringValue(long value, java.util.Locale locale, boolean useGrouping)
          Returns a formatted string for the given long value in the given locale.
static java.lang.String getStringValue(java.lang.Long object, java.util.Locale locale, boolean useGrouping)
          Returns a formatted string for the given Long in the given locale.
static java.lang.String getStringValue(long value, java.util.Locale locale, java.lang.String pattern)
          Returns a formatted string for the given long value in the given locale.
static java.lang.String getStringValue(java.lang.Long object, java.util.Locale locale, java.lang.String pattern)
          Returns a formatted string for the given Long in the given locale.
static java.lang.String getStringValue(long value, java.util.Locale locale, java.lang.String pattern, boolean useGrouping)
          Returns a formatted string for the given long value in the given locale.
static java.lang.String getStringValue(java.lang.Long object, java.util.Locale locale, java.lang.String pattern, boolean useGrouping)
          Returns a formatted string for the given Long in the given locale.
 java.lang.Object getValue(java.lang.Object object, java.util.Locale locale)
          Returns a new Long derived from the given object in the given locale.
static long parseLong(java.lang.String string)
          Tries to parse the given string as a long in the default locale.
static long parseLong(java.lang.String string, java.util.Locale locale)
          Tries to parse the given string as a long in the given locale.
static long parseLong(java.lang.String string, java.util.Locale locale, java.lang.String pattern)
          Tries to parse the given string as a long in the given locale.
 
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

ClassName

public static final java.lang.String ClassName
Our Java class name.

See Also:
Constant Field Values
Constructor Detail

LongFormatter

public LongFormatter()
Creates a new LongFormatter.

Method Detail

getStringValue

public static java.lang.String getStringValue(java.lang.Long object)
Returns a formatted string for the given Long in the default locale.

Parameters:
object - the Long to format into a string
Returns:
a string representation of the Long

getStringValue

public static java.lang.String getStringValue(java.lang.Long object,
                                              java.util.Locale locale)
Returns a formatted string for the given Long in the given locale. The locale parameter must be non-null.

Parameters:
object - the Long to format into a string
locale - the Locale to use for formatting
Returns:
a string representation of the Long, or empty string if the Long is null

getStringValue

public static java.lang.String getStringValue(java.lang.Long object,
                                              java.util.Locale locale,
                                              java.lang.String pattern)
Returns a formatted string for the given Long in the given locale. The locale parameter must be non-null.

Parameters:
object - the Long to format into a string
locale - the Locale to use for formatting
pattern - the DecimalFormat pattern to use for formatting
Returns:
a string representation of the Long, or empty string if the Long is null
See Also:
DecimalFormat

getStringValue

public static java.lang.String getStringValue(java.lang.Long object,
                                              java.util.Locale locale,
                                              boolean useGrouping)
Returns a formatted string for the given Long in the given locale. The locale parameter must be non-null.

Parameters:
object - the Long to format into a string
locale - the Locale to use for formatting
useGrouping - whether grouping characters should be used
Returns:
a string representation of the Long, or empty string if the Long is null

getStringValue

public static java.lang.String getStringValue(java.lang.Long object,
                                              java.util.Locale locale,
                                              java.lang.String pattern,
                                              boolean useGrouping)
Returns a formatted string for the given Long in the given locale. The locale parameter must be non-null.

Parameters:
object - the Long to format into a string
locale - the Locale to use for formatting
pattern - the DecimalFormat pattern to use for formatting
useGrouping - whether grouping characters should be used
Returns:
a string representation of the Long, or empty string if the Long is null
See Also:
DecimalFormat

getStringValue

public static java.lang.String getStringValue(long value)
Returns a formatted string for the given long value in the default locale.

Parameters:
value - the long value to format into a string
Returns:
a string representation of the long

getStringValue

public static java.lang.String getStringValue(long value,
                                              java.util.Locale locale)
Returns a formatted string for the given long value in the given locale. The locale parameter must be non-null.

Parameters:
value - the long value to format into a string
locale - the Locale to use for formatting
Returns:
a string representation of the long

getStringValue

public static java.lang.String getStringValue(long value,
                                              java.util.Locale locale,
                                              java.lang.String pattern)
Returns a formatted string for the given long value in the given locale. The locale parameter must be non-null.

Parameters:
value - the long value to format into a string
locale - the Locale to use for formatting
pattern - the DecimalFormat pattern to use for formatting
Returns:
a string representation of the long
See Also:
DecimalFormat

getStringValue

public static java.lang.String getStringValue(long value,
                                              java.util.Locale locale,
                                              boolean useGrouping)
Returns a formatted string for the given long value in the given locale. The locale parameter must be non-null.

Parameters:
value - the long value to format into a string
locale - the Locale to use for formatting
useGrouping - whether grouping characters should be used
Returns:
a string representation of the long

getStringValue

public static java.lang.String getStringValue(long value,
                                              java.util.Locale locale,
                                              java.lang.String pattern,
                                              boolean useGrouping)
Returns a formatted string for the given long value in the given locale. The locale parameter must be non-null.

Parameters:
value - the long value to format into a string
locale - the Locale to use for formatting
pattern - the DecimalFormat pattern to use for formatting
useGrouping - whether grouping characters should be used
Returns:
a string representation of the long
See Also:
DecimalFormat

parseLong

public static long parseLong(java.lang.String string)
                      throws java.text.ParseException
Tries to parse the given string as a long in the default locale.

Parameters:
string - the string to parse as a long
Returns:
a long value derived from the string
Throws:
java.text.ParseException - if the string cannot be parsed as an long

parseLong

public static long parseLong(java.lang.String string,
                             java.util.Locale locale)
                      throws java.text.ParseException
Tries to parse the given string as a long in the given locale.

Parameters:
string - the string to parse as a long
locale - the Locale to use for parsing
Returns:
a long value derived from the string
Throws:
java.text.ParseException - if the string cannot be parsed as an long

parseLong

public static long parseLong(java.lang.String string,
                             java.util.Locale locale,
                             java.lang.String pattern)
                      throws java.text.ParseException
Tries to parse the given string as a long in the given locale.

Parameters:
string - the string to parse as a long
locale - the Locale to use for parsing
pattern - the DecimalFormat pattern to use for parsing
Returns:
a long value derived from the string
Throws:
java.text.ParseException - if the string cannot be parsed as an long
See Also:
DecimalFormat

getLongValue

public static long getLongValue(java.lang.Object object)
Returns a long value derived from the given object in the default locale. If the object is not a Long, it is converted to a string and parsed. Returns zero if the object can't be converted to a long.

Parameters:
object - the object to convert to an long value
Returns:
a long derived from the given object

compareLongs

public static int compareLongs(java.lang.Long l1,
                               java.lang.Long l2)
Compares two Long 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.

Parameters:
l1 - the first Long to compare
l2 - the second Long to compare
Returns:
int value which determines how the two objects should be ordered

compareLongs

public static int compareLongs(long l1,
                               long l2)
Compares two long 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.

Parameters:
l1 - the first long value to compare
l2 - the second long value to compare
Returns:
int value which determines how the two values should be ordered

getValue

public java.lang.Object getValue(java.lang.Object object,
                                 java.util.Locale locale)
Returns a new Long derived from the given object in the given locale. If the object is not a Long, it is converted to a string and parsed. Returns null if the object can't be parsed as a Long. The locale parameter is currently unused.

Specified by:
getValue in class Formatter
Parameters:
object - the object to convert to a Long
locale - the Locale to use for conversion (unused)
Returns:
a Long derived from the given object


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.