01: /*
02: * Copyright 2006-2007 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.Locale;
19:
20: /**
21: * This wrapper around a ValidationService is itself a ValidationService
22: * implementation. However, it can be used as a wrapper that takes a
23: * validation factory and the validation set name, bypassing the need
24: * to call the factory's getValidationService() method.
25: *
26: * @author Shellman, Dan
27: */
28: public class ValidationServiceWrapper implements ValidationService {
29: ValidationService service;
30:
31: /**
32: * Construct the wrapper with an existing factory and the
33: * ValidationSet name (the name of the service).
34: *
35: * @param factory The factory containing the validation service
36: * @param validationSetName The fully qualified name of the validation set
37: */
38: public ValidationServiceWrapper(ValidationFactory factory,
39: String validationSetName) {
40: service = factory.getValidationService(validationSetName);
41: } //end ValidationServiceWrapper()
42:
43: /**
44: * Construct the wrapper with a factory config and the ValidationSet
45: * name (the name of the service). The factory config should be
46: * completely configured prior to constructing this wrapper.
47: *
48: * @param config The config of the validation factory
49: * @param validationSetName The fully qualified name of the validation set
50: */
51: public ValidationServiceWrapper(ValidationFactoryConfig config,
52: String validationSetName) {
53: ValidationFactory factory;
54:
55: factory = config.getFactory();
56: service = factory.getValidationService(validationSetName);
57: } //end ValidationServiceWrapper()
58:
59: public void validate(Object obj) throws ValidationException {
60: service.validate(obj);
61: } //end validate()
62:
63: public void validate(Object obj, Locale locale)
64: throws ValidationException {
65: service.validate(obj, locale);
66: } //end validate()
67:
68: public void validateObject(Object obj) {
69: service.validateObject(obj);
70: } //end validateObject()
71:
72: public void validateObject(Object obj, Locale locale) {
73: service.validateObject(obj, locale);
74: } //end validateObject()
75:
76: public String getServiceName() {
77: return service.getServiceName();
78: } //end getServiceName()
79:
80: /**
81: * Retrieves an iterator of String values representing the documentation
82: * configured for this validation service (the underlying validation set).
83: *
84: * @return Returns an iterator of Strings representing documentation.
85: */
86: public DocumentationIterator getDocumentation() {
87: return service.getDocumentation();
88: } //end getDocumentation()
89: } //end ValidationServiceWrapper
|