|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.nucleus.logging.VariableArgumentApplicationLoggingImpl atg.nucleus.GenericService atg.commerce.util.AddressValidatorImpl
public class AddressValidatorImpl
This class provides a default implementation of AddressValidator. By default the following address properties are checked :
If the address is an instance of atg.core.util.ContactInfo, the following properties may also be checked:
Field Summary | |
---|---|
static java.lang.String |
ADDRESS1_MISSING
|
static java.lang.String |
CITY_MISSING
|
static java.lang.String |
CLASS_VERSION
Class version string |
static java.lang.String |
COUNTRY_MISSING
|
static java.lang.String |
COUNTY_MISSING
|
static java.lang.String |
EMAIL_INVALID
|
static java.lang.String |
EMAIL_MISSING
|
static java.lang.String |
ERROR_MAP_KEY
|
static java.lang.String |
FAX_NUMBER_INVALID
|
static java.lang.String |
FAX_NUMBER_MISSING
|
static java.lang.String |
FIRST_NAME_MISSING
|
static java.lang.String |
LAST_NAME_MISSING
|
protected java.lang.String[] |
mCountriesWithStates
|
protected boolean |
mValidateAddress1
|
protected boolean |
mValidateCity
|
protected boolean |
mValidateCountry
|
protected boolean |
mValidateCounty
|
protected boolean |
mValidateEmail
|
protected boolean |
mValidateFaxNumber
|
protected boolean |
mValidateFirstName
|
protected boolean |
mValidateLastName
|
protected boolean |
mValidatePhoneNumber
|
protected boolean |
mValidatePostalCode
|
protected boolean |
mValidateState
|
static java.lang.String |
PHONE_NUMBER_INVALID
|
static java.lang.String |
PHONE_NUMBER_MISSING
|
static java.lang.String |
POSTAL_CODE_MISSING
|
static java.lang.String |
RESOURCE_MAP_KEY
|
static java.lang.String |
STATE_MISSING
|
Fields inherited from class atg.nucleus.GenericService |
---|
SERVICE_INFO_KEY |
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging |
---|
DEFAULT_LOG_TRACE_STATUS |
Fields inherited from interface atg.nucleus.logging.ApplicationLogging |
---|
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS |
Constructor Summary | |
---|---|
AddressValidatorImpl()
|
Method Summary | |
---|---|
protected java.util.Map |
addError(java.lang.String pKey,
java.util.ResourceBundle pResources,
java.util.Map pResourceAndErrorKeyMaps,
java.util.Map pErrors)
This method looks up the resourced error message in the resource bundle and adds the error message to the map. |
protected void |
addHashedError(PipelineResult pResult,
java.lang.String pKey,
java.lang.String pId,
java.lang.Object pError)
This method adds an error to the PipelineResult object. |
boolean |
countryNeedsState(java.lang.String pCountry)
Determine whether a state is required based on the country by consulting the property countriesWithStates . |
java.lang.String[] |
getCountriesWithStates()
Return the list of countries for which a state or province is required to have a valid shipping address. |
boolean |
getValidateAddress1()
Returns property validateAddress1 |
boolean |
getValidateCity()
Returns property validateCity |
boolean |
getValidateCountry()
Returns the validateCountry flag |
boolean |
getValidateCounty()
Returns property validateCounty |
boolean |
getValidateEmail()
Returns the validateEmail flag |
boolean |
getValidateFaxNumber()
Returns the validateFaxNumber flag |
boolean |
getValidateFirstName()
Returns property validateFirstName |
boolean |
getValidateLastName()
Returns property validateLastName |
boolean |
getValidatePhoneNumber()
Returns the validatePhoneNumber flag |
boolean |
getValidatePostalCode()
Returns property validatePostalCode |
boolean |
getValidateState()
Returns property validateState |
boolean |
isEmpty(java.lang.String pStr)
Return true if pStr is null or consists entirely of whitespace. |
void |
setCountriesWithStates(java.lang.String[] pCountriesWithStates)
Specify the set of countries for which a state or province name is required in order to have a valid address. |
void |
setValidateAddress1(boolean pValidateAddress1)
Sets property validateAddress1 |
void |
setValidateCity(boolean pValidateCity)
Sets property validateCity |
void |
setValidateCountry(boolean pValidateCountry)
Sets the validateCountry flag. |
void |
setValidateCounty(boolean pValidateCounty)
Sets property validateCounty |
void |
setValidateEmail(boolean pValidateEmail)
Sets the validateEmail flag. |
void |
setValidateFaxNumber(boolean pValidateFaxNumber)
Sets the validateFaxNumber flag. |
void |
setValidateFirstName(boolean pValidateFirstName)
Sets property validateFirstName |
void |
setValidateLastName(boolean pValidateLastName)
Sets property validateLastName |
void |
setValidatePhoneNumber(boolean pValidatePhoneNumber)
Sets the validatePhoneNumber flag. |
void |
setValidatePostalCode(boolean pValidatePostalCode)
Sets property validatePostalCode |
void |
setValidateState(boolean pValidateState)
Sets property validateState |
java.util.Collection |
validateAddress(Address pAddress)
Verify that all required properties are present in an address. |
java.util.Collection |
validateAddress(Address pAddress,
java.util.Locale pLocale)
Verify that all required properties are present in an address. |
java.util.Collection |
validateAddress(Address pAddress,
java.util.ResourceBundle pResources)
Verify that all required properties are present in an address. |
protected java.util.Map |
validateAddress(Address pAddress,
java.util.ResourceBundle pResources,
java.util.Map pResourceAndErrorKeyMaps)
Based on the component configuration, this method validates the necessary fields and collects and returns all error messages. |
protected void |
validateAddress(Address pAddress,
java.lang.String pId,
PipelineResult pResult,
java.util.ResourceBundle pResources,
java.util.Map pResourceAndErrorKeyMaps)
This method is added here to share the code between ShippingAddrValidatorImpl and BillingAddrValidatorImpl . |
boolean |
validateEmailAddress(java.lang.String pEmail)
Validates an email address for correctness. |
boolean |
validatePhoneNumber(java.lang.String pPhoneNumber)
Validates a phone number for correctness. |
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl |
---|
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
public static final java.lang.String FIRST_NAME_MISSING
public static final java.lang.String LAST_NAME_MISSING
public static final java.lang.String ADDRESS1_MISSING
public static final java.lang.String CITY_MISSING
public static final java.lang.String COUNTY_MISSING
public static final java.lang.String STATE_MISSING
public static final java.lang.String POSTAL_CODE_MISSING
public static final java.lang.String COUNTRY_MISSING
public static final java.lang.String PHONE_NUMBER_MISSING
public static final java.lang.String PHONE_NUMBER_INVALID
public static final java.lang.String EMAIL_MISSING
public static final java.lang.String EMAIL_INVALID
public static final java.lang.String FAX_NUMBER_MISSING
public static final java.lang.String FAX_NUMBER_INVALID
public static final java.lang.String RESOURCE_MAP_KEY
public static final java.lang.String ERROR_MAP_KEY
protected boolean mValidateFirstName
protected boolean mValidateLastName
protected boolean mValidateAddress1
protected boolean mValidateCity
protected boolean mValidateCounty
protected boolean mValidateState
protected boolean mValidatePostalCode
protected boolean mValidateCountry
protected boolean mValidatePhoneNumber
protected boolean mValidateFaxNumber
protected boolean mValidateEmail
protected java.lang.String[] mCountriesWithStates
Constructor Detail |
---|
public AddressValidatorImpl()
Method Detail |
---|
public boolean getValidateFirstName()
public void setValidateFirstName(boolean pValidateFirstName)
pValidateFirstName
- the value to set for property validateFirstNamepublic boolean getValidateLastName()
public void setValidateLastName(boolean pValidateLastName)
pValidateLastName
- the value to set for property validateLastNamepublic boolean getValidateAddress1()
public void setValidateAddress1(boolean pValidateAddress1)
pValidateAddress1
- the value to set for property validateAddress1public boolean getValidateCity()
public void setValidateCity(boolean pValidateCity)
pValidateCity
- the value to set for property validateCitypublic boolean getValidateCounty()
public void setValidateCounty(boolean pValidateCounty)
pValidateCounty
- the value to set for property validateCountypublic boolean getValidateState()
public void setValidateState(boolean pValidateState)
pValidateState
- the value to set for property validateStatepublic boolean getValidatePostalCode()
public void setValidatePostalCode(boolean pValidatePostalCode)
pValidatePostalCode
- the value to set for property validatePostalCodepublic boolean getValidateCountry()
public void setValidateCountry(boolean pValidateCountry)
public boolean getValidatePhoneNumber()
public void setValidatePhoneNumber(boolean pValidatePhoneNumber)
public boolean getValidateFaxNumber()
public void setValidateFaxNumber(boolean pValidateFaxNumber)
public boolean getValidateEmail()
public void setValidateEmail(boolean pValidateEmail)
public void setCountriesWithStates(java.lang.String[] pCountriesWithStates)
This property is a list of countries that are supported by the site for which a state (province) field is required in order to have a valid address. For example, "usa" and "canada" might go on this list, but "germany" would not.
The country names in this list should be lower case and must be spelled as they would be spelled when the user enters or selects them. If the user chooses a country from a menu it is easy to make this list consistent with user input. If the user provides the name through a text input field, this list should contain common variations and misspellings, since the value in the list must match the user's input exactly except. Comparisons are case-insensitive, so it is not necessary to include all possible combinations of capitalization in this list.
public java.lang.String[] getCountriesWithStates()
public java.util.Collection validateAddress(Address pAddress)
validateAddress
in interface AddressValidator
pAddress
- The address being examined.
validateAddress(Address, ResourceBundle)
public java.util.Collection validateAddress(Address pAddress, java.util.Locale pLocale)
validateAddress
in interface AddressValidator
pAddress
- The address being examined.pLocale
- The optional locale to use when looking up the resource bundle
that contains error messages. If null, the default server locale
will be used.
validateAddress(Address, ResourceBundle)
public java.util.Collection validateAddress(Address pAddress, java.util.ResourceBundle pResources)
validateAddress
in interface AddressValidator
pAddress
- The address being examined.pResources
- The resource bundle from which to retrieve error messages.
validateAddress(Address, ResourceBundle, Map)
public boolean countryNeedsState(java.lang.String pCountry)
countriesWithStates
.
pCountry
- The country name being queried. If null, assume the country does
require a state or province designation as part of the shipping
address.
public boolean validatePhoneNumber(java.lang.String pPhoneNumber)
public boolean validateEmailAddress(java.lang.String pEmail)
public boolean isEmpty(java.lang.String pStr)
protected java.util.Map validateAddress(Address pAddress, java.util.ResourceBundle pResources, java.util.Map pResourceAndErrorKeyMaps)
For Example, If the component is configured to validate first and last name, then this method validates the first and last name. Also if there is any error message in the validation, all the error message is collected and returned.
pAddress
- The address being examined.pResources
- The resource bundle to look up error messages.pResourceAndErrorKeyMaps
- The optional alternate resource and error key map. This is used in ShippingAddrValidatorImpl
and BillingAddrValidatorImpl
. These classes pass in alternate resource and error key maps.
-- This method adds the error message to the map
protected void validateAddress(Address pAddress, java.lang.String pId, PipelineResult pResult, java.util.ResourceBundle pResources, java.util.Map pResourceAndErrorKeyMaps)
ShippingAddrValidatorImpl
and BillingAddrValidatorImpl
.
This method first gets the validated error message and loops through the error message and adds the error message to the
PipelineResult
object.
pAddress
- The address being examinedpId
- The id of the object that owns the address, used in
constructing error messages. For example, when validating the
address in a credit card, the caller might provide the credit card
id here.pResult
- A PipelineResult object in which to store error messages if any
required values are missing from the address.pResources
- The resource bundle to look up error messages.pResourceAndErrorKeyMaps
- The optional alternate resource and error key map. This is used in ShippingAddrValidatorImpl
and BillingAddrValidatorImpl
. These classes pass in alternate resource and error key maps.-- This method collects all the error messages with error keys.
,
-- This method adds the error messages to the PipelineResult
protected java.util.Map addError(java.lang.String pKey, java.util.ResourceBundle pResources, java.util.Map pResourceAndErrorKeyMaps, java.util.Map pErrors)
pResourceAndErrorKeyMaps
)is passed in, use the alternate
keys to look up the error message in the resource bundle and save the error message in the map using the error key.
Alternatively if this map is not passed in then this method uses the key lookup the error message and the same
key is used to save the error message in the map.
pKey
- The key to find the resourced error message or locate the alternate resource and error key.
If the pResourceAndErrorKeyMaps
is passed in, then the resource key is used to find the
resourced error message and the error key is used to save the error message.pResources
- The resource bundle to lookup error message.pResourceAndErrorKeyMaps
- This map contains two maps. One for the resource and other for error keys.pErrors
- This map contains the error key and resourced error message.
protected void addHashedError(PipelineResult pResult, java.lang.String pKey, java.lang.String pId, java.lang.Object pError)
pResult
- the PipelineResult object supplied in runProcess()pKey
- the key to use to store the HashMap in the PipelineResult objectpId
- the key to use to store the error message within the HashMap in the
PipelineResult objectpError
- the error object to store in the HashMapPipelineResult
,
#runProcess(Object, PipelineResult)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |