~ubuntu-branches/ubuntu/trusty/libstruts1.2-java/trusty-proposed

« back to all changes in this revision

Viewing changes to src/share/org/apache/struts/config/ControllerConfig.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2004-11-19 15:35:25 UTC
  • Revision ID: james.westby@ubuntu.com-20041119153525-mdu08a76z4zo67xt
Tags: upstream-1.2.4
ImportĀ upstreamĀ versionĀ 1.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ControllerConfig.java,v 1.19 2004/03/14 06:23:47 sraeburn Exp $
 
3
 * $Revision: 1.19 $
 
4
 * $Date: 2004/03/14 06:23:47 $
 
5
 *
 
6
 * Copyright 1999-2004 The Apache Software Foundation.
 
7
 * 
 
8
 * Licensed under the Apache License, Version 2.0 (the "License");
 
9
 * you may not use this file except in compliance with the License.
 
10
 * You may obtain a copy of the License at
 
11
 * 
 
12
 *      http://www.apache.org/licenses/LICENSE-2.0
 
13
 * 
 
14
 * Unless required by applicable law or agreed to in writing, software
 
15
 * distributed under the License is distributed on an "AS IS" BASIS,
 
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
17
 * See the License for the specific language governing permissions and
 
18
 * limitations under the License.
 
19
 */
 
20
 
 
21
 
 
22
package org.apache.struts.config;
 
23
 
 
24
 
 
25
import java.io.Serializable;
 
26
 
 
27
 
 
28
/**
 
29
 * <p>A JavaBean representing the configuration information of a
 
30
 * <code>&lt;controller&gt;</code> element in a Struts
 
31
 * configuration file.</p>
 
32
 *
 
33
 * @version $Revision: 1.19 $ $Date: 2004/03/14 06:23:47 $
 
34
 * @since Struts 1.1
 
35
 */
 
