fh.global.util.formatting
Class HTTPInputValidation

java.lang.Object
  extended by fh.global.util.formatting.HTTPInputValidation

public class HTTPInputValidation
extends java.lang.Object


Constructor Summary
HTTPInputValidation()
           
 
Method Summary
static boolean formatBoolean(java.lang.String input, boolean defaultValue, java.lang.String trueValue, java.lang.String falseValue)
          This method takes in a string and tries to convert it to a boolean value, if the input string is equal to the trueValue string then true is returned, if the input string is equal to the falseValue string then false if returned, in all other cases the default value will be returned.
static int formatInt(java.lang.String input, int defaultValue)
          This method takes in a string and formats it into a number, if the string is null or not a valid number then the default value is returned.
static java.lang.String formatParamNoQuote(java.lang.String input)
          This method takes in an input as a string, if null it returns a new string which is blank.
static java.lang.String formatParamYesQuote(java.lang.String input)
          This method will format a string so it can safley be put in an SQL statement, but it will preserve the quotes that are used in it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPInputValidation

public HTTPInputValidation()
Method Detail

formatParamNoQuote

public static java.lang.String formatParamNoQuote(java.lang.String input)
This method takes in an input as a string, if null it returns a new string which is blank. if the string is not null then any single quotes from the string are removed then then the string is returned

Parameters:
input - The input string to validate
Returns:
The formatted and corrected string, this will never be null

formatInt

public static int formatInt(java.lang.String input,
                            int defaultValue)
This method takes in a string and formats it into a number, if the string is null or not a valid number then the default value is returned.

Parameters:
input - The string value to be formatted as an int
defaultValue - The value that should be returned if the string is null or not numeric
Returns:
The formatted int value

formatBoolean

public static boolean formatBoolean(java.lang.String input,
                                    boolean defaultValue,
                                    java.lang.String trueValue,
                                    java.lang.String falseValue)
This method takes in a string and tries to convert it to a boolean value, if the input string is equal to the trueValue string then true is returned, if the input string is equal to the falseValue string then false if returned, in all other cases the default value will be returned.

Parameters:
input - The input string to convert to boolean
defaultValue - The default value to return if the input can not be determined
trueValue - The value that the input must equal for true to be returned
falseValue - The value that the input must equal for false to be returned
Returns:
The parsed boolean value of the input.

formatParamYesQuote

public static java.lang.String formatParamYesQuote(java.lang.String input)
This method will format a string so it can safley be put in an SQL statement, but it will preserve the quotes that are used in it

Parameters:
input - The input to parse
Returns:
The formatted String