01: /*
02: * Copyright 2004-2006 Fouad HAMDI with the idea
03: * of SameLAN, S.L. Soluciones Tecnológicas.
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.csvbeans.validators;
18:
19: import org.csvbeans.Property;
20: import org.csvbeans.context.ContextManager;
21: import org.csvbeans.exceptions.ValidationException;
22:
23: /**
24: * Has the responsability to validate values.
25: *
26: * @author Fouad Hamdi
27: * @since 0.7
28: */
29: public interface Validator {
30: /**
31: * Validate the specified value.
32: * @param value the value to validate.
33: * @throws ValidationException is thrown if the value is invalid.
34: */
35: void validate(String value) throws ValidationException;
36:
37: /**
38: * Is called at the initialization of the validator.
39: * @param manager the context manager
40: */
41: void init(ContextManager manager);
42:
43: /**
44: * Add a property to the validator.
45: * @param property
46: */
47: void addProperty(Property property);
48:
49: /**
50: * Is called at the end of the record context. Implement it when
51: * you need to release some resources before the record context is
52: * closed.
53: */
54: void onEndingRecordContext();
55:
56: /**
57: * Is called at the end of the session context. Implement it when
58: * you need to release some resources before the session context is
59: * closed.
60: */
61: void onEndingSessionContext();
62: }
|