01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.guard;
13:
14: import java.lang.annotation.Documented;
15: import java.lang.annotation.ElementType;
16: import java.lang.annotation.Retention;
17: import java.lang.annotation.RetentionPolicy;
18: import java.lang.annotation.Target;
19:
20: /**
21: * Before the annotated method is executed the expression is evaluated.<br>
22: * This evaluation happens <u>after</u> the single parameter constraints were validated
23: * and only if no parameter constraint violations were detected.
24: * <br>
25: * If constraint violations occur, the annotated method will not be executed
26: * instead it will throw a ConstraintsViolatedException exception.
27: *
28: * @author Sebastian Thomschke
29: */
30: @Documented
31: @Retention(RetentionPolicy.RUNTIME)
32: @Target({ElementType.METHOD})
33: public @interface Pre {
34:
35: /**
36: * error code passed to the ConstraintViolation object
37: */
38: String errorCode() default "net.sf.oval.guard.Pre";
39:
40: /**
41: * formula in the given expression language describing the constraint. the formula must return true if the constraint is satisfied.
42: * <br>
43: * available variables are:<br>
44: * <b>_this</b> -> the validated bean<br>
45: * <b>_args[]</b> -> the current parameter values<br>
46: * additionally variables matching the parameter names are available<br>
47: */
48: String expr();
49:
50: /**
51: * the expression language that is used
52: */
53: String lang();
54:
55: /**
56: * message to be used for the ContraintsViolatedException
57: *
58: * @see net.sf.oval.exception.ConstraintsViolatedException
59: */
60: String message() default "net.sf.oval.guard.Pre.violated";
61:
62: /**
63: * The associated validation profiles.
64: */
65: String[] profiles() default {};
66:
67: /**
68: * severity passed to the ConstraintViolation object
69: */
70: int severity() default 0;
71: }
|