commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Meikle (JIRA)" <>
Subject [jira] Updated: (RESOURCES-17) [resources] Messages Refactoring
Date Fri, 29 May 2009 04:32:45 GMT


Dave Meikle updated RESOURCES-17:

    Attachment: RESOURCES-17.diff

Attached is a patch with proposed API changes based on the comments above - any comments or
other things we want to change whilst we are here?

> [resources] Messages Refactoring
> --------------------------------
>                 Key: RESOURCES-17
>                 URL:
>             Project: Commons Resources
>          Issue Type: Bug
>         Environment: Operating System: All
> Platform: All
>            Reporter: Niall Pemberton
>            Priority: Critical
>         Attachments: RESOURCES-17.diff
> I'm proposing the Messages's API change to the following:
>   public void setDefaultLocale(Locale locale)
>   public Locale getDefaultLocale()
>   public String getMessage(String key)
>   public String getMessage(String key, Object[] args)
>   public String getMessage(String key, Locale locale) 
>   public String getMessage(String key, String key, Object[] args, Locale locale)
>   public static Resources getMessages(ResourcesFactory factory, String name)
>   public static Object[] args(Object arg0)
>   public static Object[] args(Object arg0, Object arg1)
>   public static Object[] args(Object arg0, Object arg1, Object arg2)
>   public static Object[] args(Object arg0, Object arg1, Object arg2, Object 
> arg3)
> ...for the following reasoning:
> 1) Remove the static getMessage() methods from the Messages object. The problem 
> is that currently the instance methods all call one of the static methods to do 
> the MessageFormat processing making this class difficult to create custom 
> implementations for.
> 2) Change the getMessage() parameter order to key, args, locale (as per Bug 
> 37702)
> 3) Remove the static setFactory method and change the static getMessages method 
> to include a Factory parameter - that way there would be no conflict with 
> different parts of an application having to set a static instance variable 
> before calling getMessages().
> 4) Only have one instance method that has an Object[] for arguments, but add 
> static convenience methods for turning arguments into an Object[].  Users could 
> then do something like the following:
>  String msg = messages.getMessage(locale, "", Messages.args
> ("first", "second"));
> 5) Provide methods to set the default Locale, if not supplied in the getMessage
> () methods.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message