org.gjt.rec.util
Class Booleans

java.lang.Object
  |
  +--org.gjt.rec.util.Booleans

public final class Booleans
extends Object

A toolbox of tools that work with boolean and Boolean.

See Also:
Boolean

Nested Class Summary
static class Booleans.FlagType
           
 
Field Summary
static String REVISION
           
 
Method Summary
static Boolean parse(String flagString)
          Works out the Boolean value represented by a particular string.
static Boolean parse(String flagString, Booleans.FlagType flagType)
          Works out the Boolean value represented by a particular string using a particular flag convention.
static boolean parseBoolean(String flagString)
          Works out the boolean value represented by a particular string.
static boolean parseBoolean(String flagString, Booleans.FlagType flagType)
          Works out the boolean value represented by a particular string using a particular flag convention.
static String toString(boolean booleanValue, Booleans.FlagType flagType)
          Converts a particular boolean value to its string representation using a particular flag convention.
static String toString(Boolean b, Booleans.FlagType flagType)
          Converts a particular Boolean value to its string representation using a particular flag convention.
static Boolean wrap(boolean booleanValue)
          Returns an instance of Boolean representing a particular boolean value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values
Method Detail

wrap

public static Boolean wrap(boolean booleanValue)
Returns an instance of Boolean representing a particular boolean value. The same instance will be used for all true boolean values, i.e. the Boolean objects are flyweighted.

Parameters:
booleanValue - the boolean value to wrap
Returns:
the Boolean representing booleanValue

parse

public static Boolean parse(String flagString)
                     throws ParseException
Works out the Boolean value represented by a particular string.

Parameters:
flagString - the string in which to look for a boolean value representation
Returns:
the Boolean value represented by flagString or null if flagString is null
Throws:
ParseException - if flagString represents neither true, false nor null

parse

public static Boolean parse(String flagString,
                            Booleans.FlagType flagType)
                     throws ParseException
Works out the Boolean value represented by a particular string using a particular flag convention.

Parameters:
flagString - the string in which to look for a boolean value representation
flagType - the flag convention to use when parsing the boolean string representation. true or false values in other conventions will result in a ParseException
Throws:
NullPointerException - if flagType is null
ParseException - if flagString represents neither true, false nor null

parseBoolean

public static boolean parseBoolean(String flagString)
                            throws ParseException
Works out the boolean value represented by a particular string.

Parameters:
flagString - the string in which to look for a boolean value representation
Throws:
NullPointerException - if flagString is null
ParseException - if flagString represents neither true nor false

parseBoolean

public static boolean parseBoolean(String flagString,
                                   Booleans.FlagType flagType)
                            throws ParseException
Works out the boolean value represented by a particular string using a particular flag convention.

Parameters:
flagString - the string in which to look for a boolean value representation
flagType - the flag convention to use when parsing the boolean string representation. true or false values in other conventions will result in a ParseException
Throws:
NullPointerException - if flagString is null
ParseException - if flagString represents neither true nor false

toString

public static String toString(Boolean b,
                              Booleans.FlagType flagType)
Converts a particular Boolean value to its string representation using a particular flag convention.

Parameters:
flagType - the flag convention to use
b - the value to convert
Returns:
the string representation of b or null if b is null
Throws:
NullPointerException - if flagType is null

toString

public static String toString(boolean booleanValue,
                              Booleans.FlagType flagType)
Converts a particular boolean value to its string representation using a particular flag convention.

Parameters:
flagType - the flag convention to use
booleanValue - the value to convert
Returns:
the string representation of booleanValue
Throws:
NullPointerException - if flagType is null