net.sourceforge.argval
Interface ArgumentValidation

All Known Implementing Classes:
ArgumentValidationImpl

public interface ArgumentValidation


Field Summary
static String VALIDATION_TYPE_NAME_ARGUMENT
           
static String VALIDATION_TYPE_NAME_PROPERTY_KEY
           
 
Method Summary
 void addError(String error)
          Add an error message to the list of error messages.
 void addError(String argumentName, String message)
          Add an error message, for the given argumentName, to the list of error messages.
 void addError(String argumentName, String key, String message)
          Add an error message, for when the argument is a Map instance, to the list of error messages, for the given key.
 boolean containsIllegalArgument()
          Returns true if there are arguments checked (through one of the methods isValidXxxxx), that did not full fill the condition of that validation check, otherwise false.
 IllegalArgumentException createIllegalArgumentException()
          Creates an IllegalArgumentException with a detailed message about which arguments did not satisfy the required conditions.
 String getMessage()
          Creates a message about all the validated conditions which are not satisfied.
 Map<String,String> getPattern()
          Returns the Map of pattern names and their regular expression.
 org.apache.oro.text.regex.Pattern getPattern(String patternName)
          Returns the Pattern found under the patternName, or throws an IllegalArgumentException if the patternName is not available.
 Set<String> getPatternNames()
          Returns the Set of pattern names.
 String getRegularExpression(String patternName)
          Returns the regular expression found under the patternName, or throws an IllegalArgumentException if the patternName is not available.
 boolean isValidCollectionWhenMinElements(String argumentName, Collection<?> argumentValue, int minElements)
          Validates if the Collection argumentValue is at least containing the minimal number of elements (minElements).
 boolean isValidCollectionWhenNoNulls(String argumentName, Collection<?> argumentValue)
          Validates if the Collection argumentValue is not null and that its containing elements are also not null.
 boolean isValidMatchingDateFormat(String argumentName, String argumentValue, DateFormat dateFormat)
          Validates if the String argumentValue matches the dateFormat.
 boolean isValidMatchingDateFormat(String argumentName, String argumentValue, String dateFormatName)
          Validates if the String argumentValue matches the date format registered under the dateFormatName.
 boolean isValidMatchingPattern(String argumentName, String argumentValue, String patternName)
          Validates if the String argumentValue matches the pattern regisstered under the patternName.
 boolean isValidNotNullForKey(String string, Map<String,String> dataModelIdMap, String keyDataVendor)
           
 boolean isValidStringLength(String argumentName, String argumentValue, int length)
          Validates if the String argumentValue has an exact length of length.
 boolean isValidStringMaxLength(String argumentName, String argumentValue, int maxLength)
          Validates if the String argumentValue has a maximum length of maxLength.
 boolean isValidStringMinAndMaxLength(String argumentName, String argumentValue, int minLength, int maxLength)
          Validates if the String argumentValue has a minimal length of minLength and a maximum length of maxLength.
 boolean isValidStringMinLength(String argumentName, String argumentValue, int minLength)
          Validates if the String argumentValue has a minimal length of minLength.
 boolean isValidWhenBoolean(String argumentName, String argumentValue)
          Validates if the String argumentValue contains the text true or false.
 boolean isValidWhenDirectory(String argumentName, File argumentValue)
           
 boolean isValidWhenDirectory(String argumentName, String argumentValue)
          Validates if the String argumentValue is a directory.
 boolean isValidWhenFile(String argumentName, File argumentValue)
           
 boolean isValidWhenFile(String argumentName, String argumentValue)
          Validates if the String argumentValue is a file.
 boolean isValidWhenGreaterThen(String argumentName, int argumentValue, int value)
          Validates if the Integer argumentValue is greate then Integer value.
 boolean isValidWhenInSet(String argumentName, String argumentValue, Set<String> argumentSet)
          Validates if the String argumentValue is an element contained by the Set argumentSet.
 boolean isValidWhenInteger(String argumentName, String argumentValue)
          Validates if the String argumentValue is an Integer value.
 boolean isValidWhenLong(String argumentName, String argumentValue)
          Validates if the String argumentValue is a Long value.
 boolean isValidWhenNotInSet(String argumentName, String argumentValue, Set<String> argumentSet)
          Validates if the String argumentValue is not already contained by the Set argumentSet.
 boolean isValidWhenNotNull(String argumentName, Object argumentValue)
          Validates if the String argumentValue contains an instance reference (is not null).
 boolean isValidWhenNotNullInCollection(String string, Collection<?> collection)
           
 boolean isValidWhenUri(String argumentName, String argumentValue)
          Validates if the String argumentValue is an valid uri.
 boolean isValidWhenUrl(String argumentName, String argumentValue)
          Validates if the String argumentValue is an valid url.
 

