01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.uilib.form;
16:
17: import java.io.Serializable;
18: import java.util.Set;
19: import org.araneaframework.Environment;
20:
21: /**
22: * A constraint operates on some form {@link org.araneaframework.Component} providing means
23: * for defining the conditions under which {@link org.araneaframework.Component} is considered
24: * valid. During validation, {@link Constraint} may produce appropriate error messages.
25: *
26: * @see org.araneaframework.uilib.form.constraint.BaseConstraint
27: */
28: public interface Constraint extends Serializable {
29: /**
30: * This method validates this {@link Constraint} conditions.
31: */
32: public boolean validate() throws Exception;
33:
34: /**
35: * Returns the validation errors produced while validating this {@link Constraint}.
36: * @return validation errors.
37: */
38: public Set getErrors();
39:
40: /**
41: * Clears the the errors produced while validating this {@link Constraint}.
42: */
43: public void clearErrors();
44:
45: /**
46: * Sets the custom error message, that will be used in place of default ones when
47: * this {@link Constraint} does not hold.
48: *
49: * @param customErrorMessage custom error message
50: */
51: public void setCustomErrorMessage(String customErrorMessage);
52:
53: /**
54: * Sets the {@link org.araneaframework.Environment} of this {@link Constraint}.
55: * Environment should come from whatever {@link org.araneaframework.Component} that this
56: * {@link Constraint} is operating on.
57: *
58: * {@link Constraint} {@link org.araneaframework.Environment} may be set to non-null
59: * value only once, further calls are ignored. Application programmer typically never
60: * calls this method as {@link org.araneaframework.Environment} is propagated seamlessly.
61: *
62: * @param environment
63: */
64: public void setEnvironment(Environment environment);
65: }
|