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 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 import org.metricshub.wbem.javax.cim.CIMObjectPath;
49 import org.metricshub.wbem.javax.cim.CIMProperty;
50 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.LocalPathBuilder;
51 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
52 import org.xml.sax.Attributes;
53 import org.xml.sax.SAXException;
54
55
56
57
58 public class LocalInstancePathNode extends AbstractObjectPathNode {
59
60 private boolean iHasLocalNameSpacePath;
61
62 private String iNameSpaceStr;
63
64
65 private boolean iHasInstanceName;
66
67 private String iClassNameStr;
68
69 private CIMProperty<?>[] iKeys;
70
71
72 private CIMObjectPath iLocalPath;
73
74
75
76
77 public LocalInstancePathNode() {
78 super(LOCALINSTANCEPATH);
79 }
80
81
82
83
84 @Override
85 public void init(Attributes pAttribs, SAXSession pSession) {
86 this.iLocalPath = pSession.getDefLocalPath();
87 this.iHasLocalNameSpacePath = this.iHasInstanceName = false;
88 this.iNameSpaceStr = this.iClassNameStr = null;
89 this.iKeys = null;
90
91 }
92
93
94
95
96 @Override
97 public void parseData(String pData) {
98
99 }
100
101 @Override
102 public void testChild(String pNodeNameEnum) throws SAXException {
103 if (pNodeNameEnum == LOCALNAMESPACEPATH) {
104 if (this.iHasLocalNameSpacePath) throw new SAXException(
105 getNodeName() + " node can have only one LOCALNAMESPACEPATH child node!"
106 );
107 } else if (pNodeNameEnum == INSTANCENAME) {
108 if (this.iHasInstanceName) throw new SAXException(
109 getNodeName() + " node can have only one INSTANCENAME child node!"
110 );
111 } else throw new SAXException(getNodeName() + " node cannot have " + pNodeNameEnum + " child node!");
112 }
113
114 @Override
115 public void childParsed(Node pChild) {
116 if (pChild instanceof LocalNameSpacePathNode) {
117 this.iHasLocalNameSpacePath = true;
118 this.iNameSpaceStr = ((LocalNameSpacePathNode) pChild).getNameSpace();
119 } else {
120 this.iHasInstanceName = true;
121 InstanceNameNode instNameNode = (InstanceNameNode) pChild;
122 this.iClassNameStr = instNameNode.getClassName();
123 this.iKeys = instNameNode.getKeys();
124 }
125 }
126
127 @Override
128 public void testCompletness() throws SAXException {
129 if (!this.iHasLocalNameSpacePath) throw new SAXException(
130 getNodeName() + " node must have a LOCALNAMESPACEPATH child node!"
131 );
132 if (!this.iHasInstanceName) throw new SAXException(getNodeName() + " node must have a INSTANCENAME child node!");
133 }
134
135 public CIMObjectPath getCIMObjectPath() {
136
137
138 return LocalPathBuilder.build(this.iLocalPath, this.iClassNameStr, this.iNameSpaceStr, this.iKeys);
139 }
140 }