KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > config > MessageResourcesConfig


1 /*
2  * $Id: MessageResourcesConfig.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19
20 package org.apache.struts.config;
21
22
23 import java.io.Serializable JavaDoc;
24 import org.apache.struts.Globals;
25
26
27 /**
28  * <p>A JavaBean representing the configuration information of a
29  * <code>&lt;message-resources&gt;</code> element in a Struts
30  * configuration file.</p>
31  *
32  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
33  * @since Struts 1.1
34  */

35
36 public class MessageResourcesConfig implements Serializable JavaDoc {
37
38
39     // ----------------------------------------------------- Instance Variables
40

41
42     /**
43      * Has this component been completely configured?
44      */

45     protected boolean configured = false;
46
47
48     // ------------------------------------------------------------- Properties
49

50
51     /**
52      * Fully qualified Java class name of the MessageResourcesFactory class
53      * we should use.
54      */

55     protected String JavaDoc factory =
56         "org.apache.struts.util.PropertyMessageResourcesFactory";
57
58     public String JavaDoc getFactory() {
59         return (this.factory);
60     }
61
62     public void setFactory(String JavaDoc factory) {
63         if (configured) {
64             throw new IllegalStateException JavaDoc("Configuration is frozen");
65         }
66         this.factory = factory;
67     }
68
69
70     /**
71      * The servlet context attributes key under which this MessageResources
72      * instance is stored.
73      */

74     protected String JavaDoc key = Globals.MESSAGES_KEY;
75
76     public String JavaDoc getKey() {
77         return (this.key);
78     }
79
80     public void setKey(String JavaDoc key) {
81         if (configured) {
82             throw new IllegalStateException JavaDoc("Configuration is frozen");
83         }
84         this.key = key;
85     }
86
87
88     /**
89      * Should we return <code>null</code> for unknown message keys?
90      */

91     protected boolean nullValue = true;
92
93     public boolean getNull() {
94         return (this.nullValue);
95     }
96
97     public void setNull(boolean nullValue) {
98         if (configured) {
99             throw new IllegalStateException JavaDoc("Configuration is frozen");
100         }
101         this.nullValue = nullValue;
102     }
103
104
105     /**
106      * Parameter that is passed to the <code>createResources()</code> method
107      * of our MessageResourcesFactory implementation.
108      */

109     protected String JavaDoc parameter = null;
110
111     public String JavaDoc getParameter() {
112         return (this.parameter);
113     }
114
115     public void setParameter(String JavaDoc parameter) {
116         if (configured) {
117             throw new IllegalStateException JavaDoc("Configuration is frozen");
118         }
119         this.parameter = parameter;
120     }
121
122
123     // --------------------------------------------------------- Public Methods
124

125
126     /**
127      * Freeze the configuration of this component.
128      */

129     public void freeze() {
130
131         configured = true;
132
133     }
134
135
136     /**
137      * Return a String representation of this object.
138      */

139     public String JavaDoc toString() {
140
141         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("MessageResourcesConfig[");
142         sb.append("factory=");
143         sb.append(this.factory);
144         sb.append(",null=");
145         sb.append(this.nullValue);
146         sb.append(",parameter=");
147         sb.append(this.parameter);
148         sb.append("]");
149         return (sb.toString());
150
151     }
152
153
154 }
155
Popular Tags