View Javadoc

1   /*
2    *
3    * ====================================================================
4    *
5    * The Apache Software License, Version 1.1
6    *
7    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
8    * reserved.
9    *
10   * Redistribution and use in source and binary forms, with or without
11   * modification, are permitted provided that the following conditions
12   * are met:
13   *
14   * 1. Redistributions of source code must retain the above copyright
15   *    notice, this list of conditions and the following disclaimer.
16   *
17   * 2. Redistributions in binary form must reproduce the above copyright
18   *    notice, this list of conditions and the following disclaimer in
19   *    the documentation and/or other materials provided with the
20   *    distribution.
21   *
22   * 3. The end-user documentation included with the redistribution, if
23   *    any, must include the following acknowlegement:
24   *       "This product includes software developed by the
25   *        Apache Software Foundation (http://www.apache.org/)."
26   *    Alternately, this acknowlegement may appear in the software itself,
27   *    if and wherever such third-party acknowlegements normally appear.
28   *
29   * 4. The names "The Jakarta Project", "Struts", and "Apache Software
30   *    Foundation" must not be used to endorse or promote products derived
31   *    from this software without prior written permission. For written
32   *    permission, please contact apache@apache.org.
33   *
34   * 5. Products derived from this software may not be called "Apache"
35   *    nor may "Apache" appear in their names without prior written
36   *    permission of the Apache Group.
37   *
38   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49   * SUCH DAMAGE.
50   * ====================================================================
51   *
52   * This software consists of voluntary contributions made by many
53   * individuals on behalf of the Apache Software Foundation.  For more
54   * information on the Apache Software Foundation, please see
55   * <http://www.apache.org/>.
56   *
57   */
58  /** ------------------------------------
59   * SweetDEV RIA library
60   * Copyright [2006 - 2010] [Ideo Technologies]
61   * ------------------------------------
62   *
63   * Licensed under the Apache License, Version 2.0 (the "License");
64   * you may not use this file except in compliance with the License.
65   * You may obtain a copy of the License at
66   *
67   * 		http://www.apache.org/licenses/LICENSE-2.0
68   *
69   * Unless required by applicable law or agreed to in writing, software
70   * distributed under the License is distributed on an "AS IS" BASIS,
71   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72   * See the License for the specific language governing permissions and
73   * limitations under the License.
74   *
75   *
76   * For more information, please contact us at:
77   *         Ideo Technologies S.A
78   *        124 rue de Verdun
79   *        92800 Puteaux - France
80   *
81   *      France & Europe Phone : +33 1.46.25.09.60
82   *
83   *
84   *        web : http://www.ideotechnologies.com
85   *        email : SweetDEV-RIA@ideotechnologies.com
86   *
87   *
88   * @version ${pom.version}
89   * @author Ideo Technologies
90   */
91  package com.ideo.sweetdevria.config.elements;
92  
93  import java.io.Serializable;
94  
95  /**
96   * <p>A JavaBean representing the configuration information of a <code>&lt;message-resources&gt;</code> element in a RIA configuration file.</p>
97   */
98  public class MessageResourcesConfig implements Serializable {
99  
100     /**
101 	 * Generated serial version UID.
102 	 */
103 	private static final long serialVersionUID = 4265710466604207858L;
104 
105 	/**
106      * Has this component been completely configured?
107      */
108     protected boolean configured = false;
109 
110     /**
111      * Fully qualified Java class name of the MessageResourcesFactory class
112      * we should use.
113      */
114     protected String factory = "com.ideo.sweetdevria.util.PropertyMessageResourcesFactory";
115 
116     /**
117      * Get the factory.
118      * @return  Returns the factory.
119      */
120     public String getFactory() {
121         return (this.factory);
122     }
123 
124     /**
125      * Set the factory.
126      * @param factory  The factory to set.
127      */
128     public void setFactory(String factory) {
129         if (configured) {
130             throw new IllegalStateException("Configuration is frozen");
131         }
132         this.factory = factory;
133     }
134 
135     /**
136      * The servlet context attributes key under which this MessageResources
137      * instance is stored.
138      */
139     //protected String key = Globals.MESSAGES_KEY;
140     protected String key = "??";
141 
142     /**
143      * Get the key.
144      * @return  Returns the key.
145      */
146     public String getKey() {
147         return (this.key);
148     }
149 
150     /**
151      * Set the key.
152      * @param key  The key to set.
153      */
154     public void setKey(String key) {
155         if (configured) {
156             throw new IllegalStateException("Configuration is frozen");
157         }
158         this.key = key;
159     }
160 
161     /**
162      * Should we return <code>null</code> for unknown message keys?
163      */
164     protected boolean nullValue = true;
165 
166     public boolean getNull() {
167         return (this.nullValue);
168     }
169 
170     public void setNull(boolean nullValue) {
171         if (configured) {
172             throw new IllegalStateException("Configuration is frozen");
173         }
174         this.nullValue = nullValue;
175     }
176 
177     /**
178      * Parameter that is passed to the <code>createResources()</code> method
179      * of our MessageResourcesFactory implementation.
180      */
181     protected String parameter = null;
182 
183     /**
184      * Get the parameter.
185      * @return  Returns the parameter.
186      */
187     public String getParameter() {
188         return (this.parameter);
189     }
190 
191     /**
192      * Set the parameter.
193      * @param parameter  The parameter to set.
194      */
195     public void setParameter(String parameter) {
196         if (configured) {
197             throw new IllegalStateException("Configuration is frozen");
198         }
199         this.parameter = parameter;
200     }
201 
202     /**
203      * Freeze the configuration of this component.
204      */
205     public void freeze() {
206 
207         configured = true;
208 
209     }
210 
211     /**
212      * Return a String representation of this object.
213      */
214     public String toString() {
215 
216         StringBuffer sb = new StringBuffer("MessageResourcesConfig[");
217         sb.append("factory=");
218         sb.append(this.factory);
219         sb.append(",null=");
220         sb.append(this.nullValue);
221         sb.append(",parameter=");
222         sb.append(this.parameter);
223         sb.append("]");
224         return (sb.toString());
225 
226     }
227 }