| java.lang.Object net.sf.oval.Validator net.sf.oval.guard.Guard
Guard | public class Guard extends Validator (Code) | | Extended version of the validator to realize programming by contract.
author: Sebastian Thomschke |
Method Summary | |
public void | addChecks(Constructor constructor, int parameterIndex, Check... checks) | public void | addChecks(Method method, Check... checks) | public void | addChecks(Method method, int parameterIndex, Check... checks) | public void | addChecks(Method method, PostCheck... checks) | public void | addChecks(Method method, PreCheck... checks) | public boolean | addListener(ConstraintsViolatedListener listener) | public boolean | addListener(ConstraintsViolatedListener listener, Class guardedClass) | public boolean | addListener(ConstraintsViolatedListener listener, Object guardedObject) | protected Map<PostCheck, Object> | calculateMethodPostOldValues(Object validatedObject, Method method, Object[] args) | public Check[] | getChecks(Method method, int parameterIndex) | public PostCheck[] | getChecksPost(Method method) | public PreCheck[] | getChecksPre(Method method) Returns the registered pre condition checks for the given method. | public ParameterNameResolver | getParameterNameResolver() | protected void | guardConstructorPost(Object guardedObject, Constructor constructor, Object[] args) This method is provided for use by guard aspects. | protected void | guardConstructorPre(Object guardedObject, Constructor constructor, Object[] args) This method is provided for use by guard aspects. | protected Object | guardMethod(Object guardedObject, Method method, Object[] args, Invocable invocable) This method is provided for use by guard aspects. | public boolean | hasListener(ConstraintsViolatedListener listener) | public boolean | hasListener(ConstraintsViolatedListener listener, Class guardedClass) | public boolean | hasListener(ConstraintsViolatedListener listener, Object guardedObject) | public boolean | isActivated() | public boolean | isInProbeMode(Object guardedObject) Determines if the probe mode is enabled for the given object in the current thread.
In probe mode calls to methods of an object are not actually executed. | public boolean | isInvariantsEnabled() Determins if invariants are checked prior and after every
call to a non-private method or constructor. | public boolean | isInvariantsEnabled(Class guardedClass) Determins if invariants are checked prior and after every
call to a non-private method or constructor. | public boolean | isPostConditionsEnabled() | public boolean | isPreConditionsEnabled() | protected void | notifyListeners(Object guardedObject, ConstraintsViolatedException ex) | public void | removeChecks(Constructor constructor, int parameterIndex, Check... checks) | public void | removeChecks(Method method, int parameterIndex, Check... checks) | public void | removeChecks(Method method, PostCheck... checks) | public void | removeChecks(Method method, PreCheck... checks) | public boolean | removeListener(ConstraintsViolatedListener listener) | public boolean | removeListener(ConstraintsViolatedListener listener, Class guardedClass) | public boolean | removeListener(ConstraintsViolatedListener listener, Object guardedObject) | public void | setActivated(boolean isActivated) If set to false OVal's programming by contract features are disabled
and constraints are not checked automatically during runtime. | public void | setInProbeMode(Object guardedObject, boolean isInProbeMode) Enable or disable the probe mode for the given object in the current thread.
In probe mode calls to methods of an object are not actually executed. | public void | setInvariantsEnabled(boolean isEnabled) Specifies if invariants are checked prior and after
calls to non-private methods and constructors. | public void | setInvariantsEnabled(Class> guardedClass, boolean isEnabled) Specifies if invariants are checked prior and after
calls to non-private methods and constructors. | public void | setParameterNameResolver(ParameterNameResolver parameterNameResolver) | public void | setPostConditionsEnabled(boolean isEnabled) | public void | setPreConditionsEnabled(boolean isEnabled) | protected List<ConstraintViolation> | validateConstructorParameters(Object validatedObject, Constructor constructor, Object[] argsToValidate) | protected void | validateInvariants(Object guardedObject, List<ConstraintViolation> violations) | protected void | validateMethodParameters(Object validatedObject, Method method, Object[] args, List<ConstraintViolation> violations) | protected void | validateMethodPost(Object validatedObject, Method method, Object[] args, Object returnValue, Map<PostCheck, Object> oldValues, List<ConstraintViolation> violations) | protected void | validateMethodPre(Object validatedObject, Method method, Object[] args, List<ConstraintViolation> violations) | protected void | validateMethodReturnValue(Object validatedObject, Method method, Object returnValue, List<ConstraintViolation> violations) |
Guard | public Guard()(Code) | | Constructs a new guard object and uses a new isntance of
AnnotationsConfigurer
|
addListener | public boolean addListener(ConstraintsViolatedListener listener, Class guardedClass) throws IllegalArgumentException(Code) | | Registers the given listener for all thrown ConstraintViolationExceptions on objects of the given class
Parameters: listener - the listener to register Parameters: guardedClass - guarded class or interface true if the listener was not yet registered throws: IllegalArgumentException - if listener == null or guardedClass == null |
addListener | public boolean addListener(ConstraintsViolatedListener listener, Object guardedObject)(Code) | | Registers the given listener for all thrown ConstraintViolationExceptions on objects of the given object
Parameters: listener - the listener to register Parameters: guardedObject - true if the listener was not yet registered throws: IllegalArgumentException - if listener == null or guardedObject == null |
isActivated | public boolean isActivated()(Code) | | the isEnabled |
isInProbeMode | public boolean isInProbeMode(Object guardedObject)(Code) | | Determines if the probe mode is enabled for the given object in the current thread.
In probe mode calls to methods of an object are not actually executed. OVal only
validates method pre-conditions and notifies ConstraintViolationListeners but
does not throw ConstraintViolationExceptions. Methods with return values will return null.
Parameters: guardedObject - true if exceptions are suppressed |
isInvariantsEnabled | public boolean isInvariantsEnabled()(Code) | | Determins if invariants are checked prior and after every
call to a non-private method or constructor.
the isInvariantChecksActivated |
isInvariantsEnabled | public boolean isInvariantsEnabled(Class guardedClass)(Code) | | Determins if invariants are checked prior and after every
call to a non-private method or constructor.
Parameters: guardedClass - the guarded class the isInvariantChecksActivated |
isPostConditionsEnabled | public boolean isPostConditionsEnabled()(Code) | | the isPostChecksActivated |
isPreConditionsEnabled | public boolean isPreConditionsEnabled()(Code) | | the isPreChecksActivated |
setActivated | public void setActivated(boolean isActivated)(Code) | | If set to false OVal's programming by contract features are disabled
and constraints are not checked automatically during runtime.
Parameters: isActivated - the isActivated to set |
setInProbeMode | public void setInProbeMode(Object guardedObject, boolean isInProbeMode) throws IllegalArgumentException(Code) | | Enable or disable the probe mode for the given object in the current thread.
In probe mode calls to methods of an object are not actually executed. OVal only
validates method pre-conditions and notifies ConstraintViolationListeners but
does not throw ConstraintViolationExceptions. Methods with return values will return null.
Parameters: guardedObject - Parameters: isInProbeMode - throws: IllegalArgumentException - if guardedObject == null |
setInvariantsEnabled | public void setInvariantsEnabled(boolean isEnabled)(Code) | | Specifies if invariants are checked prior and after
calls to non-private methods and constructors.
Parameters: isEnabled - the isInvariantsEnabled to set |
setInvariantsEnabled | public void setInvariantsEnabled(Class> guardedClass, boolean isEnabled)(Code) | | Specifies if invariants are checked prior and after
calls to non-private methods and constructors.
Parameters: guardedClass - the guarded class to turn on/off the invariant checking Parameters: isEnabled - the isEnabled to set |
setPostConditionsEnabled | public void setPostConditionsEnabled(boolean isEnabled)(Code) | | Parameters: isEnabled - the isEnabled to set |
setPreConditionsEnabled | public void setPreConditionsEnabled(boolean isEnabled)(Code) | | Parameters: isEnabled - the isEnabled to set |
Methods inherited from net.sf.oval.Validator | public void addChecks(Class clazz, Check... checks) throws IllegalArgumentException(Code)(Java Doc) protected void addChecks(ClassChecks cc, ClassConfiguration classConfig) throws OValException(Code)(Java Doc) public void addChecks(Field field, Check... checks) throws IllegalArgumentException(Code)(Java Doc) public void addChecks(Method invariantMethod, Check... checks) throws IllegalArgumentException, InvalidConfigurationException(Code)(Java Doc) public void addConstraintSet(ConstraintSet constraintSet, boolean overwrite) throws ConstraintSetAlreadyDefinedException, IllegalArgumentException(Code)(Java Doc) public void addExpressionLanguage(String languageId, ExpressionLanguage expressionLanguage) throws IllegalArgumentException(Code)(Java Doc) public void assertValid(Object validatedObject) throws IllegalArgumentException, ValidationFailedException, ConstraintsViolatedException(Code)(Java Doc) public void assertValidFieldValue(Object validatedObject, Field validatedField, Object fieldValueToValidate) throws IllegalArgumentException, ValidationFailedException, ConstraintsViolatedException(Code)(Java Doc) protected void checkConstraint(List<ConstraintViolation> violations, Check check, Object validatedObject, Object valueToValidate, OValContext context) throws OValException(Code)(Java Doc) protected void checkConstraintAssertConstraintSet(List<ConstraintViolation> violations, AssertConstraintSetCheck check, Object validatedObject, Object valueToValidate, OValContext context) throws OValException(Code)(Java Doc) protected void checkConstraintAssertFieldConstraints(List<ConstraintViolation> violations, AssertFieldConstraintsCheck check, Object validatedObject, Object valueToValidate, OValContext context) throws OValException(Code)(Java Doc) protected void checkConstraintAssertValid(List<ConstraintViolation> violations, AssertValidCheck check, Object validatedObject, Object valueToValidate, OValContext context) throws OValException(Code)(Java Doc) public synchronized void disableAllProfiles()(Code)(Java Doc) public void disableProfile(String profile)(Code)(Java Doc) public synchronized void enableAllProfiles()(Code)(Java Doc) public void enableProfile(String profile)(Code)(Java Doc) public Check[] getChecks(Class clazz) throws IllegalArgumentException(Code)(Java Doc) public Check[] getChecks(Field field) throws IllegalArgumentException(Code)(Java Doc) public Check[] getChecks(Method method) throws IllegalArgumentException(Code)(Java Doc) protected ClassChecks getClassChecks(Class clazz) throws IllegalArgumentException, OValException(Code)(Java Doc) public static CollectionFactory getCollectionFactory()(Code)(Java Doc) public List<Configurer> getConfigurers()(Code)(Java Doc) public ConstraintSet getConstraintSet(String constraintSetId) throws OValException(Code)(Java Doc) public ExceptionTranslator getExceptionTranslator()(Code)(Java Doc) public ExpressionLanguage getExpressionLanguage(String languageId) throws IllegalArgumentException, ExpressionLanguageNotAvailableException(Code)(Java Doc) public static LoggerFactory getLoggerFactory()(Code)(Java Doc) public static MessageResolver getMessageResolver()(Code)(Java Doc) protected boolean isAnyProfileEnabled(String[] profileIds)(Code)(Java Doc) protected boolean isCurrentlyValidated(Object object)(Code)(Java Doc) public boolean isProfileEnabled(String profileId)(Code)(Java Doc) public void reconfigureChecks()(Code)(Java Doc) public void removeChecks(Class clazz, Check... checks) throws IllegalArgumentException(Code)(Java Doc) public void removeChecks(Field field, Check... checks) throws IllegalArgumentException(Code)(Java Doc) public void removeChecks(Method getter, Check... checks) throws IllegalArgumentException(Code)(Java Doc) public ConstraintSet removeConstraintSet(String id) throws IllegalArgumentException(Code)(Java Doc) protected String renderMessage(OValContext context, Object value, String messageKey, Map<String, String> messageValues)(Code)(Java Doc) public static void setCollectionFactory(CollectionFactory factory) throws IllegalArgumentException(Code)(Java Doc) public void setExceptionTranslator(ExceptionTranslator exceptionTranslator)(Code)(Java Doc) public static void setLoggerFactory(LoggerFactory loggerFactory)(Code)(Java Doc) public static void setMessageResolver(MessageResolver messageResolver) throws IllegalArgumentException(Code)(Java Doc) protected RuntimeException translateException(OValException ex)(Code)(Java Doc) public List<ConstraintViolation> validate(Object validatedObject) throws IllegalArgumentException, ValidationFailedException(Code)(Java Doc) public List<ConstraintViolation> validateFieldValue(Object validatedObject, Field validatedField, Object fieldValueToValidate) throws IllegalArgumentException, ValidationFailedException(Code)(Java Doc) protected void validateInvariants(Object validatedObject, List<ConstraintViolation> violations) throws IllegalArgumentException, ValidationFailedException(Code)(Java Doc)
|
|
|