Alex Blewitt wrote: > And you've still got the array, which was what Imeant in my last e-mail.
Some people like arrays, some people like Collection, others prefer iterators. I can see all sides and am happy eitherway, so long as you are consistent. However - JMX is not very Collection friendly, well many JMX agents anyway. Thus keeping to simple types where possible is best.
I do prefer to use Collections where possible...
Why not just Iterator? I don't see the benefit of ListIterator.But we still don't have a method to iterate over all the Components, or get them all. So either we need something like
ListIterator getComponentIterator()
Because: + Order and reverse order are important. You want to stop the components in the reverse order you started them. + Doing some operations like removal via the iterator can also be simpler, more efficient and less prone to simultaneous modification problems.
Remember ListIterator is-an Iterator so folks can treat it like a normal iterator.
public interface Container extends Component { public Iterator getComponents(); public void addComponent(Component component); public void removeComponent(Component component); }
Make that a ListIterator and I'm 95% happy.
Add the conveniance method for getting an array of ObjectNames and I'm 100%
+1
How's this?
public interface Container extends Component { public ListIterator getComponents(); public ListIterator getComponentNames(); public void addComponent(Component component); public void removeComponent(Component component); }
Though as soon as I did this something hit me - if you add a component by itself - and a component doesn't have an ObjectName (at least on the Component interface today) then how does the Container know the ObjectNames of the components? i.e. how can we implement the getComponentNames() method?
Maybe I've not grokked this code fully yet but either Container needs a getObjectName() or the addComponent() method should take an ObjectName right? This is echo-ing Jan's previous comment that Component should have a method...
ObjectName getObjectName();
(Jan - you used a String in your previous mail - did you mean String or ObjectName - am guessing the latter).
James ------- http://radio.weblogs.com/0112098/
