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/21 19:16:35 UTC

svn commit: r154701 - in jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n: ResourceBundleMessageProvider.java XMLMessageProvider.java

Author: dflorey
Date: Mon Feb 21 10:16:33 2005
New Revision: 154701

URL: http://svn.apache.org/viewcvs?view=rev&rev=154701
Log:
Javadocs added

Modified:
    jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/ResourceBundleMessageProvider.java
    jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/XMLMessageProvider.java

Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/ResourceBundleMessageProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/ResourceBundleMessageProvider.java?view=diff&r1=154700&r2=154701
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/ResourceBundleMessageProvider.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/ResourceBundleMessageProvider.java Mon Feb 21 10:16:33 2005
@@ -33,13 +33,18 @@
 import java.util.logging.Logger;
 
 /**
- *
+ * The <code>ResourceBundleMessageProvider</code> deals with messages defined in 
+ * resource bundles. Messages defined in resource bundles can be grouped together
+ * by adding the entry key at the end of the message key separated by a dot.
  */
 public class ResourceBundleMessageProvider implements MessageProvider {
     private static Logger logger = Logger.getLogger(ResourceBundleMessageProvider.class.getName());
 
     private static List installedResourceBundles = new ArrayList();
 
+    /* (non-Javadoc)
+     * @see org.apache.commons.i18n.MessageProvider#getText(java.lang.String, java.lang.String, java.util.Locale)
+     */
     public String getText(String id, String entry, Locale locale) throws MessageNotFoundException {
         String text = null;
         for ( Iterator i = installedResourceBundles.iterator(); i.hasNext(); ) {
@@ -67,6 +72,9 @@
                 new String[] { id })); 
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.commons.i18n.MessageProvider#getEntries(java.lang.String, java.util.Locale)
+     */
     public Map getEntries(String id, Locale locale) {
         String messageIdentifier = id+".";
         Map entries = null;
@@ -100,15 +108,34 @@
         return entries;
     }
     
+    /**
+     * Installs a new resource bundle containing messages for a specific locale 
+     * with the given name.
+     * 
+     * @param baseName the name of the resource bundle. This name will be used to 
+     * find the resource bundle by using the java mechanisms for loading resource bundles
+     * and to uninstall or update the messages contained in the resource bundle.
+     * 
+     */
     public static void install(String baseName) {
         if ( !installedResourceBundles.contains(baseName) ) 
             installedResourceBundles.add(baseName); 
     }
     
+    /**
+     * @param baseName unique identifier for the resource bundle to uninstall
+     */
     public static void uninstall(String baseName) {
         installedResourceBundles.remove(baseName);
     }
     
+    /**
+     * Update the resources specified by the given unique identifier.
+     * As the messages defined in resource bundles are not cached by the
+     * current implementation, calling this method has no effect.
+     * This may change in future versions. 
+     * @param baseName unique identifier for the resource bundle to update
+     */
     public static void update(String baseName) {
         uninstall(baseName);
         install(baseName);

Modified: jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/XMLMessageProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/XMLMessageProvider.java?view=diff&r1=154700&r2=154701
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/XMLMessageProvider.java (original)
+++ jakarta/commons/sandbox/i18n/trunk/src/java/org/apache/commons/i18n/XMLMessageProvider.java Mon Feb 21 10:16:33 2005
@@ -37,8 +37,8 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /**
- * @author Daniel Florey
- *
+ * The <code>XMLMessageProvider</code> provides messages defined in an XML format.
+ *  
  */
 public class XMLMessageProvider implements MessageProvider {
     private static Logger logger = Logger.getLogger(XMLMessageProvider.class.getName());
@@ -48,16 +48,29 @@
     private static Map installedMessages = new HashMap();
     private static Map messages = new HashMap();
     
+    /* (non-Javadoc)
+     * @see org.apache.commons.i18n.MessageProvider#getText(java.lang.String, java.lang.String, java.util.Locale)
+     */
     public String getText(String id, String entry, Locale locale) throws MessageNotFoundException {
         Message message = findMessage(id, locale);
         return message.getEntry(entry);
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.commons.i18n.MessageProvider#getEntries(java.lang.String, java.util.Locale)
+     */
     public Map getEntries(String id, Locale locale) throws MessageNotFoundException {
         Message message = findMessage(id, locale);
         return message.getEntries();
     }
 
+    /**
+     * Installs a bunch of messages provided by the given <code>InputStream</code> for all locales specifed 
+     * in the given source. The messages can be uninstalled or updated by using the given unique identifier.
+     * 
+     * @param id the unique identifier for unistalling or updating the provided messages
+     * @param inputStream providing the messages in the required XML format 
+     */
     public static void install(String id, InputStream inputStream) {
         try {
             Map applicationMessages = new HashMap();
@@ -76,6 +89,9 @@
         }
     }
     
+    /**
+     * @param id unique identifier for the messages to uninstall
+     */
     public static void uninstall(String id) {
         Collection messageKeys = (Collection)installedMessages.get(id);
         for ( Iterator i = messageKeys.iterator(); i.hasNext(); ) {
@@ -85,6 +101,10 @@
         installedMessages.remove(id);
     }
     
+    /**
+     * @param id unique identifier for the messages to update
+     * @param inputStream providing the updated messages in the required XML format
+     */
     public static void update(String id, InputStream inputStream) {
         uninstall(id);
         install(id, inputStream);



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