001: /*
002: * $Id: MessageResourcesConfig.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts.config;
022:
023: import org.apache.struts.Globals;
024:
025: /**
026: * <p>A JavaBean representing the configuration information of a
027: * <code><message-resources></code> element in a Struts configuration
028: * file.</p>
029: *
030: * @version $Rev: 471754 $ $Date: 2005-08-29 23:57:50 -0400 (Mon, 29 Aug 2005)
031: * $
032: * @since Struts 1.1
033: */
034: public class MessageResourcesConfig extends BaseConfig {
035: // ------------------------------------------------------------- Properties
036:
037: /**
038: * Fully qualified Java class name of the MessageResourcesFactory class we
039: * should use.
040: */
041: protected String factory = "org.apache.struts.util.PropertyMessageResourcesFactory";
042:
043: /**
044: * The servlet context attributes key under which this MessageResources
045: * instance is stored.
046: */
047: protected String key = Globals.MESSAGES_KEY;
048:
049: /**
050: * Should we return <code>null</code> for unknown message keys?
051: */
052: protected boolean nullValue = true;
053:
054: /**
055: * Indicates whether 'escape processing' should be performed on the error
056: * message string.
057: */
058: private boolean escape = true;
059:
060: /**
061: * Parameter that is passed to the <code>createResources()</code> method
062: * of our MessageResourcesFactory implementation.
063: */
064: protected String parameter = null;
065:
066: public String getFactory() {
067: return (this .factory);
068: }
069:
070: public void setFactory(String factory) {
071: if (configured) {
072: throw new IllegalStateException("Configuration is frozen");
073: }
074:
075: this .factory = factory;
076: }
077:
078: public String getKey() {
079: return (this .key);
080: }
081:
082: public void setKey(String key) {
083: if (configured) {
084: throw new IllegalStateException("Configuration is frozen");
085: }
086:
087: this .key = key;
088: }
089:
090: public boolean getNull() {
091: return (this .nullValue);
092: }
093:
094: public void setNull(boolean nullValue) {
095: if (configured) {
096: throw new IllegalStateException("Configuration is frozen");
097: }
098:
099: this .nullValue = nullValue;
100: }
101:
102: /**
103: * Indicates whether 'escape processing' should be performed on the error
104: * message string.
105: *
106: * @since Struts 1.2.8
107: */
108: public boolean isEscape() {
109: return escape;
110: }
111:
112: /**
113: * Set whether 'escape processing' should be performed on the error
114: * message string.
115: *
116: * @since Struts 1.2.8
117: */
118: public void setEscape(boolean escape) {
119: this .escape = escape;
120: }
121:
122: public String getParameter() {
123: return (this .parameter);
124: }
125:
126: public void setParameter(String parameter) {
127: if (configured) {
128: throw new IllegalStateException("Configuration is frozen");
129: }
130:
131: this .parameter = parameter;
132: }
133:
134: // --------------------------------------------------------- Public Methods
135:
136: /**
137: * Return a String representation of this object.
138: */
139: public String toString() {
140: StringBuffer sb = new StringBuffer("MessageResourcesConfig[");
141:
142: sb.append("factory=");
143: sb.append(this .factory);
144: sb.append(",null=");
145: sb.append(this .nullValue);
146: sb.append(",escape=");
147: sb.append(this .escape);
148: sb.append(",parameter=");
149: sb.append(this .parameter);
150: sb.append("]");
151:
152: return (sb.toString());
153: }
154: }
|