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/01/02 14:26:15 UTC

cvs commit: jakarta-commons-sandbox/i18n/src/java/org/apache/commons/i18n MessageManager.java

dflorey     2005/01/02 05:26:15

  Modified:    i18n/src/java/org/apache/commons/i18n MessageManager.java
  Log:
  Some javadoc testings
  
  Revision  Changes    Path
  1.5       +39 -32    jakarta-commons-sandbox/i18n/src/java/org/apache/commons/i18n/MessageManager.java
  
  Index: MessageManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/i18n/src/java/org/apache/commons/i18n/MessageManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MessageManager.java	29 Dec 2004 17:03:55 -0000	1.4
  +++ MessageManager.java	2 Jan 2005 13:26:15 -0000	1.5
  @@ -27,53 +27,60 @@
   import java.util.Map;
   
   /**
  + * 
    * @author Daniel Florey
  - *
    */
   public class MessageManager {
       private static List messageProviders = new ArrayList();
       
       static {
  -        messageProviders.add(new XMLMessageProvider());
  -        messageProviders.add(new ResourceBundleMessageProvider());
  +	messageProviders.add(new XMLMessageProvider());
  +	messageProviders.add(new ResourceBundleMessageProvider());
       }
       
  -    public static void addMessageProvider(MessageProvider messageProvider) {
  -        messageProviders.add(messageProvider);
  +    /**
  + * Add a custom <code>{@link MessageProvider}</code> to the
  + * <code>MessageManager</code>. It will be incorporated in later calls of the
  + * {@link getText} or {@link getEntries} methods.
  + * 
  + * @param messageProvider The <code>MessageProvider</code> to be added.
  + */
  +public static void addMessageProvider(MessageProvider messageProvider) {
  +	messageProviders.add(messageProvider);
       }
       
       public static String getText(String id, String entry, Object[] arguments, Locale locale) throws MessageNotFoundException {
  -        MessageNotFoundException exception = null;
  -        for ( Iterator i = messageProviders.iterator(); i.hasNext(); ) {
  -            try {
  -                String text =((MessageProvider)i.next()).getText(id, entry, locale);
  -                return MessageFormat.format(text, arguments);
  -            } catch ( MessageNotFoundException e ) {
  -                exception = e;
  -            }
  -        }
  -        throw exception;
  +	MessageNotFoundException exception = null;
  +	for ( Iterator i = messageProviders.iterator(); i.hasNext(); ) {
  +	    try {
  +		String text =((MessageProvider)i.next()).getText(id, entry, locale);
  +		return MessageFormat.format(text, arguments);
  +	    } catch ( MessageNotFoundException e ) {
  +		exception = e;
  +	    }
  +	}
  +	throw exception;
       }
   
       public static String getText(String id, String entry, Object[] arguments, Locale locale, String defaultText) {
  -        try {
  -            String text = getText(id, entry, arguments, locale);
  -            return MessageFormat.format(text, arguments);
  -        } catch ( MessageNotFoundException e ) {
  -            return defaultText;
  -        }
  +	try {
  +	    String text = getText(id, entry, arguments, locale);
  +	    return MessageFormat.format(text, arguments);
  +	} catch ( MessageNotFoundException e ) {
  +	    return defaultText;
  +	}
       }
       
       public static Map getEntries(String id, Locale locale) throws MessageNotFoundException {
  -        MessageNotFoundException exception = null;
  -        for ( Iterator i = messageProviders.iterator(); i.hasNext(); ) {
  -            try {
  -                Map entries =((MessageProvider)i.next()).getEntries(id, locale);
  -                return entries;
  -            } catch ( MessageNotFoundException e ) {
  -                exception = e;
  -            }
  -        }
  -        throw exception;
  +	MessageNotFoundException exception = null;
  +	for ( Iterator i = messageProviders.iterator(); i.hasNext(); ) {
  +	    try {
  +		Map entries =((MessageProvider)i.next()).getEntries(id, locale);
  +		return entries;
  +	    } catch ( MessageNotFoundException e ) {
  +		exception = e;
  +	    }
  +	}
  +	throw exception;
       }
  -}
  \ 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