org.objectweb.jac.aspects.integrity
Class GenericConditions

java.lang.Object
  extended byorg.objectweb.jac.aspects.integrity.GenericConditions

public class GenericConditions
extends Object

Some basic methods for constraints on fields values.

Constraint methods must return a Boolean that is Boolean.TRUE if the test has been validated (passed), Boolean.FALSE else. Their parameters are :

See Also:
IntegrityAC.addPreCondition(FieldItem,MethodItem,Object[],String), IntegrityAC.addPostCondition(FieldItem,MethodItem,Object[],String), IntegrityAC.doCheck()

Constructor Summary
GenericConditions()
           
 
Method Summary
static boolean authorizedValues(Object substance, FieldItem field, Object value, Object[] values)
          Check if field's value is equal to one of the authorized values.
static boolean forbiddenValues(Object substance, FieldItem field, Object value, Object[] values)
          Check if field's value is not equal to the forbidden values.
static boolean isBeginingWithLetter(Object substance, FieldItem field, Object value, Object[] values)
          Tells if the value is a letter begining string.
static boolean isBeginingWithUpperCaseChar(Object substance, FieldItem field, Object value, Object[] values)
          Tells if the value is an upper-case char begining string.
static boolean isGreaterThan(Object substance, FieldItem field, Object value, Object[] values)
          Tells if the value is greater than a given number.
static boolean isJavaIdentifier(Object substance, FieldItem field, Object value, Object[] values)
          Tells if the value is a valid java identifier.
static boolean isLowerThan(Object substance, FieldItem field, Object value, Object[] values)
          Tells if the value is lower than a given number.
static boolean isNotNull(Object substance, FieldItem field, Object value, Object[] values)
           
static boolean isNull(Object substance, FieldItem field, Object value, Object[] values)
           
static boolean isUniqueValue(Object substance, FieldItem field, Object value, Object[] values)
          Check if this field already has the same value in another object of the same type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericConditions

public GenericConditions()
Method Detail

forbiddenValues

public static boolean forbiddenValues(Object substance,
                                      FieldItem field,
                                      Object value,
                                      Object[] values)
Check if field's value is not equal to the forbidden values. If it is, the method returns false.

Parameters:
substance - the object that owns the field
field - the tested field
value - the value that is about to be set
values - the forbidden values

authorizedValues

public static boolean authorizedValues(Object substance,
                                       FieldItem field,
                                       Object value,
                                       Object[] values)
Check if field's value is equal to one of the authorized values. If it is not, the method returns false.

Parameters:
substance - the object that owns the field
field - the tested field
value - the value that is about to be set
values - the authorized values

isUniqueValue

public static boolean isUniqueValue(Object substance,
                                    FieldItem field,
                                    Object value,
                                    Object[] values)
Check if this field already has the same value in another object of the same type.

Parameters:
substance - the object that owns the field
field - the tested field
value - the value that is about to be set
values - unused

isBeginingWithUpperCaseChar

public static boolean isBeginingWithUpperCaseChar(Object substance,
                                                  FieldItem field,
                                                  Object value,
                                                  Object[] values)
Tells if the value is an upper-case char begining string.

Parameters:
substance - the object that owns the field
field - the tested field
value - the value that is about to be set
values - unused

isNotNull

public static boolean isNotNull(Object substance,
                                FieldItem field,
                                Object value,
                                Object[] values)

isNull

public static boolean isNull(Object substance,
                             FieldItem field,
                             Object value,
                             Object[] values)

isBeginingWithLetter

public static boolean isBeginingWithLetter(Object substance,
                                           FieldItem field,
                                           Object value,
                                           Object[] values)
Tells if the value is a letter begining string.

Parameters:
substance - the object that owns the field
field - the tested field
value - the value that is about to be set
values - unused

isJavaIdentifier

public static boolean isJavaIdentifier(Object substance,
                                       FieldItem field,
                                       Object value,
                                       Object[] values)
Tells if the value is a valid java identifier.

Parameters:
substance - the object that owns the field
field - the tested field
value - the value that is about to be set
values - unused

isGreaterThan

public static boolean isGreaterThan(Object substance,
                                    FieldItem field,
                                    Object value,
                                    Object[] values)
                             throws Exception
Tells if the value is greater than a given number.

Parameters:
substance - the object that owns the field
field - the tested field
value - the value that is about to be set
values - unused
Throws:
Exception

isLowerThan

public static boolean isLowerThan(Object substance,
                                  FieldItem field,
                                  Object value,
                                  Object[] values)
                           throws Exception
Tells if the value is lower than a given number.

Parameters:
substance - the object that owns the field
field - the tested field
value - the value that is about to be set
values - unused
Throws:
Exception