commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arron Bates <>
Subject [collections] - Few more collections for the masses... (important for Struts view objects, maybe other projects)
Date Fri, 17 May 2002 08:42:24 GMT

Have a couple of handy collections ready to fly, built and tested.. I 
couldn't find duplicate functionality in those already there, but you 
guys are the better judge of that.

Problem (if you want the reason for their existence)...
Struts (maybe you've heard of it) has this neato ability to create a 
requested bean for an action when it comes in from the request from the 
browser. Populates the top level bean really well. It will also populate 
any other object you put in its path. Great for most things. But... 
along comes nesting which allows for some wild data structures, and it's 
hard to assume their form when they come in, so this place holder thing 
gets a lot trickier. Add to this the fact you can now do funky trees, 
and it all goes to hell.

Easily solved with a server with at least gig of ram (virtual ram?) 
because you can just leave it all in the session. Some people don't take 
it all that well when I tell them this. Stroppy sods. So...

Solution (what the collections are)...
If the collections of objects and such could be constructed and set no 
matter what index or mapping they're built against, it would all work. 
This is what the collections do. Build objects and put them at whatever 
spot is asked for. Pass the bean's class (argument details optional) to 
the constructor, and it will build said object if need be. For the map, 
if n object is requested for a key that's not there, it will create the 
object, store it at the key and return the object. Sweet.

List does much the same thing, but with a couple of issues. If an object 
for an index is requested, the collection makes place-holders out to 
that index, creates and sets the new object. If more objects are set at 
lesser ones, then it swaps the place-holder for the new object. This 
potentially leaves place-holders in our collection. In the Struts use 
case, all things being equal, all the positions should fill up. But if 
they're not, then there's a "clean()" method provided to rip out all of 
the bad place-holders leaving a clean collection, ready to play.

They're proxies, so you pass them your concrete java.util.Map, or 
java.util.List implementation in the constructor, and they'll proxy in 
and out of that.

If everyone thinks they're cool, as I said they're ready to go.
Except I'm without the kudos to commit them to the commons CVS. I'd add 
them to Struts, but people get mad, red tape, have to take out the 
trash, you know the deal.

So either a committer who wants to support them commit them, or vote me 
into the tribe (my preference :)  I am a nice guy though. really).


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message