dlr 01/10/21 23:08:09
Modified: src/tool/org/apache/turbine/tool LocalizationTool.java
Log:
Shuffled JavaDoc and changed API slightly to allow for easier behavior
overrides via sub-classing.
Revision Changes Path
1.13 +24 -20
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.12
retrieving revision 1.13
diff -u -u -r1.12 -r1.13
--- LocalizationTool.java 2001/10/22 05:25:48 1.12
+++ LocalizationTool.java 2001/10/22 06:08:09 1.13
@@ -116,14 +116,6 @@
}
/**
- * @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
@@ -133,11 +125,24 @@
* 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 key prefix returned by {@link #getPrefix(String)}
+ * (if not <code>null</code>).
+ * @return The localized text.
+ * @see #get(String, String)
+ */
+ public String get(String key)
+ {
+ return get(null, key);
+ }
+
+ /**
+ * @param prefix A key prefix override which is passed to {@link
+ * #getPrefix(String)}.
+ * @param key The identifier for the localized text to retrieve,
* prepended by key prefix (if not <code>null</code>).
* @return The localized text.
+ * @see #get(String)
*/
public String get(String prefix, String key)
{
@@ -149,13 +154,8 @@
try
{
- // Caller-supplied value overrides default key prefix.
- if (prefix == null)
- {
- prefix = getPrefix();
- }
-
- // Prepend key prefix (if any).
+ // Determine prefix, and prepend to key (if necessary).
+ prefix = getPrefix(prefix);
if (prefix != null)
{
key = prefix + key;
@@ -185,13 +185,17 @@
/**
* Returns the prefix prepended to keys used to retrieve localized
- * text.
+ * text. This method could be overridden to introduce separator
+ * text between prefix and key (i.e. <code>prefix__key</code>).
*
+ * @param override Overrides the key prefix set for this instance,
+ * or ignored if <code>null</code>.
* @return The prefix to prepend to localization keys.
*/
- protected String getPrefix()
+ protected String getPrefix(String override)
{
- return keyPrefix;
+ // Caller-supplied value overrides default key prefix.
+ return (override == null ? keyPrefix : override);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]