[jdom-interest] Bug in PartialList?

Falk Fraikin fraikin at informatik.tu-darmstadt.de
Fri May 11 01:51:03 PDT 2001


Hi,

I just received the latest CVS version, and well - is it possible that the
bug fix Alex Rosen sent in 3rd of May was not integrated in PartialList? For
reference (excerpt from Alex' mail):

START
Here's a patch for the bug I mentioned a while back. Without it, this will
fail:

Element e = new Element("test");
Element e2 = new Element("test2");
List list = e.getChildren();
list.add(0, e2);

============================================================================
==
RCS file: /home/cvspublic/jdom/src/java/org/jdom/PartialList.java,v
retrieving revision 1.9
diff -u -r1.9 PartialList.java
--- PartialList.java	2001/04/27 18:21:20	1.9
+++ PartialList.java	2001/05/03 04:53:26
@@ -143,6 +143,11 @@
      * Inserts the given element at the beginning of this list.
      */
     public void addFirst(Object o) {
+        if (size() == 0) {
+            add(o);
+            return;
+        }
+
         int index = backingList.indexOf(getFirst());
         super.addFirst(o);

@@ -162,6 +167,11 @@
      * function to the <tt>add</tt> method; included only for consistency.)
      */
     public void addLast(Object o) {
+        if (size() == 0) {
+            add(o);
+            return;
+        }
+
         int index = backingList.indexOf(getLast());
         super.addLast(o);

END

Regards,

Falk Fraikin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20010511/e051729a/attachment.htm


More information about the jdom-interest mailing list