commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Curdt <tcu...@vafer.org>
Subject [collections] UnmodifiableBoundedCollection
Date Wed, 31 Mar 2004 14:07:17 GMT
Quoting from the javadocs

> UnmodifiableBoundedCollection decorates another BoundedCollection  to
> ensure it can't be altered.
> 
> If a BoundedCollection is first wrapped in some other collection 
> decorator, such as synchronized or predicated, the BoundedCollection 
> nature is lost. The factory on this class will attempt to retrieve the 
> bounded nature by examining the package scope variables. 

I wondered why this should be the case so I gave it a try:

         Map sm = MapUtils.synchronizedMap(new HashMap());
         Map m = MapUtils.fixedSizeMap(sm);
         m.put("a","value");

         Map m = MapUtils.fixedSizeMap(new HashMap());
         Map sm = MapUtils.synchronizedMap(m);
         sm.put("a","value");

Both examples throw an exception as exspected.
Can someone explain why the UnmodifiableBoundedCollection
is needed?

cheers
--
Torsten



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