1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 import org.metricshub.wbem.javax.cim.CIMObjectPath;
50 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
51 import org.metricshub.wbem.sblim.cimclient.internal.util.WBEMConfiguration;
52 import org.xml.sax.Attributes;
53 import org.xml.sax.SAXException;
54
55
56
57
58 public class LocalNameSpacePathNode extends AbstractPathNode {
59 private StringBuffer iNameSpaceStrBuf;
60
61 private String iNameSpaceStr;
62
63 private CIMObjectPath iNameSpacePath;
64
65 private CIMObjectPath iLocalPath;
66
67
68
69
70 public LocalNameSpacePathNode() {
71 super(LOCALNAMESPACEPATH);
72 }
73
74
75
76
77 @Override
78 public void init(Attributes pAttribs, SAXSession pSession) {
79 this.iLocalPath = pSession.getDefLocalPath();
80 this.iNameSpaceStrBuf = null;
81 this.iNameSpaceStr = null;
82 this.iNameSpacePath = null;
83
84 }
85
86
87
88
89 @Override
90 public void parseData(String pData) {
91
92 }
93
94 @Override
95 public void testChild(String pNodeNameEnum) throws SAXException {
96 if (pNodeNameEnum != NAMESPACE) throw new SAXException(
97 getNodeName() + " node can have NAMESPACE child node only! " + pNodeNameEnum + " child node is invalid!"
98 );
99 }
100
101 @Override
102 public void childParsed(Node pChild) {
103 String nsStr = ((NameSpaceNode) pChild).getNameSpace();
104 if (this.iNameSpaceStrBuf == null) {
105 this.iNameSpaceStrBuf = new StringBuffer(nsStr);
106 } else {
107 this.iNameSpaceStrBuf.append('/' + nsStr);
108 }
109 }
110
111 @Override
112 public void testCompletness() throws SAXException {
113 if (this.iNameSpaceStrBuf == null) {
114 if (
115 WBEMConfiguration.getGlobalConfiguration().allowEmptyLocalNameSpacePath() &&
116 this.iLocalPath != null &&
117 this.iLocalPath.getNamespace() != null
118 ) return;
119 throw new SAXException(getNodeName() + " node must have at least one NAMESPACE child node!");
120 }
121 }
122
123
124
125
126
127
128 public String getNameSpace() {
129 if (this.iNameSpaceStr != null) return this.iNameSpaceStr;
130 return (
131 this.iNameSpaceStr =
132 (this.iNameSpaceStrBuf == null ? this.iLocalPath.getNamespace() : this.iNameSpaceStrBuf.toString())
133 );
134 }
135
136 public CIMObjectPath getCIMObjectPath() {
137 if (this.iNameSpacePath != null) return this.iNameSpacePath;
138 return this.iNameSpacePath = new CIMObjectPath(null, null, null, getNameSpace(), null, null);
139 }
140 }