org.apache.commons.lang
クラス BooleanUtils

java.lang.Object
  拡張org.apache.commons.lang.BooleanUtils

public class BooleanUtils
extends Object

Operations on boolean primitives and Boolean objects.

This class tries to handle null input gracefully. An exception will not be thrown for a null input. Each method documents its behaviour in more detail.

導入されたバージョン:
2.0
バージョン:
$Id: BooleanUtils.java,v 1.1.1.1 2004/02/13 10:02:05 hioki Exp $
作成者:
Stephen Colebourne, Matthew Hawthorne, Gary Gregory
翻訳状況:
訳者募集中

コンストラクタの概要
BooleanUtils()
          BooleanUtils instances should NOT be constructed in standard programming.
 
メソッドの概要
static Boolean negate(Boolean bool)
          Negates the specified boolean.
static boolean toBoolean(Boolean bool)
          Converts a Boolean to a boolean handling null by returning false.
static boolean toBoolean(int value)
          Converts an int to a boolean using the convention that zero is false.
static boolean toBoolean(Integer value, Integer trueValue, Integer falseValue)
          Converts an Integer to a boolean specifying the conversion values.
static boolean toBoolean(int value, int trueValue, int falseValue)
          Converts an int to a boolean specifying the conversion values.
static boolean toBoolean(String str)
          Converts a String to a boolean.
static boolean toBoolean(String str, String trueString, String falseString)
          Converts a String to a Boolean throwing an exception if no match found.
static boolean toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull)
          Converts a Boolean to a boolean handling null.
static Boolean toBooleanObject(boolean bool)
          Boolean factory that avoids creating new Boolean objecs all the time.
static Boolean toBooleanObject(int value)
          Converts an int to a Boolean using the convention that zero is false.
static Boolean toBooleanObject(Integer value)
          Converts an Integer to a Boolean using the convention that zero is false.
static Boolean toBooleanObject(Integer value, Integer trueValue, Integer falseValue, Integer nullValue)
          Converts an Integer to a Boolean specifying the conversion values.
static Boolean toBooleanObject(int value, int trueValue, int falseValue, int nullValue)
          Converts an int to a Boolean specifying the conversion values.
static Boolean toBooleanObject(String str)
          Converts a String to a Boolean.
static Boolean toBooleanObject(String str, String trueString, String falseString, String nullString)
          Converts a String to a Boolean throwing an exception if no match.
static int toInteger(boolean bool)
          Converts a boolean to an int using the convention that zero is false.
static int toInteger(boolean bool, int trueValue, int falseValue)
          Converts a boolean to an int specifying the conversion values.
static int toInteger(Boolean bool, int trueValue, int falseValue, int nullValue)
          Converts a Boolean to an int specifying the conversion values.
static Integer toIntegerObject(boolean bool)
          Converts a boolean to an Integer using the convention that zero is false.
static Integer toIntegerObject(Boolean bool)
          Converts a Boolean to a Integer using the convention that zero is false.
static Integer toIntegerObject(boolean bool, Integer trueValue, Integer falseValue)
          Converts a boolean to an Integer specifying the conversion values.
static Integer toIntegerObject(Boolean bool, Integer trueValue, Integer falseValue, Integer nullValue)
          Converts a Boolean to an Integer specifying the conversion values.
static String toString(boolean bool, String trueString, String falseString)
          Converts a boolean to a String returning one of the input Strings.
static String toString(Boolean bool, String trueString, String falseString, String nullString)
          Converts a Boolean to a String returning one of the input Strings.
static String toStringOnOff(boolean bool)
          Converts a boolean to a String returning 'on' or 'off'.
static String toStringOnOff(Boolean bool)
          Converts a Boolean to a String returning 'on', 'off', or null.
static String toStringTrueFalse(boolean bool)
          Converts a boolean to a String returning 'true' or 'false'.
static String toStringTrueFalse(Boolean bool)
          Converts a Boolean to a String returning 'true', 'false', or null.
static String toStringYesNo(boolean bool)
          Converts a boolean to a String returning 'yes' or 'no'.
static String toStringYesNo(Boolean bool)
          Converts a Boolean to a String returning 'yes', 'no', or null.
static boolean xor(boolean[] array)
          Performs an xor on a set of booleans.
static Boolean xor(Boolean[] array)
          Performs an xor on an array of Booleans.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

BooleanUtils

public BooleanUtils()

BooleanUtils instances should NOT be constructed in standard programming. Instead, the class should be used as BooleanUtils.toBooleanObject(true);.

This constructor is public to permit tools that require a JavaBean instance to operate.

メソッドの詳細

negate

public static Boolean negate(Boolean bool)

Negates the specified boolean.

If null is passed in, null will be returned.

パラメータ:
bool - the Boolean to negate, may be null
戻り値:
the negated Boolean, or null if null input

