Class FormUtilsImpl
java.lang.Object
com.softslate.commerce.customer.core.FormUtilsImpl
- All Implemented Interfaces:
FormUtils
FormUtilsImpl is the default implementation of the
FormUtils interface for the application.- Author:
- David Tobey
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncapitalize(String stringToCapitalize) Returns a new string with the first letter of a given string capitalized.containsCharacter(String string, String characters) Determines if a given string contains a character residing in another string.deriveCardType(String number) Given a credit card number, derive its type (Visa, Discover, MasterCard or AMEX).booleandoCardTypeAndNumberMatch(String type, String number) Given a credit card type and a number, checks that the number corresponds correctly with the type.voideliminateDuplicateFacets(SearchList searchList) html5OrXhtml(javax.servlet.http.HttpServletRequest request, Settings settings) booleanisCreditCardValid(String creditCardNumber) Runs a given string through the Luhn algorithm to determine if it is a valid credit card number.booleanChecks to see if a given string is in the form of a valid integer.booleanisValidEmail(String email) Checks to see if a given string is in the form of a valid email address.booleanisValidPhone(String phone) Checks to see if a given string is in the form of a valid phone number.booleanisValidPostalCode(String postalCode, String country) Checks to see if a given string is in the form of a valid postal code, given an associated country.voidremoveAllNotInRequestFromMap(Map map, javax.servlet.http.HttpServletRequest request) voidremoveNullsFromMap(Map map) voidremovePrefixedKeysFromMap(Map map, String prefix) stringArrayAsURLParam(String parameterName, String[] stringArray) booleanstringArrayHasAnElement(BaseDynaForm form, String property) Determines if at least one element was submitted and is of non-zero length for a string array parameter of aBaseDynaForm.booleanstringArrayHasAnElement(String[] paramValues) Determines if a given string array has at least one element and that it's of non-zero length.booleanstringArrayValuesGreaterThan(BaseDynaForm form, String property, int value) Determines if at least one element was submitted and is greater than a givenintfor a string array parameter of aBaseDynaForm.booleanstringArrayValuesGreaterThan(String[] paramValues, int value) Determines if at least one element in a string array is greater than a given value.booleanstringExists(BaseDynaForm form, String property) Determines if a given parameter was included in the request for aBaseDynaFormand is of non-zero length.booleanstringValueGreaterThan(BaseDynaForm form, String property, int value) Determines if a given parameter for aBaseDynaFormis greater than a givenint.booleanstringValueLessThan(BaseDynaForm form, String property, int value) Determines if a given parameter for aBaseDynaFormis less than a givenint.booleantwoPropertiesEqual(BaseDynaForm form, String property1, String property2) Determines if two string parameters submitted to aBaseDynaFormexist and are equal.
-
Field Details
-
log
static org.apache.commons.logging.Log log
-
-
Constructor Details
-
FormUtilsImpl
public FormUtilsImpl()
-
-
Method Details
-
stringExists
Description copied from interface:FormUtilsDetermines if a given parameter was included in the request for aBaseDynaFormand is of non-zero length.- Specified by:
stringExistsin interfaceFormUtils- Parameters:
form- TheBaseDynaFormbeing processed.property- The name of the parameter being tested.- Returns:
trueif the given parameter was submitted to the form and is of non-zero length.falseif not.
-
twoPropertiesEqual
Description copied from interface:FormUtilsDetermines if two string parameters submitted to aBaseDynaFormexist and are equal.- Specified by:
twoPropertiesEqualin interfaceFormUtils- Parameters:
form- TheBaseDynaFormbeing processed.property1- The first parameter to be tested.property2- The second parameter to be tested.- Returns:
trueif the given parameters were submitted to the form and are equal.falseif not.
-
stringValueGreaterThan
Description copied from interface:FormUtilsDetermines if a given parameter for aBaseDynaFormis greater than a givenint.- Specified by:
stringValueGreaterThanin interfaceFormUtils- Parameters:
form- TheBaseDynaFormbeing processed.property- The name of the parameter to be tested.value- The value for the parameter to be tested against.- Returns:
trueif the given parameter is greater than the value.falseif not.
-
stringValueLessThan
Description copied from interface:FormUtilsDetermines if a given parameter for aBaseDynaFormis less than a givenint.- Specified by:
stringValueLessThanin interfaceFormUtils- Parameters:
form- TheBaseDynaFormbeing processed.property- The name of the parameter to be tested.value- The value for the parameter to be tested against.- Returns:
trueif the given parameter is less than the value.falseif not.
-
stringArrayHasAnElement
Description copied from interface:FormUtilsDetermines if at least one element was submitted and is of non-zero length for a string array parameter of aBaseDynaForm.- Specified by:
stringArrayHasAnElementin interfaceFormUtils- Parameters:
form- TheBaseDynaFormbeing processed.property- The name of the parameter being tested.- Returns:
trueif the given parameter has at least one element and is of non-zero length.falseif not.
-
stringArrayValuesGreaterThan
Description copied from interface:FormUtilsDetermines if at least one element was submitted and is greater than a givenintfor a string array parameter of aBaseDynaForm.- Specified by:
stringArrayValuesGreaterThanin interfaceFormUtils- Parameters:
form- TheBaseDynaFormbeing processed.property- The name of the parameter being tested.value- The value for the parameter to be tested against.- Returns:
trueif the given parameter has at least one element and is greater than the value.falseif not.
-
stringArrayHasAnElement
Description copied from interface:FormUtilsDetermines if a given string array has at least one element and that it's of non-zero length.- Specified by:
stringArrayHasAnElementin interfaceFormUtils- Parameters:
paramValues- The string array being tested.- Returns:
trueif the given string array has one element that's of non-zero length.
-
stringArrayValuesGreaterThan
Description copied from interface:FormUtilsDetermines if at least one element in a string array is greater than a given value.- Specified by:
stringArrayValuesGreaterThanin interfaceFormUtils- Parameters:
paramValues- The string array being tested.value- The value for the string array's elements to be tested against.- Returns:
trueif at least one element in a string array is greater than a given value.falseif not.
-
capitalize
Description copied from interface:FormUtilsReturns a new string with the first letter of a given string capitalized.- Specified by:
capitalizein interfaceFormUtils- Parameters:
stringToCapitalize- The string to capitalize.- Returns:
- A new string with the first letter capitalized.
-
isValidEmail
Description copied from interface:FormUtilsChecks to see if a given string is in the form of a valid email address. Uses the following regular expression for the test:.+@.+\\.[a-z]+- Specified by:
isValidEmailin interfaceFormUtils- Parameters:
email- The string to be tested.- Returns:
trueif the given string matches a valid email address.
-
isValidPhone
Description copied from interface:FormUtilsChecks to see if a given string is in the form of a valid phone number. Since phone numbers may be U.S. or international in format, and may or may not have an extension, only a light check is done ensuring that at least 10 digits are present.- Specified by:
isValidPhonein interfaceFormUtils- Parameters:
phone- The string to be tested.- Returns:
trueif the given string matches a valid phone number.
-
isValidPostalCode
Description copied from interface:FormUtilsChecks to see if a given string is in the form of a valid postal code, given an associated country. If the country is US, a simple check on the number of digits is done.- Specified by:
isValidPostalCodein interfaceFormUtils- Parameters:
postalCode- The string to be tested.- Returns:
trueif the given string matches a valid postal code.
-
isInteger
Description copied from interface:FormUtilsChecks to see if a given string is in the form of a valid integer. -
isCreditCardValid
Description copied from interface:FormUtilsRuns a given string through the Luhn algorithm to determine if it is a valid credit card number.- Specified by:
isCreditCardValidin interfaceFormUtils- Parameters:
creditCardNumber- The credit card number- Returns:
- true, if the string is a valid credit card number; false, otherwise.
-
doCardTypeAndNumberMatch
Description copied from interface:FormUtilsGiven a credit card type and a number, checks that the number corresponds correctly with the type.- Specified by:
doCardTypeAndNumberMatchin interfaceFormUtils- Parameters:
type- Four types supported: "VISA", "DISCOVER", "AMEX", and "MASTERCARD"number- The credit card number- Returns:
- true if the card type matches the number or if the card type is not supported.
-
deriveCardType
Description copied from interface:FormUtilsGiven a credit card number, derive its type (Visa, Discover, MasterCard or AMEX).- Specified by:
deriveCardTypein interfaceFormUtils- Parameters:
number- The credit card number- Returns:
- Four types supported: "VISA", "DISCOVER", "AMEX", and "MASTERCARD"
-
containsCharacter
Description copied from interface:FormUtilsDetermines if a given string contains a character residing in another string.- Specified by:
containsCharacterin interfaceFormUtils- Parameters:
string- The string to check againstcharacters- A String containing each of the characters to check- Returns:
- the first matching Character, if the string contains one of the characters, otherwise null
-
stringArrayAsURLParam
- Specified by:
stringArrayAsURLParamin interfaceFormUtils- Throws:
Exception
-
eliminateDuplicateFacets
- Specified by:
eliminateDuplicateFacetsin interfaceFormUtils
-
removeNullsFromMap
- Specified by:
removeNullsFromMapin interfaceFormUtils
-
removeAllNotInRequestFromMap
- Specified by:
removeAllNotInRequestFromMapin interfaceFormUtils
-
removePrefixedKeysFromMap
- Specified by:
removePrefixedKeysFromMapin interfaceFormUtils
-
html5OrXhtml
- Specified by:
html5OrXhtmlin interfaceFormUtils
-