ariba.util.formatter
Class SystemBooleanFormatter

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

public class SystemBooleanFormatter
extends Formatter

SystemBooleanFormatter is a subclass of Formatter which is responsible for formatting, parsing, and comparing boolean values and/or Boolean objects.

The values produced will always be 'true' or 'false' no matter the locale being used.


Field Summary
static java.lang.String ClassName
          Our Java class name.
 
Fields inherited from interface ariba.util.core.Compare
EqualTo, GreaterThan, LessThan
 
Constructor Summary
SystemBooleanFormatter()
          Creates a new SystemBooleanFormatter.
 
Method Summary
static int compareBooleans(boolean b1, boolean b2)
          Compares two boolean values for sorting purposes.
static int compareBooleans(java.lang.Boolean b1, java.lang.Boolean b2)
          Compares two Boolean objects for sorting purposes.
static boolean getBooleanValue(java.lang.Object object)
          Returns a boolean value derived from the given object.
static java.lang.String getStringValue(java.lang.Boolean object)
          Returns a formatted string for the given Boolean object in the default locale.
static java.lang.String getStringValue(java.lang.Boolean object, java.util.Locale locale)
          Deprecated. use getStringValue(Boolean) instead.
 java.lang.Object getValue(java.lang.Object object, java.util.Locale locale)
          Returns a new Boolean derived from the given object.
static boolean parseBoolean(java.lang.String string)
          Parses the given string as a boolean value.
static java.lang.Boolean parseStringAsBoolean(java.lang.String string)
          Parses the given string as a Boolean value.
 
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

SystemBooleanFormatter

public SystemBooleanFormatter()
Creates a new SystemBooleanFormatter.

Method Detail

getStringValue

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

Parameters:
object - the Boolean object to format into a string
Returns:
a formatted string for the given Boolean

getStringValue

public static java.lang.String getStringValue(java.lang.Boolean object,
                                              java.util.Locale locale)
Deprecated. use getStringValue(Boolean) instead.

Returns a formatted string for the given Boolean object

Parameters:
object - the Boolean object to format into a string
locale - the Locale to use for formatting
Returns:
a formatted string for the given Boolean object in the given locale

parseBoolean

public static boolean parseBoolean(java.lang.String string)
Parses the given string as a boolean value. Returns true if and only if the given string is "true", or if the value is "BooleanTrue".

Parameters:
string - the String to parse
Returns:
true if the given string is "true"; false otherwise.

parseStringAsBoolean

public static java.lang.Boolean parseStringAsBoolean(java.lang.String string)
Parses the given string as a Boolean value. Returns Boolean.TRUE if and only if the given string is "true" or "BooleanTrue".

Parameters:
string - the String to parse
Returns:
Boolean.TRUE if the given string is "true"; Boolean.FALSE otherwise.

getBooleanValue

public static boolean getBooleanValue(java.lang.Object object)
Returns a boolean value derived from the given object. If the object is not a Boolean, it is converted to a string and compared against the string "true" or "BooleanTrue".

Parameters:
object - the object to covert to a boolean
Returns:
a boolean derived from the given object

compareBooleans

public static int compareBooleans(java.lang.Boolean b1,
                                  java.lang.Boolean b2)
Compares two Boolean 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. Sorts Boolean.TRUE before Boolean.FALSE.

Parameters:
b1 - the first Boolean to compare
b2 - the second Boolean to compare
Returns:
int value which determines how the two objects should be ordered

compareBooleans

public static int compareBooleans(boolean b1,
                                  boolean b2)
Compares two boolean values 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. Sorts true before false.

Parameters:
b1 - the first boolean to compare
b2 - the second boolean to compare
Returns:
int value which determines how the two objects should be ordered

getValue

public java.lang.Object getValue(java.lang.Object object,
                                 java.util.Locale locale)
Returns a new Boolean derived from the given object. If the object is not a Boolean, it is converted to a string and compared against the string "true".

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


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