• 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

23.08
/exist-core/src/main/java/org/exist/dom/memtree/reference/AbstractReferenceNodeImpl.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
package org.exist.dom.memtree.reference;
25

26
import org.exist.dom.QName;
27
import org.exist.dom.memtree.DocumentImpl;
28
import org.exist.dom.memtree.NodeImpl;
29
import org.exist.dom.persistent.AttrImpl;
30
import org.exist.dom.persistent.NodeProxy;
31
import org.exist.xquery.Expression;
32
import org.exist.xquery.NodeTest;
33
import org.exist.xquery.XPathException;
34
import org.exist.xquery.value.Sequence;
35
import org.w3c.dom.DOMException;
36
import org.w3c.dom.NamedNodeMap;
37
import org.w3c.dom.Node;
38
import org.w3c.dom.NodeList;
39

40
import javax.annotation.Nullable;
41

42
/**
43
 * DOM Wrapper around a NodeProxy for use in the in-memory DOM.
44
 *
45
 * @author <a href="mailto:adam@evolvedbinary.com">Adam Retter</a>
46
 */
47
public abstract class AbstractReferenceNodeImpl<T extends AbstractReferenceNodeImpl<T, P>, P extends org.exist.dom.persistent.NodeImpl<P>> extends NodeImpl<T> {
48

49
    protected final NodeProxy nodeProxy;
50

51
    public AbstractReferenceNodeImpl(@Nullable final Expression expression, final DocumentImpl doc, final int nodeNumber, final NodeProxy nodeProxy) {
52
        super(expression, doc, nodeNumber);
1✔
53
        this.nodeProxy = nodeProxy;
1✔
54
    }
1✔
55

56
    /**
57
     * Get the node proxy.
58
     *
59
     * @return the node proxy.
60
     */
61
    public NodeProxy getNodeProxy() {
62
        return nodeProxy;
1✔
63
    }
64

65
    @SuppressWarnings("unchchecked")
66
    protected P getProxiedNode() {
67
        return (P) nodeProxy.getNode();
1✔
68
    }
69

70
    @Override
71
    public String toString() {
72
        return "reference[ " + getProxiedNode().toString() + " ]";
×
73
    }
74

75
    @Override
76
    public String getNamespaceURI() {
77
        return getProxiedNode().getNamespaceURI();
1✔
78
    }
79

80
    @Override
81
    public String getLocalName() {
82
        return getProxiedNode().getLocalName();
×
83
    }
84

85
    @Override
86
    public NamedNodeMap getAttributes() {
87
        return getProxiedNode().getAttributes();
1✔
88
    }
89

90
    @Override
91
    public NodeList getChildNodes() {
92
        return getProxiedNode().getChildNodes();
1✔
93
    }
94

95
    @Override
96
    public Node getFirstChild() {
97
        return getProxiedNode().getFirstChild();
×
98
    }
99

100
    @Override
101
    public Node getLastChild() {
102
        return getProxiedNode().getLastChild();
×
103
    }
104

105
    @Override
106
    public boolean hasAttributes() {
107
        return getProxiedNode().hasAttributes();
×
108
    }
109

110
    @Override
111
    public void selectAttributes(final NodeTest test, final Sequence result) throws XPathException {
112
        selectAttributes(getProxiedNode(), test, result);
×
113
    }
×
114

115
    @Override
116
    public boolean hasChildNodes() {
117
        return getProxiedNode().hasChildNodes();
1✔
118
    }
119

120
    private void selectAttributes(final Node node, final NodeTest test, final Sequence result) throws XPathException {
121
        @Nullable final NamedNodeMap attrs = node.getAttributes();
×
122
        if (attrs != null) {
×
123
            for (int i = 0; i < attrs.getLength(); i++) {
×
124
                final Node attr = attrs.item(i);
×
125
                if (test.matches(attr)) {
×
126
                    result.add(new NodeProxy((org.exist.dom.persistent.AttrImpl) attr));
×
127
                }
128
            }
129
        }
130
    }
×
131

132
    @Override
133
    public void selectChildren(final NodeTest test, final Sequence result) throws XPathException {
134
        @Nullable final NodeList children = getProxiedNode().getChildNodes();
×
135
        for (int i = 0; i < children.getLength(); i++) {
×
136
            final Node child = children.item(i);
×
137
            if (test.matches(child)) {
×
138
                result.add(new NodeProxy((org.exist.dom.persistent.NodeHandle) child));
×
139
            }
140
        }
141
    }
×
142

143
    @Override
144
    public void selectDescendantAttributes(final NodeTest test, final Sequence result) throws XPathException {
145
        selectDescendantAttributes(getProxiedNode(), test, result);
×
146
    }
×
147

148
    private void selectDescendantAttributes(final Node node, final NodeTest test, final Sequence result) throws XPathException {
149
        final NodeList children = node.getChildNodes();
×
150
        for (int i = 0; i < children.getLength(); i++) {
×
151
            final Node child = children.item(i);
×
152
            selectAttributes(child, test, result);
×
153
            selectDescendantAttributes(child, test, result);
×
154
        }
155
    }
×
156

157
    @Override
158
    public String getNodeValue() throws DOMException {
159
        return getProxiedNode().getNodeValue();
1✔
160
    }
161

162
    @Override
163
    public short getNodeType() {
164
        return getProxiedNode().getNodeType();
1✔
165
    }
166

167
    @Override
168
    public QName getQName() {
169
        return getProxiedNode().getQName();
1✔
170
    }
171
}
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