• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

evolvedbinary / elemental / 982

29 Apr 2025 08:34PM UTC coverage: 56.409% (+0.007%) from 56.402%
982

push

circleci

adamretter
[feature] Improve README.md badges

28451 of 55847 branches covered (50.94%)

Branch coverage included in aggregate %.

77468 of 131924 relevant lines covered (58.72%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.67
/exist-core/src/main/java/org/exist/dom/memtree/AttrImpl.java
1
/*
2
 * Elemental
3
 * Copyright (C) 2024, Evolved Binary Ltd
4
 *
5
 * admin@evolvedbinary.com
6
 * https://www.evolvedbinary.com | https://www.elemental.xyz
7
 *
8
 * Use of this software is governed by the Business Source License 1.1
9
 * included in the LICENSE file and at www.mariadb.com/bsl11.
10
 *
11
 * Change Date: 2028-04-27
12
 *
13
 * On the date above, in accordance with the Business Source License, use
14
 * of this software will be governed by the Apache License, Version 2.0.
15
 *
16
 * Additional Use Grant: Production use of the Licensed Work for a permitted
17
 * purpose. A Permitted Purpose is any purpose other than a Competing Use.
18
 * A Competing Use means making the Software available to others in a commercial
19
 * product or service that: substitutes for the Software; substitutes for any
20
 * other product or service we offer using the Software that exists as of the
21
 * date we make the Software available; or offers the same or substantially
22
 * similar functionality as the Software.
23
 *
24
 * NOTE: Parts of this file contain code from 'The eXist-db Authors'.
25
 *       The original license header is included below.
26
 *
27
 * =====================================================================
28
 *
29
 * eXist-db Open Source Native XML Database
30
 * Copyright (C) 2001 The eXist-db Authors
31
 *
32
 * info@exist-db.org
33
 * http://www.exist-db.org
34
 *
35
 * This library is free software; you can redistribute it and/or
36
 * modify it under the terms of the GNU Lesser General Public
37
 * License as published by the Free Software Foundation; either
38
 * version 2.1 of the License, or (at your option) any later version.
39
 *
40
 * This library is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
43
 * Lesser General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU Lesser General Public
46
 * License along with this library; if not, write to the Free Software
47
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
48
 */
49
package org.exist.dom.memtree;
50

51
import org.exist.numbering.NodeId;
52
import org.exist.xquery.Expression;
53
import org.exist.xquery.NodeTest;
54
import org.exist.xquery.XPathException;
55
import org.exist.xquery.value.Sequence;
56
import org.exist.xquery.value.Type;
57
import org.w3c.dom.*;
58

59

60
public class AttrImpl extends NodeImpl implements Attr {
61

62
    public static final int ATTR_CDATA_TYPE = 0;
63
    public static final int ATTR_ID_TYPE = 1;
64
    public static final int ATTR_IDREF_TYPE = 2;
65
    public static final int ATTR_IDREFS_TYPE = 3;
66

67
    public AttrImpl(final DocumentImpl doc, final int nodeNumber) {
68
        this(null, doc, nodeNumber);
×
69
    }
×
70

71
    public AttrImpl(final Expression expression, final DocumentImpl doc, final int nodeNumber) {
72
        super(expression, doc, nodeNumber);
1✔
73
    }
1✔
74

75
    @Override
76
    public NodeId getNodeId() {
77
        return document.attrNodeId[nodeNumber];
×
78
    }
79

80
    @Override
81
    public String getName() {
82
        return getQName().getStringValue();
1✔
83
    }
84

85
    @Override
86
    public short getNodeType() {
87
        return Node.ATTRIBUTE_NODE;
1✔
88
    }
89

90
    @Override
91
    public int getType() {
92
        return Type.ATTRIBUTE;
1✔
93
    }
94

95
    @Override
96
    public String getBaseURI() {
97
        final Node parent = document.getNode(document.attrParent[nodeNumber]);
×
98
        if(parent == null) {
×
99
            return null;
×
100
        }
101
        return parent.getBaseURI();
×
102
    }
103

104
    @Override
105
    public Node getFirstChild() {
106
        return null;
1✔
107
    }
108

109
    @Override
110
    public Node getPreviousSibling() {
111
        return null;
×
112
    }
113

114
    @Override
115
    public Node getNextSibling() {
116
        return null;
×
117
    }
118

119
    @Override
120
    public boolean getSpecified() {
121
        return true;
1✔
122
    }
123

124
    @Override
125
    public String getValue() {
126
        return document.attrValue[nodeNumber];
1✔
127
    }
128

129
    @Override
130
    public void setValue(final String value) throws DOMException {
131
        document.attrValue[nodeNumber] = value;
×
132
    }
×
133

134
    @Override
135
    public String getNodeValue() throws DOMException {
136
        return getValue();
1✔
137
    }
138

139
    @Override
140
    public void setNodeValue(final String nodeValue) throws DOMException {
141
        //This method was added to enable the SQL XQuery Extension Module
142
        //to change the value of an attribute after the fact - Andrzej
143
        setValue(nodeValue);
×
144
    }
×
145

146
    @Override
147
    public String getStringValue() throws DOMException {
148
        return document.attrValue[nodeNumber];
1✔
149
    }
150

151
    @Override
152
    public String getTextContent() throws DOMException {
153
        return getNodeValue();
×
154
    }
155

156
    @Override
157
    public void setTextContent(final String textContent) throws DOMException {
158
        setNodeValue(textContent);
×
159
    }
×
160

161
    @Override
162
    public Element getOwnerElement() {
163
        final Node node = document.getNode(document.attrParent[nodeNumber]);
1✔
164
        if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
1!
165
            return (Element) node;
1✔
166
        }
167
        return null;
1✔
168
    }
169

170
    @Override
171
    public Node getParentNode() {
172
        return null;
1✔
173
    }
174

175
    @Override
176
    public void selectDescendantAttributes(final NodeTest test, final Sequence result) throws XPathException {
177
        if(test.matches(this)) {
×
178
            result.add(this);
×
179
        }
180
    }
×
181

182
    @Override
183
    public Node selectParentNode() {
184
        return getOwnerElement();
1✔
185
    }
186

187
    @Override
188
    public void selectAncestors(boolean includeSelf, NodeTest test, Sequence result) throws XPathException {
189
        if (test.matches(this)) {
1!
190
            result.add(this);
×
191
        }
192
        final ElementImpl ownerElement = (ElementImpl) getOwnerElement();
1✔
193
        if (ownerElement != null) {
1✔
194
            ownerElement.selectAncestors(true, test, result);
1✔
195
        }
196
    }
1✔
197

198
    @Override
199
    public TypeInfo getSchemaTypeInfo() {
200
        return null;
×
201
    }
202

203
    @Override
204
    public boolean isId() {
205
        return (document.attrType[nodeNumber] == ATTR_ID_TYPE);
1!
206
    }
207

208
    @Override
209
    public int getItemType() {
210
        return Type.ATTRIBUTE;
1✔
211
    }
212

213
    @Override
214
    public String toString() {
215
        return "in-memory#attribute {" + getQName().getStringValue() + "} {" + getValue() + "} ";
1✔
216
    }
217

218
    @Override
219
    public void selectAttributes(final NodeTest test, final Sequence result)
220
            throws XPathException {
221
        //do nothing, which will return an empty sequence
222
    }
×
223

224
    @Override
225
    public void selectChildren(final NodeTest test, final Sequence result)
226
            throws XPathException {
227
        //do nothing, which will return an empty sequence
228
    }
×
229

230
    @Override
231
    public boolean equals(final Object obj) {
232
        if(!super.equals(obj)) {
1✔
233
            return false;
1✔
234
        }
235

236
        if(obj instanceof AttrImpl other) {
1!
237
            return other.getQName().equals(getQName())
1!
238
                    && other.document.attrValue[nodeNumber].equals(document.attrValue[nodeNumber]);
1!
239
        }
240

241
        return false;
×
242
    }
243
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc