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.sax.SAXSession;
51 import org.metricshub.wbem.sblim.cimclient.internal.util.XMLHostStr;
52 import org.xml.sax.Attributes;
53 import org.xml.sax.SAXException;
54
55
56
57
58 public class InstancePathNode extends AbstractObjectPathNode {
59
60 private boolean iHasInstancePath;
61
62 private String iLocalNameSpacePathStr;
63
64 private XMLHostStr iHostStr;
65
66
67 private boolean iHasInstanceName;
68
69 private String iClassNameStr;
70
71 private CIMProperty<?>[] iKeys;
72
73
74
75
76 public InstancePathNode() {
77 super(INSTANCEPATH);
78 }
79
80
81
82
83
84 @Override
85 public void init(Attributes pAttribs, SAXSession pSession) {
86 this.iHasInstanceName = this.iHasInstancePath = false;
87 this.iLocalNameSpacePathStr = this.iClassNameStr = null;
88 this.iHostStr = new XMLHostStr();
89 this.iKeys = null;
90 }
91
92 @Override
93 public void testChild(String pNodeNameEnum) throws SAXException {
94 if (pNodeNameEnum == NAMESPACEPATH) {
95 if (this.iHasInstancePath) throw new SAXException(
96 "INSTANCEPATH node can have only one NAMESPACEPATH child node!"
97 );
98 } else if (pNodeNameEnum == INSTANCENAME) {
99 if (this.iHasInstanceName) throw new SAXException("INSTANCEPATH node can have only one INSTANCENAME child node!");
100 } else throw new SAXException("INSTANCEPATH node cannot have " + pNodeNameEnum + " child node!");
101 }
102
103
104
105
106 @Override
107 public void parseData(String pData) {
108
109 }
110
111 @Override
112 public void childParsed(Node pChild) {
113 if (pChild instanceof NameSpacePathNode) {
114 NameSpacePathNode nsPathNode = (NameSpacePathNode) pChild;
115 this.iHostStr.set(nsPathNode.getHostStr());
116 this.iLocalNameSpacePathStr = nsPathNode.getLocalNameSpacePath();
117 this.iHasInstancePath = true;
118 } else {
119 InstanceNameNode instNameNode = (InstanceNameNode) pChild;
120 this.iClassNameStr = instNameNode.getClassName();
121 this.iKeys = instNameNode.getKeys();
122 this.iHasInstanceName = true;
123 }
124 }
125
126 @Override
127 public void testCompletness() throws SAXException {
128 if (!this.iHasInstancePath) throw new SAXException("INSTANCEPATH node must have a NAMESPACEPATH child node!");
129 if (!this.iHasInstanceName) throw new SAXException("INSTANCEPATH node must have an INSTANCENAME child node!");
130 }
131
132 public CIMObjectPath getCIMObjectPath() {
133
134
135
136
137 return new CIMObjectPath(
138 this.iHostStr.getProtocol(),
139 this.iHostStr.getHost(),
140 this.iHostStr.getPort(),
141 this.iLocalNameSpacePathStr,
142 this.iClassNameStr,
143 this.iKeys
144 );
145 }
146 }