net.sf.valjax
Class AbstractBlackListValidator

java.lang.Object
  extended by net.sf.valjax.AbstractValidator
      extended by net.sf.valjax.AbstractBlackListValidator
All Implemented Interfaces:
InitializingBean, Validator

public abstract class AbstractBlackListValidator
extends AbstractValidator
implements InitializingBean

Provides validation for a configured black list file.

Implements afterPropertiesSet using the black list file from setBlacklistFile and loads the contents into a HashSet that is used to validate values against. Each line in the blacklist is its own entry in the HashSet.

Concrete implementations of this class need to follow the contract stated in the Validator interface. Concrete classes can also provide there own blacklist files, which will override the default blacklist file.

This is a one blackListFile per Validator setup. You can use the default blacklist file or you can supply your own, but you can not use both.

Author:
Zach Legein
See Also:
Validator

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Fields inherited from class net.sf.valjax.AbstractValidator
NAME_PATTERN_1, NAME_PATTERN_2, PATTERN_ADDRESS, PATTERN_ALPHA, PATTERN_ALPHANUMERIC, PATTERN_CURRENCY, PATTERN_DATE, PATTERN_DIGITS, PATTERN_FAX, PATTERN_MONTH, PATTERN_MONTH_YEAR, PATTERN_NUMBER, PATTERN_PHONE, PATTERN_YEAR, PATTERN_ZIP
 
Constructor Summary
AbstractBlackListValidator()
           
 
Method Summary
 void afterPropertiesSet()
          Loads the blackListFile in a HashSet that will be used to validate against.
 Boolean isBlackListEmail(String value)
          Validates whether an email is on the blacklist or not.
 Boolean isBlackListValue(String value)
          Validates whether an value is on the blacklist or not.
 void setBlackListFile(String blackListFile)
          The name of the blacklist file to load from the classpath.
 
Methods inherited from class net.sf.valjax.AbstractValidator
isAddress, isAlpha, isAlphaNumeric, isCurrency, isDate, isDigits, isFamilyName, isFax, isGivenName, isMonth, isMonthYear, isNumber, isPhone, isYear, isZip, validateCustom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.validation.Validator
supports, validate
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Constructor Detail

AbstractBlackListValidator

public AbstractBlackListValidator()
Method Detail

isBlackListEmail

public Boolean isBlackListEmail(String value)
Validates whether an email is on the blacklist or not.

Strips the email address using the '@' symbol and check each piece to see if it is on the blacklist.

Parameters:
value - The String to check.
Returns:
Whether value is on the blacklist or not.

isBlackListValue

public Boolean isBlackListValue(String value)
Validates whether an value is on the blacklist or not.

Parameters:
value - The input to validate.
Returns:
Whether value is on the blacklist or not.

afterPropertiesSet

public void afterPropertiesSet()
Loads the blackListFile in a HashSet that will be used to validate against.

BlackListFile is taken from the claspath fed into an InputStreamReader as an InputStream. Concrete implementation of this class can supply their own blackList file or can use the default, but you can not use both.

Specified by:
afterPropertiesSet in interface InitializingBean

setBlackListFile

public void setBlackListFile(String blackListFile)
The name of the blacklist file to load from the classpath.

Parameters:
blackListFile - The blacklist file to load.


Copyright © 2007. All Rights Reserved.