toBooleanObject

public static Boolean toBooleanObject(boolean bool)

Boolean factory that avoids creating new Boolean objecs all the time.

This method was added to JDK1.4 but is available here for earlier JDKs.

パラメータ:
bool - the boolean to convert
戻り値:
Boolean.TRUE or Boolean.FALSE as appropriate

toBoolean

public static boolean toBoolean(Boolean bool)

Converts a Boolean to a boolean handling null by returning false.

パラメータ:
bool - the boolean to convert
戻り値:
true or false, null returns false

toBooleanDefaultIfNull

public static boolean toBooleanDefaultIfNull(Boolean bool,
                                             boolean valueIfNull)

Converts a Boolean to a boolean handling null.

パラメータ:
bool - the boolean to convert
valueIfNull - the boolean value to return if null
戻り値:
true or false

toBoolean

public static boolean toBoolean(int value)

Converts an int to a boolean using the convention that zero is false.

パラメータ:
value - the int to convert
戻り値:
true if non-zero, false if zero

toBooleanObject

public static Boolean toBooleanObject(int value)

Converts an int to a Boolean using the convention that zero is false.

パラメータ:
value - the int to convert
戻り値:
Boolean.TRUE if non-zero, Boolean.FALSE if zero, null if null

toBooleanObject

public static Boolean toBooleanObject(Integer value)

Converts an Integer to a Boolean using the convention that zero is false.

null will be converted to null.

パラメータ:
value - the Integer to convert
戻り値:
Boolean.TRUE if non-zero, Boolean.FALSE if zero, null if null input

toBoolean

public static boolean toBoolean(int value,
                                int trueValue,
                                int falseValue)

Converts an int to a boolean specifying the conversion values.

パラメータ:
value - the Integer to convert
trueValue - the value to match for true
falseValue - the value to match for false
戻り値:
true or false
例外:
IllegalArgumentException - if no match

toBoolean

public static boolean toBoolean(Integer value,
                                Integer trueValue,
                                Integer falseValue)

Converts an Integer to a boolean specifying the conversion values.

パラメータ:
value - the Integer to convert
trueValue - the value to match for true, may be null
falseValue - the value to match for false, may be null
戻り値:
true or false
例外:
IllegalArgumentException - if no match

toBooleanObject

public static Boolean toBooleanObject(int value,
                                      int trueValue,
                                      int falseValue,
                                      int nullValue)

Converts an int to a Boolean specifying the conversion values.

パラメータ:
value - the Integer to convert
trueValue - the value to match for true
falseValue - the value to match for false
nullValue - the value to to match for null
戻り値:
Boolean.TRUE, Boolean.FALSE, or null
例外:
IllegalArgumentException - if no match

toBooleanObject

public static Boolean toBooleanObject(Integer value,
                                      Integer trueValue,
                                      Integer falseValue,
                                      Integer nullValue)

Converts an Integer to a Boolean specifying the conversion values.

パラメータ:
value - the Integer to convert
trueValue - the value to match for true, may be null
falseValue - the value to match for false, may be null
nullValue - the value to to match for null, may be null
戻り値:
Boolean.TRUE, Boolean.FALSE, or null
例外:
IllegalArgumentException - if no match

toInteger

public static int toInteger(boolean bool)

Converts a boolean to an int using the convention that zero is false.

パラメータ:
bool - the boolean to convert
戻り値:
one if true, zero if false

toIntegerObject

public static Integer toIntegerObject(boolean bool)

Converts a boolean to an Integer using the convention that zero is false.

パラメータ:
bool - the boolean to convert
戻り値:
one if true, zero if false

toIntegerObject

public static Integer toIntegerObject(Boolean bool)

Converts a Boolean to a Integer using the convention that zero is false.

null will be converted to null.

パラメータ:
bool - the Boolean to convert
戻り値:
one if Boolean.TRUE, zero if Boolean.FALSE, null if null

toInteger

public static int toInteger(boolean bool,
                            int trueValue,
                            int falseValue)

Converts a boolean to an int specifying the conversion values.

パラメータ:
bool - the to convert
trueValue - the value to return if true
falseValue - the value to return if false
戻り値:
the appropriate value

toInteger

public static int toInteger(Boolean bool,
                            int trueValue,
                            int falseValue,
                            int nullValue)

Converts a Boolean to an int specifying the conversion values.

パラメータ:
bool - the Boolean to convert
trueValue - the value to return if true
falseValue - the value to return if false
nullValue - the value to return if null
戻り値:
the appropriate value

toIntegerObject

public static Integer toIntegerObject(boolean bool,
                                      Integer trueValue,
                                      Integer falseValue)

Converts a boolean to an Integer specifying the conversion values.