Field Detail

VALIDATION_TYPE_NAME_ARGUMENT

static final String VALIDATION_TYPE_NAME_ARGUMENT
See Also:
Constant Field Values

VALIDATION_TYPE_NAME_PROPERTY_KEY

static final String VALIDATION_TYPE_NAME_PROPERTY_KEY
See Also:
Constant Field Values
Method Detail

getMessage

String getMessage()
Creates a message about all the validated conditions which are not satisfied.

Returns:
The message containing the details about the not met conditions.

containsIllegalArgument

boolean containsIllegalArgument()
Returns true if there are arguments checked (through one of the methods isValidXxxxx), that did not full fill the condition of that validation check, otherwise false.

Returns:
true if not all validated conditions are satisfied, otherwise false.

createIllegalArgumentException

IllegalArgumentException createIllegalArgumentException()
Creates an IllegalArgumentException with a detailed message about which arguments did not satisfy the required conditions.

Returns:
a new IllegalArgumentException
See Also:
getMessage()

isValidWhenNotNull

boolean isValidWhenNotNull(String argumentName,
                           Object argumentValue)
Validates if the String argumentValue contains an instance reference (is not null).

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
Returns:
true if the condition is met, otherwise false.

isValidWhenBoolean

boolean isValidWhenBoolean(String argumentName,
                           String argumentValue)
Validates if the String argumentValue contains the text true or false.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
Returns:
true if the condition is met, otherwise false.

isValidWhenInteger

boolean isValidWhenInteger(String argumentName,
                           String argumentValue)
Validates if the String argumentValue is an Integer value.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
Returns:
true if the condition is met, otherwise false.

isValidWhenLong

boolean isValidWhenLong(String argumentName,
                        String argumentValue)
Validates if the String argumentValue is a Long value.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
Returns:
true if the condition is met, otherwise false.

isValidWhenDirectory

boolean isValidWhenDirectory(String argumentName,
                             String argumentValue)
Validates if the String argumentValue is a directory.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
Returns:
true if the condition is met, otherwise false.

isValidWhenDirectory

boolean isValidWhenDirectory(String argumentName,
                             File argumentValue)

isValidWhenFile

boolean isValidWhenFile(String argumentName,
                        String argumentValue)
Validates if the String argumentValue is a file.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
Returns:
true if the condition is met, otherwise false.

isValidWhenFile

boolean isValidWhenFile(String argumentName,
                        File argumentValue)

isValidWhenUrl

boolean isValidWhenUrl(String argumentName,
                       String argumentValue)
Validates if the String argumentValue is an valid url.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
Returns:
true if the condition is met, otherwise false.

isValidWhenUri

boolean isValidWhenUri(String argumentName,
                       String argumentValue)
Validates if the String argumentValue is an valid uri.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
Returns:
true if the condition is met, otherwise false.

isValidWhenInSet

boolean isValidWhenInSet(String argumentName,
                         String argumentValue,
                         Set<String> argumentSet)
Validates if the String argumentValue is an element contained by the Set argumentSet.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
argumentSet - The Set to validate against.
Returns:
true if the condition is met, otherwise false.

isValidWhenNotInSet

boolean isValidWhenNotInSet(String argumentName,
                            String argumentValue,
                            Set<String> argumentSet)
Validates if the String argumentValue is not already contained by the Set argumentSet.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
argumentSet - The Set to validate against.
Returns:
true if the condition is met, otherwise false.

isValidWhenNotNullInCollection

boolean isValidWhenNotNullInCollection(String string,
                                       Collection<?> collection)

isValidCollectionWhenNoNulls

boolean isValidCollectionWhenNoNulls(String argumentName,
                                     Collection<?> argumentValue)
Validates if the Collection argumentValue is not null and that its containing elements are also not null. Meaning the Collection may be empty. And when not empty, each entry should contain a instance.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
Returns:
true if the condition is met, otherwise false.

isValidCollectionWhenMinElements

boolean isValidCollectionWhenMinElements(String argumentName,
                                         Collection<?> argumentValue,
                                         int minElements)
