Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
IParameterConstraint |
|
| 1.0;1 |
1 | /** | |
2 | * | |
3 | */ | |
4 | package pt.digitalis.dif.dem.objects.parameters.constraints; | |
5 | ||
6 | import pt.digitalis.dif.dem.interfaces.IStageInstance; | |
7 | ||
8 | /** | |
9 | * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a> | |
10 | * @created Nov 16, 2007 | |
11 | */ | |
12 | public interface IParameterConstraint { | |
13 | ||
14 | /** | |
15 | * Configures the constraint. Optional. The maximum value for max, or maskString for mask. | |
16 | * | |
17 | * @param configurationString | |
18 | */ | |
19 | public void configureConstraint(String configurationString); | |
20 | ||
21 | /** | |
22 | * Builds a JavaScript boolean expression to check this constraint. Will assume there is a "value" variable with the | |
23 | * current parameter value in context to get the parameter value from. | |
24 | * | |
25 | * @return the JS code to validate | |
26 | */ | |
27 | public String getJavaScriptValidationCondition(); | |
28 | ||
29 | /** | |
30 | * Get the Validation result, Validates the parameter value passed in it's native type | |
31 | * | |
32 | * @param value | |
33 | * the value to validate | |
34 | * @param stageInstance | |
35 | * the current stage in execution | |
36 | * @return T if the validation succeded | |
37 | */ | |
38 | public ParameterConstraintResult getValidationResult(Object value, IStageInstance stageInstance); | |
39 | ||
40 | /** | |
41 | * Checks if the parameter attribute is of a supported class for this constraint to be used | |
42 | * | |
43 | * @param clazz | |
44 | * the class of the attribute on witch the constraint has been applied | |
45 | * @return T is it is a supported class | |
46 | */ | |
47 | public boolean isSupportedClass(Class<?> clazz); | |
48 | ||
49 | /** | |
50 | * Validates the parameter value passed in it's native type | |
51 | * | |
52 | * @param value | |
53 | * the value to validate | |
54 | * @param stageInstance | |
55 | * the current stage in execution | |
56 | * @return T if the validation succeeded | |
57 | */ | |
58 | public boolean validateConstraint(Object value, IStageInstance stageInstance); | |
59 | ||
60 | /** | |
61 | * Validates the parameter value passed as a String | |
62 | * | |
63 | * @param value | |
64 | * the value to validate | |
65 | * @param stageInstance | |
66 | * the current stage in execution | |
67 | * @return T if the validation succeded | |
68 | */ | |
69 | public boolean validateConstraint(String value, IStageInstance stageInstance); | |
70 | ||
71 | /** | |
72 | * Get a description on why the validation fails | |
73 | * | |
74 | * @return the validation error message in the default language | |
75 | */ | |
76 | public String validationErrorMessage(); | |
77 | ||
78 | /** | |
79 | * Get a description on why the validation fails | |
80 | * | |
81 | * @param parseValues | |
82 | * if T will replace the current parameter value in the message. Otherwise return the untouched message | |
83 | * for custom parsing | |
84 | * @return the validation error message in the default language | |
85 | */ | |
86 | public String validationErrorMessage(boolean parseValues); | |
87 | ||
88 | /** | |
89 | * Get a description on why the validation fails | |
90 | * | |
91 | * @param parseValues | |
92 | * if T will replace the current parameter value in the message. Otherwise return the untouched message | |
93 | * for custom parsing | |
94 | * @param language | |
95 | * the language on witch to create the error message | |
96 | * @return the validation error message | |
97 | */ | |
98 | public String validationErrorMessage(boolean parseValues, String language); | |
99 | ||
100 | /** | |
101 | * Get a description on why the validation fails | |
102 | * | |
103 | * @param language | |
104 | * the language on witch to create the error message | |
105 | * @return the validation error message | |
106 | */ | |
107 | public String validationErrorMessage(String language); | |
108 | ||
109 | } |