You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Anaximandro (Woody)" <ag...@globo.com> on 2005/02/01 09:12:53 UTC

[i18n] sugestion patch

Index: LocalizedBundle.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons-sandbox/i18n/src/java/org/apache/commons/i18
n/LocalizedBundle.java,v
retrieving revision 1.3
diff -u -r1.3 LocalizedBundle.java
--- LocalizedBundle.java 29 Dec 2004 17:03:55 -0000 1.3
+++ LocalizedBundle.java 1 Feb 2005 03:07:12 -0000
@@ -35,21 +35,19 @@
  * that might be used to include dynamic values into the message text and
knows nothing
  *
  */
-public class LocalizedBundle implements Serializable {
-    public final static String ID = "id";
-    public final static String ARGUMENTS = "arguments";
+public abstract class LocalizedBundle implements Serializable {

-    protected String id;
-    protected Object[] arguments;
+    private final String id;
+    private final Object[] arguments;

     /**
      * @param messageId The messageId refers the corresponding bundle in
the file containing
      * the localized messages. The format of the message file depends on
the implementation of the
      * MessageManager.
      */
-    public LocalizedBundle(String messageId) {
+    public LocalizedBundle(final String messageId) {
         this.id = messageId;
-        this.arguments = new Object[0];
+        this.arguments = null;
     }

     /**
@@ -59,7 +57,7 @@
      * @param arguments An array of objects containing argument for the
messages. These arguments
      * are used to insert dynamic values into the localized messages.
      */
-    public LocalizedBundle(String messageId, Object[] arguments) {
+    public LocalizedBundle(final String messageId, final Object[]
arguments) {
         this.id = messageId;
         this.arguments = arguments;
     }
@@ -68,14 +66,14 @@
      * @return returns the id of this bundle
      */
     public String getId() {
-        return id;
+        return this.id;
     }

     /**
      * @return returns the arguments associated with this message bundle
      */
     public Object[] getArguments() {
-     return arguments;
+     return this.arguments;
     }

     /**
@@ -85,8 +83,8 @@
      * @throws MessageNotFoundException if an entry with the given key can
not be found
      * in this bundle
      */
-    public String getText(String key, Locale locale) throws
MessageNotFoundException {
-        return MessageManager.getText(id, key, arguments, locale);
+    public String getEntry(final String key, final Locale locale) throws
MessageNotFoundException {
+        return MessageManager.getText(this.id, key, this.arguments,
locale);
     }

     /**
@@ -95,7 +93,7 @@
      * @param defaultText the text to be returned if no entry was found for
the given key
      * @return returns the localized text
      */
-    public String getText(String key, String defaultText, Locale locale) {
-        return MessageManager.getText(id, key, arguments, locale,
defaultText);
+    public String getEntry(final String key, final String defaultText,
final Locale locale) {
+        return MessageManager.getText(this.id, key, this.arguments, locale,
defaultText);
     }
 }
\ No newline at end of file
Index: LocalizedError.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons-sandbox/i18n/src/java/org/apache/commons/i18
n/LocalizedError.java,v
retrieving revision 1.1
diff -u -r1.1 LocalizedError.java
--- LocalizedError.java 4 Oct 2004 13:41:09 -0000 1.1
+++ LocalizedError.java 1 Feb 2005 03:07:12 -0000
@@ -37,34 +37,34 @@
     }

     public String getSummary() throws MessageNotFoundException {
-        return getText(SUMMARY, Locale.getDefault());
+        return getEntry(SUMMARY, Locale.getDefault());
     }

     public String getSummary(Locale locale) throws MessageNotFoundException
{
-        return getText(SUMMARY, locale);
+        return getEntry(SUMMARY, locale);
     }

     public String getSummary(String defaultSummary) {
-        return getText(SUMMARY, defaultSummary, Locale.getDefault());
+        return getEntry(SUMMARY, defaultSummary, Locale.getDefault());
     }

     public String getSummary(Locale locale, String defaultSummary) {
-        return getText(SUMMARY, defaultSummary, locale);
+        return getEntry(SUMMARY, defaultSummary, locale);
     }

     public String getDetails() throws MessageNotFoundException {
-        return getText(DETAILS, Locale.getDefault());
+        return getEntry(DETAILS, Locale.getDefault());
     }

     public String getDetails(Locale locale) throws MessageNotFoundException
{
-        return getText(DETAILS, locale);
+        return getEntry(DETAILS, locale);
     }

     public String getDetails(String defaultDetails) {
-        return getText(DETAILS, defaultDetails, Locale.getDefault());
+        return getEntry(DETAILS, defaultDetails, Locale.getDefault());
     }

     public String getDetails(Locale locale, String defaultDetails) {
-        return getText(DETAILS, defaultDetails, locale);
+        return getEntry(DETAILS, defaultDetails, locale);
     }
 }
\ No newline at end of file
Index: LocalizedMessage.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons-sandbox/i18n/src/java/org/apache/commons/i18
n/LocalizedMessage.java,v
retrieving revision 1.1
diff -u -r1.1 LocalizedMessage.java
--- LocalizedMessage.java 4 Oct 2004 13:41:09 -0000 1.1
+++ LocalizedMessage.java 1 Feb 2005 03:07:12 -0000
@@ -36,18 +36,18 @@
     }

     public String getTitle() throws MessageNotFoundException {
-        return getText(TITLE, Locale.getDefault());
+        return getEntry(TITLE, Locale.getDefault());
     }

     public String getTitle(Locale locale) throws MessageNotFoundException {
-        return getText(TITLE, locale);
+        return getEntry(TITLE, locale);
     }

     public String getTitle(String defaultTitle) {
-        return getText(TITLE, defaultTitle, Locale.getDefault());
+        return getEntry(TITLE, defaultTitle, Locale.getDefault());
     }

     public String getTitle(Locale locale, String defaultTitle) {
-        return getText(TITLE, defaultTitle, locale);
+        return getEntry(TITLE, defaultTitle, locale);
     }
 }
Index: LocalizedText.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons-sandbox/i18n/src/java/org/apache/commons/i18
n/LocalizedText.java,v
retrieving revision 1.1
diff -u -r1.1 LocalizedText.java
--- LocalizedText.java 4 Oct 2004 13:41:09 -0000 1.1
+++ LocalizedText.java 1 Feb 2005 03:07:12 -0000
@@ -36,18 +36,18 @@
     }

     public String getText() throws MessageNotFoundException  {
-        return getText(TEXT, Locale.getDefault());
+        return getEntry(TEXT, Locale.getDefault());
     }

     public String getText(Locale locale) throws MessageNotFoundException  {
-        return getText(TEXT, locale);
+        return getEntry(TEXT, locale);
     }

     public String getText(String defaultText) {
-        return getText(TEXT, defaultText, Locale.getDefault());
+        return getEntry(TEXT, defaultText, Locale.getDefault());
     }

     public String getText(Locale locale, String defaultText) {
-        return getText(TEXT, defaultText, locale);
+        return getEntry(TEXT, defaultText, locale);
     }
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org