Validates if the Collection argumentValue is at least containing the minimal number of elements (minElements).

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
minElements - The minimal number of arguments, the collection should contain.
Returns:
true if the condition is met, otherwise false.

isValidWhenGreaterThen

boolean isValidWhenGreaterThen(String argumentName,
                               int argumentValue,
                               int value)
Validates if the Integer argumentValue is greate then Integer value.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
value - The value to validate against.
Returns:
true if the condition is met, otherwise false.

isValidStringMinLength

boolean isValidStringMinLength(String argumentName,
                               String argumentValue,
                               int minLength)
Validates if the String argumentValue has a minimal length of minLength.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
minLength - The length to validate against.
Returns:
true if the condition is met, otherwise false.

isValidStringMaxLength

boolean isValidStringMaxLength(String argumentName,
                               String argumentValue,
                               int maxLength)
Validates if the String argumentValue has a maximum length of maxLength.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
maxLength - The length to validate against.
Returns:
true if the condition is met, otherwise false.

isValidStringLength

boolean isValidStringLength(String argumentName,
                            String argumentValue,
                            int length)
Validates if the String argumentValue has an exact length of length.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
length - The length to validate against.
Returns:
true if the condition is met, otherwise false.

isValidStringMinAndMaxLength

boolean isValidStringMinAndMaxLength(String argumentName,
                                     String argumentValue,
                                     int minLength,
                                     int maxLength)
Validates if the String argumentValue has a minimal length of minLength and a maximum length of maxLength.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
minLength - The minimal length to validate against.
maxLength - The maximum length to validate against.
Returns:
true if the condition is met, otherwise false.

isValidMatchingDateFormat

boolean isValidMatchingDateFormat(String argumentName,
                                  String argumentValue,
                                  DateFormat dateFormat)
Validates if the String argumentValue matches the dateFormat.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
dateFormat - The date format which is used for matching.
Returns:
true if the condition is met, otherwise false.

isValidMatchingDateFormat

boolean isValidMatchingDateFormat(String argumentName,
                                  String argumentValue,
                                  String dateFormatName)
Validates if the String argumentValue matches the date format registered under the dateFormatName.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
patternName - The name of the date format, which is used for matching.
Returns:
true if the condition is met, otherwise false.
See Also:
isValidMatchingDateFormat(String, String, DateFormat)

isValidMatchingPattern

boolean isValidMatchingPattern(String argumentName,
                               String argumentValue,
                               String patternName)
Validates if the String argumentValue matches the pattern regisstered under the patternName.

Parameters:
argumentName - The name of the argument, which is validated.
argumentValue - The value of the argument, which is validated.
patternName - The name of the pattern, which is used for matching.
Returns:
true if the condition is met, otherwise false.

addError

void addError(String error)
Add an error message to the list of error messages. The list of error messages is used to create the IllegalArgumentException message.

Parameters:
error - The error message to add.
See Also:
addError(String, String)

addError

void addError(String argumentName,
              String message)
Add an error message, for the given argumentName, to the list of error messages.

Parameters:
argumentName - - the argument (or property-key) in which the problem is found.
message - - the message that describes the problem.

addError

void addError(String argumentName,
              String key,
              String message)
Add an error message, for when the argument is a Map instance, to the list of error messages, for the given key.

Parameters:
argumentName - - the argument Map (or property-key).
key - - the key under which the problem is found.
message - - the message that describes the problem.

getPatternNames

Set<String> getPatternNames()
Returns the Set of pattern names.

Returns:
The names of all the patterns.

getPattern

Map<String,String> getPattern()
Returns the Map of pattern names and their regular expression.

Returns:
All pattern names and their regular expression (as String).

getPattern

org.apache.oro.text.regex.Pattern getPattern(String patternName)
Returns the Pattern found under the patternName, or throws an IllegalArgumentException if the patternName is not available.

Parameters:
patternName - The name of the pattern.
Returns:
The found Pattern.

getRegularExpression

String getRegularExpression(String patternName)
Returns the regular expression found under the patternName, or throws an IllegalArgumentException if the patternName is not available.

Parameters:
patternName - The name of the pattern.
Returns:
The regular expression.

isValidNotNullForKey

boolean isValidNotNullForKey(String string,
                             Map<String,String> dataModelIdMap,
                             String keyDataVendor)


Copyright © 2013 Verhagen Software. All Rights Reserved.