MCPcopy Create free account
hub / github.com/apache/solr / DOMConfigNode

Class DOMConfigNode

solr/core/src/java/org/apache/solr/util/DOMConfigNode.java:30–85  ·  view source on GitHub ↗

Read using DOM

Source from the content-addressed store, hash-verified

28
29/** Read using DOM */
30public class DOMConfigNode implements ConfigNode {
31
32 private final Node node;
33 private Map<String, String> attrs; // lazy populated
34
35 public DOMConfigNode(Node node) {
36 this.node = node;
37 }
38
39 @Override
40 public String name() {
41 return node.getNodeName();
42 }
43
44 @Override
45 public String txt() {
46 return DOMUtil.getText(node);
47 }
48
49 @Override
50 public Map<String, String> attributes() {
51 if (attrs != null) return attrs;
52 Map<String, String> attrs = DOMUtil.toMap(node.getAttributes());
53 return this.attrs = attrs.isEmpty() ? Map.of() : attrs;
54 }
55
56 @Override
57 public ConfigNode child(String name) {
58 Node n = DOMUtil.getChild(node, name);
59 return n == null ? null : new DOMConfigNode(n);
60 }
61
62 @Override
63 public List<ConfigNode> getAll(String name) {
64 List<ConfigNode> result = new ArrayList<>();
65 forEachChild(
66 it -> {
67 if (name.equals(it.name())) {
68 result.add(it);
69 }
70 return Boolean.TRUE;
71 });
72 return result;
73 }
74
75 @Override
76 public void forEachChild(Function<ConfigNode, Boolean> fun) {
77 NodeList nlst = node.getChildNodes();
78 for (int i = 0; i < nlst.getLength(); i++) {
79 Node item = nlst.item(i);
80 if (item.getNodeType() != Node.ELEMENT_NODE) continue;
81 Boolean toContinue = fun.apply(new DOMConfigNode(item));
82 if (Boolean.FALSE.equals(toContinue)) break;
83 }
84 }
85}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…