com.guiseframework.validator
Class PANValidator

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.event.GuiseBoundPropertyObject
          extended by com.guiseframework.validator.AbstractValidator<com.globalmentor.iso.idcard.PAN>
              extended by com.guiseframework.validator.PANValidator
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, Validator<com.globalmentor.iso.idcard.PAN>

public class PANValidator
extends AbstractValidator<com.globalmentor.iso.idcard.PAN>

A validator to validate a Primary Account Number (PAN) of an identification card as defined in ISO/IEC 7812-1:2000(E), "Identification cards - Identification of issuers - Part 1: Numbering system". The validator ensures that the PAN represents one of the allowed ID card products. PANs for unknown products are considered invalid.

See Also:
IDCard

Field Summary
static java.lang.String VALID_PRODUCTS_PROPERTY
          The valid products bound property.
 
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
 
Fields inherited from interface com.guiseframework.validator.Validator
INVALID_VALUE_MESSAGE_PROPERTY, VALUE_REQUIRED_MESSAGE_PROPERTY, VALUE_REQUIRED_PROPERTY
 
Constructor Summary
PANValidator(boolean valueRequired)
          Value required constructor accepting all known products.
PANValidator(boolean valueRequired, com.globalmentor.iso.idcard.Product... validProducts)
          Value required and valid products constructor.
PANValidator(com.globalmentor.iso.idcard.Product... validProducts)
          Valid products constructor with no value required.
 
Method Summary
 java.util.Set<com.globalmentor.iso.idcard.Product> getValidProducts()
           
 void setValidProducts(com.globalmentor.iso.idcard.Product... validProducts)
          Sets the PAN products that the validator considers valid.
 void setValidProducts(java.util.Set<com.globalmentor.iso.idcard.Product> newValidProducts)
          Sets the PAN products that the validator considers valid.
 void validate(com.globalmentor.iso.idcard.PAN value)
          Checks whether a given value is valid, and throws an exception if not.
 
Methods inherited from class com.guiseframework.validator.AbstractValidator
getInvalidValueMessage, getValueRequiredMessage, isValid, isValueRequired, setInvalidValueMessage, setValueRequired, setValueRequiredMessage, throwInvalidValueValidationException, throwValueRequiredValidationException, toString
 
Methods inherited from class com.guiseframework.event.GuiseBoundPropertyObject
getSession
 
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.guiseframework.validator.Validator
getSession
 
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 

Field Detail

VALID_PRODUCTS_PROPERTY

public static final java.lang.String VALID_PRODUCTS_PROPERTY
The valid products bound property.

Constructor Detail

PANValidator

public PANValidator(com.globalmentor.iso.idcard.Product... validProducts)
Valid products constructor with no value required.

Parameters:
validProducts - The products that are allowed, if any.
Throws:
java.lang.NullPointerException - if the given array of valid products is null.

PANValidator

public PANValidator(boolean valueRequired)
Value required constructor accepting all known products.

Parameters:
valueRequired - Whether the value must be non-null in order to be considered valid.

PANValidator

public PANValidator(boolean valueRequired,
                    com.globalmentor.iso.idcard.Product... validProducts)
Value required and valid products constructor.

Parameters:
valueRequired - Whether the value must be non-null in order to be considered valid.
validProducts - The products that are allowed, if any.
Throws:
java.lang.NullPointerException - if the given array of valid products is null.
Method Detail

getValidProducts

public java.util.Set<com.globalmentor.iso.idcard.Product> getValidProducts()
Returns:
The read-only set of valid products.

setValidProducts

public void setValidProducts(java.util.Set<com.globalmentor.iso.idcard.Product> newValidProducts)
Sets the PAN products that the validator considers valid. This is a bound property.

Parameters:
newValidProducts - The set of valid products.
Throws:
java.lang.NullPointerException - if the given set of valid products is null.
See Also:
VALID_PRODUCTS_PROPERTY

setValidProducts

public void setValidProducts(com.globalmentor.iso.idcard.Product... validProducts)
Sets the PAN products that the validator considers valid. This is a bound property. This implementation delegates to setValidProducts(Set)

Parameters:
validProducts - The products that are allowed, if any.
Throws:
java.lang.NullPointerException - if the given array of valid products is null.
See Also:
VALID_PRODUCTS_PROPERTY

validate

public void validate(com.globalmentor.iso.idcard.PAN value)
              throws ValidationException
Checks whether a given value is valid, and throws an exception if not. This version determines whether a given PAN represents one of the supported products and is the correct length.

Specified by:
validate in interface Validator<com.globalmentor.iso.idcard.PAN>
Overrides:
validate in class AbstractValidator<com.globalmentor.iso.idcard.PAN>
Parameters:
value - The value to validate.
Throws:
ValidationException - if the provided value is not valid.
See Also:
AbstractValidator.throwInvalidValueValidationException(Object), AbstractValidator.throwValueRequiredValidationException(Object)


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.