commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [collections] Modify getter result
Date Mon, 20 Dec 2004 20:17:02 GMT
See LazyMap.
Stephen

----- Original Message ----- 
From: "Nentwig, Timo" <timo.nentwig@jamba-ag.de>
I'm not sure whether this can be done with commons-collections. 

I need to hook in a collection and return a default value when the
requested key does not exist in the collection. E.g.

Map currency = new HashMap()
{
{
put("DE", "EUR");
put("US", "USD");
}
};

And currency.get("XY") is supposed to return a default value (this may
require additional logic and e.g. may write to the logger that an yet
unsupported ISOCODE was requested).

Can this be done?

Kind regards
Timo

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




---------------------------------------------------------------------
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