org.apache.commons.validator
クラス GenericValidator

java.lang.Object
  拡張org.apache.commons.validator.GenericValidator
すべての実装インタフェース:
Serializable

public class GenericValidator
extends Object
implements Serializable

このクラスは妥当性チェックを行う基本的なメソッドを持ちます。

バージョン:
$Revision: 1.1.1.1 $ $Date: 2004/02/13 10:02:01 $
作成者:
David Winterfeldt, James Turner
関連項目:
直列化された形式
翻訳者:
日置 聡

フィールドの概要
static String REGEXP_DELIM
          Delimiter to put around a regular expression following Perl 5 syntax.
 
コンストラクタの概要
GenericValidator()
           
 
メソッドの概要
protected static String getDelimittedRegexp(String regexp)
          Adds a '/' on either side of the regular expression.
static boolean isBlankOrNull(String value)
          Checks if the field isn't null and length of the field is greater than zero not including whitespace.
static boolean isByte(String value)
          Checks if the value can safely be converted to a byte primitive.
static boolean isCreditCard(String value)
          Checks if the field is a valid credit card number.
static boolean isDate(String value, Locale locale)
          Checks if the field is a valid date.
static boolean isDate(String value, String datePattern, boolean strict)
          Checks if the field is a valid date.
static boolean isDouble(String value)
          Checks if the value can safely be converted to a double primitive.
static boolean isEmail(String value)
          Checks if a field has a valid e-mail address.
static boolean isFloat(String value)
          Checks if the value can safely be converted to a float primitive.
static boolean isInRange(double value, double min, double max)
          Checks if a value is within a range (min & max specified in the vars attribute).
static boolean isInRange(float value, float min, float max)
          Checks if a value is within a range (min & max specified in the vars attribute).
static boolean isInRange(int value, int min, int max)
          Checks if a value is within a range (min & max specified in the vars attribute).
static boolean isInRange(short value, short min, short max)
          Checks if a value is within a range (min & max specified in the vars attribute).
static boolean isInt(String value)
          Checks if the value can safely be converted to a int primitive.
static boolean isLong(String value)
          Checks if the value can safely be converted to a long primitive.
static boolean isShort(String value)
          Checks if the value can safely be converted to a short primitive.
static boolean matchRegexp(String value, String regexp)
          Checks if the value matches the regular expression.
static boolean maxLength(String value, int max)
          Checks if the value's length is less than or equal to the max.
static boolean minLength(String value, int min)
          Checks if the value's length is greater than or equal to the min.
protected static boolean validateCreditCardLuhnCheck(String cardNumber)
          Checks for a valid credit card number.
protected static boolean validateCreditCardPrefixCheck(String cardNumber)
          Checks for a valid credit card number.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

REGEXP_DELIM

public static final String REGEXP_DELIM
Delimiter to put around a regular expression following Perl 5 syntax.

関連項目:
定数フィールド値
コンストラクタの詳細

GenericValidator

public GenericValidator()
メソッドの詳細

isBlankOrNull

public static boolean isBlankOrNull(String value)

Checks if the field isn't null and length of the field is greater than zero not including whitespace.

パラメータ:
value - The value validation is being performed on.

matchRegexp

public static boolean matchRegexp(String value,
                                  String regexp)

Checks if the value matches the regular expression.

パラメータ:
value - The value validation is being performed on.
regexp - The regular expression.

isByte

public static boolean isByte(String value)

Checks if the value can safely be converted to a byte primitive.

パラメータ:
value - The value validation is being performed on.

isShort

public static boolean isShort(String value)

Checks if the value can safely be converted to a short primitive.

パラメータ:
value - The value validation is being performed on.

isInt

public static boolean isInt(String value)

Checks if the value can safely be converted to a int primitive.

パラメータ:
value - The value validation is being performed on.

isLong

public static boolean isLong(String value)

Checks if the value can safely be converted to a long primitive.

パラメータ:
value - The value validation is being performed on.

isFloat

public static boolean isFloat(String value)

Checks if the value can safely be converted to a float primitive.

パラメータ:
value - The value validation is being performed on.

isDouble

public static boolean isDouble(String value)

Checks if the value can safely be converted to a double primitive.

パラメータ:
value - The value validation is being performed on.

isDate

public static boolean isDate(String value,
                             Locale locale)

Checks if the field is a valid date. The Locale is used with java.text.DateFormat. The setLenient method is set to false for all.

パラメータ:
value - The value validation is being performed on.
locale - The locale to use for the date format, defaults to the default system default if null.

isDate

public static boolean isDate(String value,
                             String datePattern,
                             boolean strict)

Checks if the field is a valid date. The pattern is used with java.text.SimpleDateFormat. If strict is true, then the length will be checked so '2/12/1999' will not pass validation with the format 'MM/dd/yyyy' because the month isn't two digits. The setLenient method is set to false for all.

パラメータ:
value - The value validation is being performed on.
datePattern - The pattern passed to SimpleDateFormat.
strict - Whether or not to have an exact match of the datePattern.

isInRange

public static boolean isInRange(int value,
                                int min,
                                int max)

Checks if a value is within a range (min & max specified in the vars attribute).

パラメータ:
value - The value validation is being performed on.
min - The minimum value of the range.
max - The maximum value of the range.

isInRange

public static boolean isInRange(float value,
                                float min,
                                float max)

Checks if a value is within a range (min & max specified in the vars attribute).

パラメータ:
value - The value validation is being performed on.
min - The minimum value of the range.
max - The maximum value of the range.

isInRange

public static boolean isInRange(short value,
                                short min,
                                short max)

Checks if a value is within a range (min & max specified in the vars attribute).

パラメータ:
value - The value validation is being performed on.
min - The minimum value of the range.
max - The maximum value of the range.

isInRange

public static boolean isInRange(double value,
                                double min,
                                double max)

Checks if a value is within a range (min & max specified in the vars attribute).

パラメータ:
value - The value validation is being performed on.
min - The minimum value of the range.
max - The maximum value of the range.

isCreditCard

public static boolean isCreditCard(String value)

Checks if the field is a valid credit card number.

Translated to Java by Ted Husted (husted@apache.org).
    Reference Sean M. Burke's script at http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl

パラメータ:
value - The value validation is being performed on.

validateCreditCardLuhnCheck

protected static boolean validateCreditCardLuhnCheck(String cardNumber)

Checks for a valid credit card number.

Translated to Java by Ted Husted (husted@apache.org).
    Reference Sean M. Burke's script at http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl

パラメータ:
cardNumber - Credit Card Number

validateCreditCardPrefixCheck

protected static boolean validateCreditCardPrefixCheck(String cardNumber)

Checks for a valid credit card number.

Translated to Java by Ted Husted (husted@apache.org).
    Reference Sean M. Burke's script at http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl

パラメータ:
cardNumber - Credit Card Number

isEmail

public static boolean isEmail(String value)

Checks if a field has a valid e-mail address.

Based on a script by Sandeep V. Tamhankar (stamhankar@hotmail.com), http://javascript.internet.com

パラメータ:
value - The value validation is being performed on.

maxLength

public static boolean maxLength(String value,
                                int max)

Checks if the value's length is less than or equal to the max.

パラメータ:
value - The value validation is being performed on.
max - The maximum length.

minLength

public static boolean minLength(String value,
                                int min)

Checks if the value's length is greater than or equal to the min.

パラメータ:
value - The value validation is being performed on.
min - The minimum length.

getDelimittedRegexp

protected static String getDelimittedRegexp(String regexp)
Adds a '/' on either side of the regular expression.



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