commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Pemberton <niall.pember...@gmail.com>
Subject Re: [RESOURCES] Messages vs. regular properties
Date Thu, 01 Dec 2005 02:00:03 GMT
On 12/1/05, Michael Jouravlev <jmikus@gmail.com> wrote:
> Do I miss something or messages and resources are incompatible? From
> my point of view they are basically the same thing. Differences are:
>
>  * resources can be anything, messages can be only strings
>  * messages take parameters to stick into placeholders

If were talking in Commons Resources terms then Resources and Message
are different things - a Message is the representation of the key to a
resource - Resources are what resolve those keys into the resource
object.

Messages is a convenience class provided to do the following processing:

1) Resolve a resources key into its String value
2) Do parametric replacement of arguments using MessageFormat


> So why two sets of classes, which are so different? For example, I was
> able to easily load message from property file located in the
> classpath, but I could not do the same treating message as resource,
> because current API does not search in classpath. Or does it? Locale
> is not optional, should it be?

Different resources implementations look for different things
PropertyMessageResources uses a URL to locale properties files. If you
want something different then you can take one of the base
implementations and easily provide your own.

> Maybe it is possible to introduce Property class, make Message
> subclass of Property. Ditch Messages class and create one Properties
> class (or some other name) that holds both properties and messages and
> whatnot.

There are implementations based both on properties files and XML
already - check out the user guide.

Niall

> At any rate, the usage of properties and messages should be identical.
>
> Michael.

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


Mime
View raw message