dlr 01/10/21 22:25:48
Modified: src/tool/org/apache/turbine/tool LocalizationTool.java
Log:
Added method for retrieving values with ad hoc key prefixes (even when
a key prefix is set).
Revision Changes Path
1.12 +20 -7
jakarta-turbine-3/src/tool/org/apache/turbine/tool/LocalizationTool.java
Index: LocalizationTool.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/tool/org/apache/turbine/tool/LocalizationTool.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -u -r1.11 -r1.12
--- LocalizationTool.java 2001/10/20 21:43:22 1.11
+++ LocalizationTool.java 2001/10/22 05:25:48 1.12
@@ -77,9 +77,6 @@
* <li>automatic language negotiation (already supported)</li>
* </ol></li>
*
- * <li>A method for retrieving the values keyed by prefix-less keys
- * when a key prefix is set.</li>
- *
* <li>Missing key message format pulled from TR.props.</li>
*
* </ul></p>
@@ -119,6 +116,14 @@
}
/**
+ * @see #get(String, String)
+ */
+ public String get(String key)
+ {
+ return get(null, key);
+ }
+
+ /**
* <p>Performs text lookups for localization.</p>
*
* <p>Assuming there is a instance of this class with a HTTP
@@ -128,12 +133,13 @@
* in Spanish (depending on the value of the HTTP request's
* <code>Accept-Language</code> header).</p>
*
+ * @param prefix Overrides {@link #getPrefix()}, or
+ * <code>null</code> to ignore it.
* @param key The identifier for the localized text to retrieve,
- * prepended by <code>getPrefix()</code> (if not
- * <code>null</code>).
+ * prepended by key prefix (if not <code>null</code>).
* @return The localized text.
*/
- public String get(String key)
+ public String get(String prefix, String key)
{
if (bundle == null)
{
@@ -143,11 +149,18 @@
try
{
- String prefix = getPrefix();
+ // Caller-supplied value overrides default key prefix.
+ if (prefix == null)
+ {
+ prefix = getPrefix();
+ }
+
+ // Prepend key prefix (if any).
if (prefix != null)
{
key = prefix + key;
}
+
return bundle.getString(key);
}
catch (MissingResourceException noKey)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]