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.control;
16:
17: /**
18: * This class represents a further concretezation of {@link org.araneaframework.uilib.form.control.StringArrayRequestControl},
19: * that is it represents controls, that have a single <code>String</code> request parameter.
20: *
21: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
22: *
23: */
24: public abstract class StringRequestControl extends
25: StringArrayRequestControl {
26:
27: //*********************************************************************
28: // FIELDS
29: //*********************************************************************
30:
31: //*********************************************************************
32: //* INTERNAL METHODS
33: //*********************************************************************
34:
35: /**
36: * This is just a proxy to {@link #fromRequest(String)}.
37: */
38: protected Object fromRequestParameters(String[] parameterValues) {
39: return fromRequest(parameterValues[0]);
40: }
41:
42: /**
43: * This is just a proxy to {@link #preprocessRequestParameter(String)}.
44: */
45: protected String[] preprocessRequestParameters(
46: String[] parameterValues) {
47: String result = parameterValues == null ? preprocessRequestParameter(null)
48: : preprocessRequestParameter(parameterValues[0]);
49: return result == null ? null : new String[] { result };
50: }
51:
52: /**
53: * This is just a proxy to {@link #toResponse(Object)}.
54: */
55: protected String[] toResponseParameters(Object controlValue) {
56: String result = toResponse(controlValue);
57: return result == null ? null : new String[] { result };
58: }
59:
60: //*********************************************************************
61: //* ABSTRACT METHODS
62: //*********************************************************************
63:
64: /**
65: * @see StringArrayRequestControl#preprocessRequestParameters(String[])
66: */
67: protected abstract String preprocessRequestParameter(
68: String parameterValue);
69:
70: /**
71: * @see StringArrayRequestControl#fromRequestParameters(String[])
72: */
73: protected abstract Object fromRequest(String parameterValue);
74:
75: /**
76: * @see StringArrayRequestControl#toResponseParameters(Object)
77: */
78: protected abstract String toResponse(Object controlValue);
79: }
|