commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37711] - [resources] Messages Refactoring
Date Sun, 04 Dec 2005 19:58:09 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37711>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37711





------- Additional Comments From chris@absolutegiganten.org  2005-12-04 20:58 -------
(In reply to comment #0)
> 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.

+ 1

> 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().

So getMessages would do a setFactory as a side effect. Sounds ugly. Or do you
want to remove the static factory member altogether ?
 
> 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, "foo.bar", Messages.args
> ("first", "second"));

After letting it sink in a couple of days I second Michael on this one. Only one
instance method with Object[] and no convenience methods which provide no real
advantage over a new Object[] {}. 


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message