01: /*
02: * Copyright 2006 Dan Shellman
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: */
16: package org.iscreen.impl;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20: import java.util.Locale;
21: import org.iscreen.impl.BaseValidationService;
22: import org.iscreen.impl.DefaultValidatorContext;
23: import org.iscreen.impl.ContextBean;
24: import org.iscreen.impl.ValidatorWrapper;
25:
26: /**
27: * This is a mock validation service that extends the base validation service.
28: * It's used to test the base validation service.
29: *
30: * @author Shellman, Dan
31: */
32: public class MockValidationService extends BaseValidationService {
33: private List validators = new ArrayList();
34: private int index = 0;
35:
36: /**
37: * Default constructor.
38: */
39: public MockValidationService(String id, Locale locale) {
40: super (id, locale);
41: } //end MockValidationService()
42:
43: public void addValidator(ValidatorWrapper wrapper) {
44: validators.add(wrapper);
45: } //end addValidator()
46:
47: // ***
48: // Protected methods
49: // ***
50:
51: protected ValidatorWrapper getNextValidator() {
52: if (index >= validators.size()) {
53: return null;
54: } else {
55: return (ValidatorWrapper) validators.get(index++);
56: }
57: } //end getNextValidator()
58:
59: protected void resetValidatorIteration() {
60: index = 0;
61: } //end resetValidatorIteration()
62:
63: protected DefaultValidatorContext constructContext(
64: ContextBean root, Locale locale) {
65: return super .constructContext(root, locale);
66: } //end constructContext()
67:
68: protected ContextBean constructContextBean(Object objToValidate) {
69: return super .constructContextBean(objToValidate);
70: } //end constructContextBean()
71: } //end MockValidationService
|