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.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 LocalClassPathNode extends AbstractObjectPathNode {
59
60 private boolean iHasLocalNameSpacePath, iHasClassName;
61
62 private String iNameSpaceStr;
63
64
65 private String iClassNameStr;
66
67
68 private CIMObjectPath iLocalPath;
69
70
71
72
73 public LocalClassPathNode() {
74 super(LOCALCLASSPATH);
75 }
76
77
78
79
80 @Override
81 public void init(Attributes pAttribs, SAXSession pSession) {
82 this.iLocalPath = pSession.getDefLocalPath();
83 this.iHasLocalNameSpacePath = this.iHasClassName = false;
84 this.iNameSpaceStr = this.iClassNameStr = null;
85
86 }
87
88
89
90
91 @Override
92 public void parseData(String pData) {
93
94 }
95
96 @Override
97 public void testChild(String pNodeNameEnum) throws SAXException {
98 if (pNodeNameEnum == LOCALNAMESPACEPATH) {
99 if (this.iHasLocalNameSpacePath) throw new SAXException(
100 "LOCALCLASSPATH node already has a LOCALNAMESPACEPATH child node!"
101 );
102 } else if (pNodeNameEnum == CLASSNAME) {
103 if (this.iHasClassName) throw new SAXException("LOCALCLASSPATH node already has a CLASSNAME child node!");
104 } else throw new SAXException(
105 "LOCALCLASSPATH node cannot have " +
106 pNodeNameEnum +
107 " child node!" +
108 " It can have LOCALNAMESPACEPATH and CLASSNAME child nodes only!"
109 );
110 }
111
112 @Override
113 public void childParsed(Node pChild) {
114 if (pChild instanceof LocalNameSpacePathNode) {
115 this.iNameSpaceStr = ((LocalNameSpacePathNode) pChild).getNameSpace();
116 this.iHasLocalNameSpacePath = true;
117 } else {
118 this.iClassNameStr = ((ClassNameNode) pChild).getClassName();
119 this.iHasClassName = true;
120 }
121 }
122
123 @Override
124 public void testCompletness() throws SAXException {
125 if (!this.iHasLocalNameSpacePath) throw new SAXException(
126 "LOCALNAMESPACE child node is mandatory for LOCALCLASSPATH node!"
127 );
128 if (!this.iHasClassName) throw new SAXException("CLASSNAME child node is mandatory for LOCALCLASSPATH node!");
129 }
130
131 public CIMObjectPath getCIMObjectPath() {
132 return LocalPathBuilder.build(this.iLocalPath, this.iClassNameStr, this.iNameSpaceStr);
133 }
134 }