Interface FormUtils
- All Known Implementing Classes:
FormUtilsImpl
public interface FormUtils
Interface for utility methods used by Struts Form classes.
When the application needs to create an instance that implements
FormUtils
, it calls
BusinessObjectFactory.createUtilsObject(java.lang.String)
,
which finds the name of the Java class to instantiate from the
"formUtilsImplemeter" setting in the appComponents.properties
file.
The default "formUtilsImplemeter" is
FormUtilsImpl
.
-
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).boolean
doCardTypeAndNumberMatch
(String type, String number) Given a credit card type and a number, checks that the number corresponds correctly with the type.void
eliminateDuplicateFacets
(SearchList searchList) html5OrXhtml
(javax.servlet.http.HttpServletRequest request, Settings settings) boolean
isCreditCardValid
(String creditCardNumber) Runs a given string through the Luhn algorithm to determine if it is a valid credit card number.boolean
Checks to see if a given string is in the form of a valid integer.boolean
isValidEmail
(String email) Checks to see if a given string is in the form of a valid email address.boolean
isValidPhone
(String phone) Checks to see if a given string is in the form of a valid phone number.boolean
isValidPostalCode
(String postalCode, String country) Checks to see if a given string is in the form of a valid postal code, given an associated country.void
removeAllNotInRequestFromMap
(Map incomingProperties, javax.servlet.http.HttpServletRequest request) void
removeNullsFromMap
(Map incomingProperties) void
removePrefixedKeysFromMap
(Map properties, String string) stringArrayAsURLParam
(String parameterName, String[] stringArray) boolean
stringArrayHasAnElement
(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
.boolean
stringArrayHasAnElement
(String[] paramValues) Determines if a given string array has at least one element and that it's of non-zero length.boolean
stringArrayValuesGreaterThan
(BaseDynaForm form, String property, int value) Determines if at least one element was submitted and is greater than a givenint
for a string array parameter of aBaseDynaForm
.boolean
stringArrayValuesGreaterThan
(String[] paramValues, int value) Determines if at least one element in a string array is greater than a given value.boolean
stringExists
(BaseDynaForm form, String property) Determines if a given parameter was included in the request for aBaseDynaForm
and is of non-zero length.boolean
stringValueGreaterThan
(BaseDynaForm form, String property, int value) Determines if a given parameter for aBaseDynaForm
is greater than a givenint
.boolean
stringValueLessThan
(BaseDynaForm form, String property, int value) Determines if a given parameter for aBaseDynaForm
is less than a givenint
.boolean
twoPropertiesEqual
(BaseDynaForm form, String property1, String property2) Determines if two string parameters submitted to aBaseDynaForm
exist and are equal.
-
Method Details
-
stringExists
Determines if a given parameter was included in the request for aBaseDynaForm
and is of non-zero length.- Parameters:
form
- TheBaseDynaForm
being processed.property
- The name of the parameter being tested.- Returns:
true
if the given parameter was submitted to the form and is of non-zero length.false
if not.
-
twoPropertiesEqual
Determines if two string parameters submitted to aBaseDynaForm
exist and are equal.- Parameters:
form
- TheBaseDynaForm
being processed.property1
- The first parameter to be tested.property2
- The second parameter to be tested.- Returns:
true
if the given parameters were submitted to the form and are equal.false
if not.
-
stringValueGreaterThan
Determines if a given parameter for aBaseDynaForm
is greater than a givenint
.- Parameters:
form
- TheBaseDynaForm
being processed.property
- The name of the parameter to be tested.value
- The value for the parameter to be tested against.- Returns:
true
if the given parameter is greater than the value.false
if not.
-
stringValueLessThan
Determines if a given parameter for aBaseDynaForm
is less than a givenint
.- Parameters:
form
- TheBaseDynaForm
being processed.property
- The name of the parameter to be tested.value
- The value for the parameter to be tested against.- Returns:
true
if the given parameter is less than the value.false
if not.
-
stringArrayHasAnElement
Determines if at least one element was submitted and is of non-zero length for a string array parameter of aBaseDynaForm
.- Parameters:
form
- TheBaseDynaForm
being processed.property
- The name of the parameter being tested.- Returns:
true
if the given parameter has at least one element and is of non-zero length.false
if not.
-
stringArrayValuesGreaterThan
Determines if at least one element was submitted and is greater than a givenint
for a string array parameter of aBaseDynaForm
.- Parameters:
form
- TheBaseDynaForm
being processed.property
- The name of the parameter being tested.value
- The value for the parameter to be tested against.- Returns:
true
if the given parameter has at least one element and is greater than the value.false
if not.
-
stringArrayHasAnElement
Determines if a given string array has at least one element and that it's of non-zero length.- Parameters:
paramValues
- The string array being tested.- Returns:
true
if the given string array has one element that's of non-zero length.
-
stringArrayValuesGreaterThan
Determines if at least one element in a string array is greater than a given value.- Parameters:
paramValues
- The string array being tested.value
- The value for the string array's elements to be tested against.- Returns:
true
if at least one element in a string array is greater than a given value.false
if not.
-
capitalize
Returns a new string with the first letter of a given string capitalized.- Parameters:
stringToCapitalize
- The string to capitalize.- Returns:
- A new string with the first letter capitalized.
-
isValidEmail
Checks 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]+
- Parameters:
email
- The string to be tested.- Returns:
true
if the given string matches a valid email address.
-
isValidPhone
Checks 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.- Parameters:
phone
- The string to be tested.- Returns:
true
if the given string matches a valid phone number.
-
isValidPostalCode
Checks 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.- Parameters:
postalCode
- The string to be tested.- Returns:
true
if the given string matches a valid postal code.
-
isInteger
Checks to see if a given string is in the form of a valid integer.- Parameters:
value
- The string to be tested.- Returns:
true
if the given string is a valid integer
-
isCreditCardValid
Runs a given string through the Luhn algorithm to determine if it is a valid credit card number.- Parameters:
creditCardNumber
- The credit card number- Returns:
- true, if the string is a valid credit card number; false, otherwise.
-
doCardTypeAndNumberMatch
Given a credit card type and a number, checks that the number corresponds correctly with the type.- 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
Given a credit card number, derive its type (Visa, Discover, MasterCard or AMEX).- Parameters:
number
- The credit card number- Returns:
- Four types supported: "VISA", "DISCOVER", "AMEX", and "MASTERCARD"
-
containsCharacter
Determines if a given string contains a character residing in another string.- 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
- Throws:
Exception
-
eliminateDuplicateFacets
-
removePrefixedKeysFromMap
-
removeNullsFromMap
-
removeAllNotInRequestFromMap
void removeAllNotInRequestFromMap(Map incomingProperties, javax.servlet.http.HttpServletRequest request) -
html5OrXhtml
-