パラメータ:
bool - the to convert
trueValue - the value to return if true, may be null
falseValue - the value to return if false, may be null
戻り値:
the appropriate value

toIntegerObject

public static Integer toIntegerObject(Boolean bool,
                                      Integer trueValue,
                                      Integer falseValue,
                                      Integer nullValue)

Converts a Boolean to an Integer specifying the conversion values.

パラメータ:
bool - the Boolean to convert
trueValue - the value to return if true, may be null
falseValue - the value to return if false, may be null
nullValue - the value to return if null, may be null
戻り値:
the appropriate value

toBooleanObject

public static Boolean toBooleanObject(String str)

Converts a String to a Boolean.

'true', 'on' or 'yes' (case insensitive) will return true. 'false', 'off' or 'no' (case insensitive) will return false. Otherwise, null is returned.

パラメータ:
str - the String to check
戻り値:
the Boolean value of the string, null if no match or null input

toBooleanObject

public static Boolean toBooleanObject(String str,
                                      String trueString,
                                      String falseString,
                                      String nullString)

Converts a String to a Boolean throwing an exception if no match.

パラメータ:
str - the String to check
trueString - the String to match for true (case sensitive), may be null
falseString - the String to match for false (case sensitive), may be null
nullString - the String to match for null (case sensitive), may be null
戻り値:
the Boolean value of the string, null if no match or null input

toBoolean

public static boolean toBoolean(String str)

Converts a String to a boolean.

'true', 'on' or 'yes' (case insensitive) will return true. Otherwise, false is returned.

パラメータ:
str - the String to check
戻り値:
the boolean value of the string, false if no match

toBoolean

public static boolean toBoolean(String str,
                                String trueString,
                                String falseString)

Converts a String to a Boolean throwing an exception if no match found.

null is returned if there is no match.

パラメータ:
str - the String to check
trueString - the String to match for true (case sensitive), may be null
falseString - the String to match for false (case sensitive), may be null
戻り値:
the boolean value of the string
例外:
IllegalArgumentException - if the String doesn't match

toStringTrueFalse

public static String toStringTrueFalse(Boolean bool)

Converts a Boolean to a String returning 'true', 'false', or null.

パラメータ:
bool - the Boolean to check
戻り値:
'true', 'false', or null

toStringOnOff

public static String toStringOnOff(Boolean bool)

Converts a Boolean to a String returning 'on', 'off', or null.

パラメータ:
bool - the Boolean to check
戻り値:
'on', 'off', or null

toStringYesNo

public static String toStringYesNo(Boolean bool)

Converts a Boolean to a String returning 'yes', 'no', or null.

パラメータ:
bool - the Boolean to check
戻り値:
'yes', 'no', or null

toString

public static String toString(Boolean bool,
                              String trueString,
                              String falseString,
                              String nullString)

Converts a Boolean to a String returning one of the input Strings.

パラメータ:
bool - the Boolean to check
trueString - the String to return if true, may be null
falseString - the String to return if false, may be null
nullString - the String to return if null, may be null
戻り値:
one of the three input Strings

toStringTrueFalse

public static String toStringTrueFalse(boolean bool)

Converts a boolean to a String returning 'true' or 'false'.

パラメータ:
bool - the Boolean to check
戻り値:
'true', 'false', or null

toStringOnOff

public static String toStringOnOff(boolean bool)

Converts a boolean to a String returning 'on' or 'off'.

パラメータ:
bool - the Boolean to check
戻り値:
'on', 'off', or null

toStringYesNo

public static String toStringYesNo(boolean bool)

Converts a boolean to a String returning 'yes' or 'no'.

パラメータ:
bool - the Boolean to check
戻り値:
'yes', 'no', or null

toString

public static String toString(boolean bool,
                              String trueString,
                              String falseString)

Converts a boolean to a String returning one of the input Strings.

パラメータ:
bool - the Boolean to check
trueString - the String to return if true, may be null
falseString - the String to return if false, may be null
戻り値:
one of the two input Strings

xor

public static boolean xor(boolean[] array)

Performs an xor on a set of booleans.

パラメータ:
array - an array of booleans
戻り値:
true if the xor is successful.
例外:
IllegalArgumentException - if array is null
IllegalArgumentException - if array is empty.

xor

public static Boolean xor(Boolean[] array)

Performs an xor on an array of Booleans.

パラメータ:
array - an array of Booleans
戻り値:
true if the xor is successful.
例外:
IllegalArgumentException - if array is null
IllegalArgumentException - if array is empty.
IllegalArgumentException - if array contains a null


このドキュメントは、Ja-Jakartaにより訳されました。 コメントがある場合は report@jajakarta.orgまでお願いします。
Translated into Japanese by jajakarta.org. The original page is here.
Copyright (c) 2002-2003 - Apache Software Foundation