> > // does its best to make an iterator for an object.
> > //
> > public static java.util.Iterator getIterator(java.lang.Object);
>
> what's the reasoning behind the above method? what's wrong with the
> iterator() method on Collection interface?
>
> Or is the idea that you can pass a single object to it that isn't of
> type Collection and still get back an iterator? i.e. be able to treat
> any object as a collection - just that single objects are always
> Collections of one :)
Yep. I use it in some JavaBeans stuff I have. I have an AbstractBeanViewer
which takes care of the dotted and []'d notation etc. Also in a code
generation framework of mine. In both cases I test an Object for
iteratableness by trying to get an iterator from it. So it handles turning
an Object[] into an iterator, Enumeration, getting the values of a Map
etc.
>
> ?
> >
> > // get sub-collection of a collection. need to add an array version too
> > public static java.util.Collection slice(java.util.Collection, int,
> > int);
> >
>
> how does the above work with Collections that don't have an explicit
> ordering, like a Map or Set?
>
Map's aren't Collections, so it doesn't work with them. Set's it treats in
iterator order, so you've a good point, it should be java.util.List
slice(java.util.List, int, int)
Bay