You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by df...@apache.org on 2005/02/20 13:51:09 UTC

svn commit: r154508 - in jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n: LocalizedBundle.java MessageNotFoundException.java bundles/ErrorBundle.java bundles/MessageBundle.java bundles/TextBundle.java

Author: dflorey
Date: Sun Feb 20 04:51:07 2005
New Revision: 154508

URL: http://svn.apache.org/viewcvs?view=rev&rev=154508
Log:
Improved javadocs. Removed MessageBundle

Removed:
    jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/MessageBundle.java
Modified:
    jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedBundle.java
    jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/MessageNotFoundException.java
    jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java
    jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java

Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedBundle.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedBundle.java?view=diff&r1=154507&r2=154508
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedBundle.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/LocalizedBundle.java Sun Feb 20 04:51:07 2005
@@ -27,13 +27,17 @@
 import java.util.Locale;
 
 /**
- * @author Daniel Florey
  * 
- * The <code>LocalizedBundle</code> class represents a bundle of localized messages that
- * belong together.
- * The <code>LocalizedBundle</code> class itself contains the message id and the arguments
+ * <p>The <code>LocalizedBundle</code> class represents a bundle of localized messages that
+ * belong together.</p>
+ * <p> The <code>LocalizedBundle</code> class itself contains the message id and the arguments
  * that might be used to include dynamic values into the message text.
- *   
+ * The message id specifies the base name of the message bundle.
+ * Single entries of the message bundle can be retrieved using the <code>getText()</code> method by passing
+ * the key of the desired message entry.</p>  
+ * This class should not be used directly in order to retrieve entries of a message bundle. It is recommended
+ * to subclass the <code>LocalizedBundle</code> class in order to define a specific localized bundle. 
+ * @see TextBundle, MessageBundle, ErrorBundle    
  */
 public class LocalizedBundle implements Serializable {
     public final static String ID = "id";
@@ -79,11 +83,11 @@
     /**
      * @param key the key of the specific message entry in the message bundle
      * @param locale the locale for that this message should be rendered
-     * @return returns the localized text  
+     * @return returns the text of the desired message entry for the given locale  
      * @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 {
+    public String getEntry(String key, Locale locale) throws MessageNotFoundException {
         return MessageManager.getText(id, key, arguments, locale);
     }
 
@@ -91,9 +95,9 @@
      * @param key the key of the specific message entry in the message bundle
      * @param locale the locale for that this message should be rendered
      * @param defaultText the text to be returned if no entry was found for the given key
-     * @return returns the localized text  
+     * @return returns the text of the desired message entry for the given locale  
      */
-    public String getText(String key, String defaultText, Locale locale) {
+    public String getEntry(String key, String defaultText, Locale locale) {
         return MessageManager.getText(id, key, arguments, locale, defaultText);
     }
 }

Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/MessageNotFoundException.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/MessageNotFoundException.java?view=diff&r1=154507&r2=154508
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/MessageNotFoundException.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/MessageNotFoundException.java Sun Feb 20 04:51:07 2005
@@ -24,11 +24,39 @@
 
 import java.lang.RuntimeException;
 
+/**
+ * The <code>MessageNotFoundException</code> indicates that a particular message
+ * could not be found by using the given message id.
+ *
+ */
 public class MessageNotFoundException extends RuntimeException {
+    /**
+     * Constructs a new runtime exception with the specified detail message indicating that a particular message
+     * could not be found.
+     * The cause is not initialized, and may subsequently be initialized by a
+     * call to {@link #initCause}.
+     *
+     * @param   message   the detail message. The detail message is saved for 
+     *          later retrieval by the {@link #getMessage()} method.
+     */
     public MessageNotFoundException(String message) {
         super(message);
     }
 
+    /**
+     * Constructs a new runtime exception with the specified detail message indicating that a particular message and cause
+     * indicating that a particular message could not be found.
+     * <p>Note that the detail message associated with
+     * <code>cause</code> is <i>not</i> automatically incorporated in
+     * this runtime exception's detail message.
+     *
+     * @param  message the detail message (which is saved for later retrieval
+     *         by the {@link #getMessage()} method).
+     * @param  cause the cause (which is saved for later retrieval by the
+     *         {@link #getCause()} method).  (A <tt>null</tt> value is
+     *         permitted, and indicates that the cause is nonexistent or
+     *         unknown.)
+     */
     public MessageNotFoundException(String message, Throwable cause) {
         super(message, cause);
     }

Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java?view=diff&r1=154507&r2=154508
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/ErrorBundle.java Sun Feb 20 04:51:07 2005
@@ -26,31 +26,88 @@
 
 import org.apache.commons.i18n.MessageNotFoundException;
 
-public class ErrorBundle extends MessageBundle {
+
+/**
+ * <p>The <code>ErrorBundle</code> bundles together title, text, details and summary.</p>
+ * <p>This bundle can be used to describe an error in detail and is used in the provided localized
+ * exceptions.</p>
+ *
+ */
+public class ErrorBundle extends TextBundle {
+    public final static String TITLE = "title";
     public final static String SUMMARY = "summary";
     public final static String DETAILS = "details";
 
+    /**
+     * @param messageId Unique message id that identifies the message 
+     */
     public ErrorBundle(String messageId) {
         super(messageId);
     }
 
+    /**
+     * @param messageId Unique message id that identifies the message 
+     * @param arguments An array of objects conaining the values that should be
+     * inserted into the localized message.  
+     */
     public ErrorBundle(String messageId, Object[] arguments) {
         super(messageId, arguments);
     }
 
+
+    /**
+     * @param locale The locale that is used to find the appropriate localized text 
+     * @return returns the localized message entry with the key <code>title</code>
+     * @throws MessageNotFoundException is thrown if no entry with key <code>title</code> could be found in the message bundle identified by the given message identifier
+     */
+    public String getTitle(Locale locale) throws MessageNotFoundException {
+        return getEntry(TITLE, locale);
+    }
+
+    /**
+     * @param locale The locale that is used to find the appropriate localized text 
+     * @param defaultText The default text will be returned, if no entry with key <code>title</code> could be found in the message bundle identified by the given message identifier
+     * @return returns the localized message entry with the key <code>title</code>
+     */
+    public String getTitle(Locale locale, String defaultSummary) {
+        return getEntry(TITLE, defaultSummary, locale);
+    }
+
+
+    /**
+     * @param locale The locale that is used to find the appropriate localized text 
+     * @return returns the localized message entry with the key <code>summary</code>
+     * @throws MessageNotFoundException is thrown if no entry with key <code>summary</code> could be found in the message bundle identified by the given message identifier
+     */
     public String getSummary(Locale locale) throws MessageNotFoundException {
-        return getText(SUMMARY, locale);
+        return getEntry(SUMMARY, locale);
     }
 
+    /**
+     * @param locale The locale that is used to find the appropriate localized text 
+     * @param defaultText The default text will be returned, if no entry with key <code>summary</code> could be found in the message bundle identified by the given message identifier
+     * @return returns the localized message entry with the key <code>summary</code>
+     */
     public String getSummary(Locale locale, String defaultSummary) {
-        return getText(SUMMARY, defaultSummary, locale);
+        return getEntry(SUMMARY, defaultSummary, locale);
     }
 
+
+    /**
+     * @param locale The locale that is used to find the appropriate localized text 
+     * @return returns the localized message entry with the key <code>details</code>
+     * @throws MessageNotFoundException is thrown if no entry with key <code>details</code> could be found in the message bundle identified by the given message identifier
+     */
     public String getDetails(Locale locale) throws MessageNotFoundException {
-        return getText(DETAILS, locale);
+        return getEntry(DETAILS, locale);
     }
 
+    /**
+     * @param locale The locale that is used to find the appropriate localized text 
+     * @param defaultText The default text will be returned, if no entry with key <code>details</code> could be found in the message bundle identified by the given message identifier
+     * @return returns the localized message entry with the key <code>details</code>
+     */
     public String getDetails(Locale locale, String defaultDetails) {
-        return getText(DETAILS, defaultDetails, locale);
+        return getEntry(DETAILS, defaultDetails, locale);
     }
 }

Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java?view=diff&r1=154507&r2=154508
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/bundles/TextBundle.java Sun Feb 20 04:51:07 2005
@@ -27,22 +27,46 @@
 import org.apache.commons.i18n.LocalizedBundle;
 import org.apache.commons.i18n.MessageNotFoundException;
 
+/**
+ * <p>The <code>TextBundle</code> represents the most simple localized bundle with just
+ * one single entry. Use this class if you want to deal with simple localized strings that may
+ * contain dynamic elements.</p>
+ *
+ */
 public class TextBundle extends LocalizedBundle {
     public final static String TEXT = "text";
 
+    /**
+     * @param messageId Unique message id that identifies the message 
+     */
     public TextBundle(String messageId) {
         super(messageId);
     }
 
+    /**
+     * @param messageId Unique message id that identifies the message 
+     * @param arguments An array of objects conaining the values that should be
+     * inserted into the localized message.  
+     */
     public TextBundle(String messageId, Object[] arguments) {
         super(messageId, arguments);
     }
 
+    /**
+     * @param locale The locale that is used to find the appropriate localized text 
+     * @return returns the localized message entry with the key <code>text</code>
+     * @throws MessageNotFoundException is thrown if no entry with key <code>text</code> could be found in the message bundle identified by the given message identifier
+     */
     public String getText(Locale locale) throws MessageNotFoundException  {
-        return getText(TEXT, locale);
+        return getEntry(TEXT, locale);
     }
 
+    /**
+     * @param locale The locale that is used to find the appropriate localized text 
+     * @param defaultText The default text will be returned, if no entry with key <code>text</code> could be found in the message bundle identified by the given message identifier
+     * @return returns the localized message entry with the key <code>text</code>
+     */
     public String getText(Locale locale, String defaultText) {
-        return getText(TEXT, defaultText, locale);
+        return getEntry(TEXT, defaultText, locale);
     }
 }



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