1
1
/*
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
+ *
2
26
* eXist-db Open Source Native XML Database
3
27
* Copyright (C) 2001 The eXist-db Authors
4
28
*
@@ -46,6 +70,26 @@ public boolean add(final Node node) {
46
70
return super .add (node );
47
71
}
48
72
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
+
49
93
/**
50
94
* Add all elements of the other NodeList to
51
95
* this NodeList
@@ -54,18 +98,26 @@ public boolean add(final Node node) {
54
98
* if none or only some were added.
55
99
*/
56
100
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
+
57
109
if (other .getLength () == 0 ) {
58
110
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 ;
66
118
}
67
- return result ;
68
119
}
120
+ return result ;
69
121
}
70
122
71
123
@ Override
0 commit comments