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;
17:
18: import java.util.HashMap;
19: import java.util.Locale;
20: import java.util.Map;
21:
22: /**
23: * This ValidationFactory is used to test the ValidationFactory base class.
24: *
25: * @author Shellman, Dan
26: */
27: public class MockValidationFactory extends ValidationFactory {
28: private Map validationServices = new HashMap();
29: private boolean configLoadedFlag = false;
30: private boolean defaultLocaleFlag = false;
31:
32: /**
33: * Default constructor.
34: */
35: public MockValidationFactory() {
36: } //end MockValidationFactory()
37:
38: public void register() {
39: ValidationFactory.registerFactory(this .getClass(),
40: getFactoryId());
41: } //end register()
42:
43: public String getFactoryId() {
44: return "MockValidationFactory";
45: } //end getFactoryId()
46:
47: public void addValidationService(String serviceName,
48: ValidationService service) {
49: validationServices.put(serviceName, service);
50: } //end addValidationService()
51:
52: public ValidationService getValidationService(String serviceName) {
53: return (ValidationService) validationServices.get(serviceName);
54: } //end getValidationService()
55:
56: public Object getService(String serviceKey) {
57: return serviceMap.get(serviceKey);
58: } //end getService()
59:
60: public boolean isConfigLoaded() {
61: return configLoadedFlag;
62: } //end isConfigLoaded()
63:
64: public boolean isDefaultLocaleSet() {
65: return defaultLocaleFlag;
66: } //end isDefaultLocaleSet()
67:
68: public void setDefaultLocale(Locale locale) {
69: super .setDefaultLocale(locale);
70: defaultLocaleFlag = true;
71: } //end setDefaultLocale()
72:
73: protected void loadConfig() {
74: configLoadedFlag = true;
75: } //end loadConfig()
76: } //end MockValidationFactory
|