11/*
2+ * Elemental
3+ * Copyright (C) 2024, Evolved Binary Ltd
4+ *
5+ 6+ * https://www.evolvedbinary.com | https://www.elemental.xyz
7+ *
8+ * This library is free software; you can redistribute it and/or
9+ * modify it under the terms of the GNU Lesser General Public
10+ * License as published by the Free Software Foundation; version 2.1.
11+ *
12+ * This library is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public
18+ * License along with this library; if not, write to the Free Software
19+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+ *
21+ * NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+ * The original license header is included below.
23+ *
24+ * =====================================================================
25+ *
226 * eXist-db Open Source Native XML Database
327 * Copyright (C) 2001 The eXist-db Authors
428 *
@@ -46,6 +70,26 @@ public boolean add(final Node node) {
4670 return super .add (node );
4771 }
4872
73+ /**
74+ * Add all elements of the other NodeListImpl to
75+ * this NodeListImpl.
76+ *
77+ * @param other NodeListImpl to add.
78+ *
79+ * @return true if the list was modified, false otherwise.
80+ */
81+ public boolean addAll (final NodeListImpl other ) {
82+ if (other == null ) {
83+ return false ;
84+ }
85+
86+ if (other .isEmpty ()) {
87+ return false ;
88+ }
89+
90+ return addAll ((ArrayList <Node >) other );
91+ }
92+
4993 /**
5094 * Add all elements of the other NodeList to
5195 * this NodeList
@@ -54,18 +98,26 @@ public boolean add(final Node node) {
5498 * if none or only some were added.
5599 */
56100 public boolean addAll (final NodeList other ) {
101+ if (other == null ) {
102+ return false ;
103+ }
104+
105+ if (other instanceof NodeListImpl ) {
106+ return addAll ((NodeListImpl ) other );
107+ }
108+
57109 if (other .getLength () == 0 ) {
58110 return false ;
59- } else {
60- boolean result = true ;
61- for ( int i = 0 ; i < other . getLength (); i ++) {
62- if (! add ( other .item ( i )) ) {
63- result = false ;
64- break ;
65- }
111+ }
112+
113+ boolean result = true ;
114+ for ( int i = 0 ; i < other .getLength (); i ++ ) {
115+ if (! add ( other . item ( i ))) {
116+ result = false ;
117+ break ;
66118 }
67- return result ;
68119 }
120+ return result ;
69121 }
70122
71123 @ Override
0 commit comments