36
 
 
37
public class ControllerConfig implements Serializable {
 
38
 
 
39
 
 
40
    // ----------------------------------------------------- Instance Variables
 
41
 
 
42
 
 
43
    /**
 
44
     * Has this component been completely configured?
 
45
     */
 
46
    protected boolean configured = false;
 
47
 
 
48
 
 
49
    // ------------------------------------------------------------- Properties
 
50
 
 
51
 
 
52
    /**
 
53
     * The input buffer size for file uploads.
 
54
     */
 
55
    protected int bufferSize = 4096;
 
56
 
 
57
    public int getBufferSize() {
 
58
        return (this.bufferSize);
 
59
    }
 
60
 
 
61
    public void setBufferSize(int bufferSize) {
 
62
        if (configured) {
 
63
            throw new IllegalStateException("Configuration is frozen");
 
64
        }
 
65
        this.bufferSize = bufferSize;
 
66
    }
 
67
 
 
68
 
 
69
    /**
 
70
     * The content type and character encoding to be set on each response.
 
71
     */
 
72
    protected String contentType = "text/html";
 
73
 
 
74
    public String getContentType() {
 
75
        return (this.contentType);
 
76
    }
 
77
 
 
78
    public void setContentType(String contentType) {
 
79
        if (configured) {
 
80
            throw new IllegalStateException("Configuration is frozen");
 
81
        }
 
82
        this.contentType = contentType;
 
83
    }
 
84
 
 
85
    /**
 
86
     * <p>The replacement pattern used to determine a context-relative URL
 
87
     * from a {@link ForwardConfig} element.  The pattern may consist of any
 
88
     * combination of the following markers and characters:</p>
 
89
     * <ul>
 
90
     * <li><code><strong>$M</strong></code> - Replaced by the module
 
91
     *     prefix for the current module.</li>
 
92
     * <li><code><strong>$P</strong></code> - Replaced by the <code>path</code>
 
93
     *     property of a {@link ForwardConfig} instance.</li>
 
94
     * <li><code><strong>$$</strong></code> - Renders a literal dollar sign
 
95
     *     ("$") character in the resulting URL.</li>
 
96
     * <li>A dollar sign followed by any other character is reserved for
 
97
     *     future use, and both characters are silently swallowed.</li>
 
98
     * <li>All other characters in the pattern are passed through unchanged.
 
99
     *     </li>
 
100
     * </ul>
 
101
     *
 
102
     * <p>If this property is set to <code>null</code>, a default pattern of
 
103
     * <code>$M$P</code> is utilized, which is backwards compatible with
 
104
     * the hard coded functionality in prior versions.</p>
 
105
     */
 
106
    protected String forwardPattern = null;
 
107
 
 
108
    public String getForwardPattern() {
 
109
        return (this.forwardPattern);
 
110
    }
 
111
 
 
112
    public void setForwardPattern(String forwardPattern) {
 
113
        this.forwardPattern = forwardPattern;
 
114
    }
 
115
 
 
116
 
 
117
    /**
 
118
     * <p>Should the <code>input</code> property of {@link ActionConfig}
 
119
     * instances associated with this module be treated as the
 
120
     * name of a corresponding {@link ForwardConfig}.  A <code>false</code>
 
121
     * value treats them as a module-relative path (consistent
 
122
     * with the hard coded behavior of earlier versions of Struts.</p>
 
123
     *
 
124
     * @since Struts 1.1
 
125
     */
 
126
    protected boolean inputForward = false;
 
127
 
 
128
    public boolean getInputForward() {
 
129
        return (this.inputForward);
 
130
    }
 
131
 
 
132
    public void setInputForward(boolean inputForward) {
 
133
        this.inputForward = inputForward;
 
134
    }
 
135
 
 
136
 
 
137
    /**
 
138
     * Should we store a Locale object in the user's session if needed?
 
139
     */
 
140
    protected boolean locale = true;
 
141
 
 
142
    public boolean getLocale() {
 
143
        return (this.locale);
 
144
    }
 
145
 
 
146
    public void setLocale(boolean locale) {
 
147
        if (configured) {
 
148
            throw new IllegalStateException("Configuration is frozen");
 
149
        }
 
150
        this.locale = locale;
 
151
    }
 
152
 
 
153
 
 
154
    /**
 
155
     * The maximum file size to process for file uploads.
 
156
     */
 
157
    protected String maxFileSize = "250M";
 
158
 
 
159
    public String getMaxFileSize() {
 
160
        return (this.maxFileSize);
 
161
    }
 
162
 
 
163
    public void setMaxFileSize(String maxFileSize) {
 
164
        if (configured) {
 
165
            throw new IllegalStateException("Configuration is frozen");
 
166
        }
 
167
        this.maxFileSize = maxFileSize;
 
168
    }
 
169
 
 
170
 
 
171
    /**
 
172
     * The maximum file size to retain in memory.
 
173
     */
 
174
    protected String memFileSize = "256K";
 
175
 
 
176
    public String getMemFileSize() {
 
177
        return (this.memFileSize);
 
178
    }
 
179
 
 
180
    public void setMemFileSize(String memFileSize) {
 
181
        if (configured) {
 
182
            throw new IllegalStateException("Configuration is frozen");
 
183
        }
 
184
        this.memFileSize = memFileSize;
 
185
    }
 
186
 
 
187
 
 
188
    /**
 
189
     * The fully qualified Java class name of the MultipartRequestHandler
 
190
     * class to be used.
 
191
     */
 
192
    protected String multipartClass =
 
193
        "org.apache.struts.upload.CommonsMultipartRequestHandler";
 
194
 
 
195
    public String getMultipartClass() {
 
196
        return (this.multipartClass);
 
197
    }
 
198
 
 
199
    public void setMultipartClass(String multipartClass) {
 
200
        if (configured) {
 
201
            throw new IllegalStateException("Configuration is frozen");
 
202
        }
 
203
        this.multipartClass = multipartClass;
 
204
    }
 
205
 
 
206
 
 
207
    /**
 
208
     * Should we set no-cache HTTP headers on each response?
 
209
     */
 
210
    protected boolean nocache = false;
 
211
 
 
212
    public boolean getNocache() {
 
213
        return (this.nocache);
 
214
    }
 
215
 
 
216
    public void setNocache(boolean nocache) {
 
217
        if (configured) {
 
218
            throw new IllegalStateException("Configuration is frozen");
 
219
        }
 
220
        this.nocache = nocache;
 
221
    }
 
222
 
 
223
 
 
224
    /**
 
225
     * <p>The replacement pattern used to determine a context-relative URL
 
226
     * from the <code>page</code> attribute of Struts tags and configuration
 
227
     * properties.  The pattern may consist of any combination of the
 
228
     * following markers and characters:</p>
 
229
     * <ul>
 
230
     * <li><code><strong>$M</strong></code> - Replaced by the module
 
231
     *     prefix for the current module.</li>
 
232
     * <li><code><strong>$P</strong></code> - Replaced by the <code>page</code>
 
233
     *     attribute value being evaluated.</li>
 
234
     * <li><code><strong>$$</strong></code> - Renders a literal dollar sign
 
235
     *     ("$") character in the resulting URL.</li>
 
236
     * <li>A dollar sign followed by any other character is reserved for
 
237
     *     future use, and both characters are silently swallowed.</li>
 
238
     * <li>All other characters in the pattern are passed through unchanged.
 
239
     *     </li>
 
240
     * </ul>
 
241
     *
 
242
     * <p>If this property is set to <code>null</code>, a default pattern of
 
243
     * <code>$M$P</code> is utilized, which is backwards compatible with
 
244
     * the hard coded functionality in prior versions.</p>
 
245
     */
 
246
    protected String pagePattern = null;
 
247
 
 
248
    public String getPagePattern() {
 
249
        return (this.pagePattern);
 
250
    }
 
251
 
 
252
    public void setPagePattern(String pagePattern) {
 
253
        this.pagePattern = pagePattern;
 
254
    }
 
255
 
 
256
 
 
257
    /**
 
258
     * The fully qualified class name of the RequestProcessor implementation
 
259
     * class to be used for this module.
 
260
     */
 
261
    protected String processorClass =
 
262
        "org.apache.struts.action.RequestProcessor";
 
263
 
 
264
    public String getProcessorClass() {
 
265
        return (this.processorClass);
 
266
    }
 
267
 
 
268
    public void setProcessorClass(String processorClass) {
 
269
        if (configured) {
 
270
            throw new IllegalStateException("Configuration is frozen");
 
271
        }
 
272
        this.processorClass = processorClass;
 
273
    }
 
274
 
 
275
 
 
276
    /**
 
277
     * The temporary working directory to use for file uploads.
 
278
     */
 
279
    protected String tempDir = null;
 
280
 
 
281
    public String getTempDir() {
 
282
        return (this.tempDir);
 
283
    }
 
284
 
 
285
    public void setTempDir(String tempDir) {
 
286
        if (configured) {
 
287
            throw new IllegalStateException("Configuration is frozen");
 
288
        }
 
289
        this.tempDir = tempDir;
 
290
    }
 
291
 
 
292
 
 
293
    // --------------------------------------------------------- Public Methods
 
294
 
 
295
 
 
296
    /**
 
297
     * Freeze the configuration of this component.
 
298
     */
 
299
    public void freeze() {
 
300
 
 
301
        configured = true;
 
302
 
 
303
    }
 
304
 
 
305
 
 
306
    /**
 
307
     * Return a String representation of this object.
 
308
     */
 
309
    public String toString() {
 
310
 
 
311
        StringBuffer sb = new StringBuffer("ControllerConfig[");
 
312
        sb.append("bufferSize=");
 
313
        sb.append(this.bufferSize);
 
314
        if (this.contentType != null) {
 
315
            sb.append(",contentType=");
 
316
            sb.append(this.contentType);
 
317
        }
 
318
        if (this.forwardPattern != null) {
 
319
            sb.append(",forwardPattern=");
 
320
            sb.append(this.forwardPattern);
 
321
        }
 
322
        sb.append(",inputForward=");
 
323
        sb.append(this.inputForward);
 
324
        sb.append(",locale=");
 
325
        sb.append(this.locale);
 
326
        if (this.maxFileSize != null) {
 
327
            sb.append(",maxFileSize=");
 
328
            sb.append(this.maxFileSize);
 
329
        }
 
330
        if (this.memFileSize != null) {
 
331
            sb.append(",memFileSize=");
 
332
            sb.append(this.memFileSize);
 
333
        }
 
334
        sb.append(",multipartClass=");
 
335
        sb.append(this.multipartClass);
 
336
        sb.append(",nocache=");
 
337
        sb.append(this.nocache);
 
338
        if (this.pagePattern != null) {
 
339
            sb.append(",pagePattern=");
 
340
            sb.append(this.pagePattern);
 
341
        }
 
342
        sb.append(",processorClass=");
 
343
        sb.append(this.processorClass);
 
344
        if (this.tempDir != null) {
 
345
            sb.append(",tempDir=");
 
346
            sb.append(this.tempDir);
 
347
        }
 
348
        sb.append("]");
 
349
        return (sb.toString());
 
350
 
 
351
    }
 
352
 
 
353
 
 
354
}