EventListModel.getElementAt(...)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

EventListModel.getElementAt(...)

Bigler Mark
EventListModel.getElementAt(...)

hi developers :)

imagine we have an EventList with 3 elements. the method getElementAt(100)
from the EventListModel of this EventList returns "null". when using a negative
index (e.g. -100) then you receive an "ArrayIndexOutOfBoundsException".

in my opinion it would be nice to return always "null" in case of an illegal index
or at least put a remark of that behaviour into the javadoc:

http://publicobject.com/glazedlists/glazedlists-1.0.0/api/ca/odell/glazedlists/swing/EventListModel.html#getElementAt(int)
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/ListModel.html#getElementAt(int)


cheers,
mark bigler

Reply | Threaded
Open this post in threaded view
|

Re: EventListModel.getElementAt(...)

James Lemieux
Hey Mark,
 
     This behaviour is completely inconsistent with DefaultTableModel and DefaultListModel. We will change EventListModel.getElementAt() and EventTableModel.getValueAt() to throw ArrayIndexOutOfBoundsExceptions if you pass any index that is illegal according to the underlying EventList. This is precisely what happens in DefaultTableModel and DefaultListModel.
 
     Thanks for the heads up. Look for an update to the latest build tonight with the fixes for these problems.
 
James

 
On 11/9/05, Bigler Mark <[hidden email]> wrote:

hi developers :)

imagine we have an EventList with 3 elements. the method getElementAt(100)
from the EventListModel of this EventList returns "null". when using a negative
index ( e.g. -100) then you receive an "ArrayIndexOutOfBoundsException".

in my opinion it would be nice to return always "null" in case of an illegal index
or at least put a remark of that behaviour into the javadoc:

<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://publicobject.com/glazedlists/glazedlists-1.0.0/api/ca/odell/glazedlists/swing/EventListModel.html#getElementAt(int" target="_blank">http://publicobject.com/glazedlists/glazedlists-1.0.0/api/ca/odell/glazedlists/swing/EventListModel.html#getElementAt(int )
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/ListModel.html#getElementAt(int" target="_blank">http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/ListModel.html#getElementAt(int )


cheers,
mark bigler


Reply | Threaded
Open this post in threaded view
|

Re: EventListModel.getElementAt(...)

James Lemieux
Mark,

     I've implemented the changes I outlined below. The methods now always throw IndexOutOfBoundsExceptions. Thanks for the heads up. The updated jars can be found here:

https://glazedlists.dev.java.net/servlets/ProjectDocumentList?folderID=3916&expandFolder=3916&folderID=3916

Thanks,

James

On 11/9/05, James Lemieux <[hidden email]> wrote:
Hey Mark,
 
     This behaviour is completely inconsistent with DefaultTableModel and DefaultListModel. We will change EventListModel.getElementAt() and EventTableModel.getValueAt() to throw ArrayIndexOutOfBoundsExceptions if you pass any index that is illegal according to the underlying EventList. This is precisely what happens in DefaultTableModel and DefaultListModel.
 
     Thanks for the heads up. Look for an update to the latest build tonight with the fixes for these problems.
 
James

 
On 11/9/05, Bigler Mark <[hidden email]> wrote:

hi developers :)

imagine we have an EventList with 3 elements. the method getElementAt(100)
from the EventListModel of this EventList returns "null". when using a negative
index ( e.g. -100) then you receive an "ArrayIndexOutOfBoundsException".

in my opinion it would be nice to return always "null" in case of an illegal index
or at least put a remark of that behaviour into the javadoc:

<a href="http://publicobject.com/glazedlists/glazedlists-1.0.0/api/ca/odell/glazedlists/swing/EventListModel.html#getElementAt%28int" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://publicobject.com/glazedlists/glazedlists-1.0.0/api/ca/odell/glazedlists/swing/EventListModel.html#getElementAt(int )
<a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/ListModel.html#getElementAt%28int" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/ListModel.html#getElementAt(int )


cheers,
mark bigler