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.sblim.cimclient.internal.cimxml.sax.SAXSession;
50 import org.metricshub.wbem.sblim.cimclient.internal.util.XMLHostStr;
51 import org.xml.sax.Attributes;
52 import org.xml.sax.SAXException;
53
54
55
56
57 public class ClassPathNode extends AbstractObjectPathNode {
58
59 private boolean iHasNameSpacePath, iHasClassName;
60
61 private String iLocalNameSpacePathStr;
62
63 private XMLHostStr iHostStr;
64
65 private String iClassNameStr;
66
67
68
69
70 public ClassPathNode() {
71 super(CLASSPATH);
72 }
73
74
75
76
77
78 @Override
79 public void init(Attributes pAttribs, SAXSession pSession) {
80
81 this.iHasNameSpacePath = this.iHasClassName = false;
82 this.iLocalNameSpacePathStr = this.iClassNameStr = null;
83 this.iHostStr = new XMLHostStr();
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 == NAMESPACEPATH) {
97 if (this.iHasNameSpacePath) throw new SAXException("CLASSPATH node already has a NAMESPACEPATH child node!");
98 } else if (pNodeNameEnum == CLASSNAME) {
99 if (this.iHasClassName) throw new SAXException("CLASSPATH node already has a CLASSNAME child node!");
100 } else throw new SAXException(
101 "CLASSPATH node cannot have " +
102 pNodeNameEnum +
103 " child node!" +
104 " It can have NAMESPACEPATH and CLASSNAME child nodes only!"
105 );
106 }
107
108 @Override
109 public void childParsed(Node pChild) {
110 if (pChild instanceof NameSpacePathNode) {
111 NameSpacePathNode nsPathNode = (NameSpacePathNode) pChild;
112 this.iLocalNameSpacePathStr = nsPathNode.getLocalNameSpacePath();
113 this.iHostStr.set(nsPathNode.getHostStr());
114 this.iHasNameSpacePath = true;
115 } else {
116 this.iClassNameStr = ((ClassNameNode) pChild).getClassName();
117 this.iHasClassName = true;
118 }
119 }
120
121 @Override
122 public void testCompletness() throws SAXException {
123 if (!this.iHasNameSpacePath) throw new SAXException("NAMESPACEPATH child node is mandatory for CLASSPATH node!");
124 if (!this.iHasClassName) throw new SAXException("CLASSNAME child node is mandatory for CLASSPATH node!");
125 }
126
127 public CIMObjectPath getCIMObjectPath() {
128
129
130
131
132 return new CIMObjectPath(
133 this.iHostStr.getProtocol(),
134 this.iHostStr.getHost(),
135 this.iHostStr.getPort(),
136 this.iLocalNameSpacePathStr,
137 this.iClassNameStr,
138 null
139 );
140 }
141 }