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
28
29
30 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 import org.metricshub.wbem.javax.cim.CIMDataType;
53 import org.metricshub.wbem.javax.cim.CIMObjectPath;
54 import org.metricshub.wbem.javax.cim.CIMQualifierType;
55 import org.metricshub.wbem.sblim.cimclient.internal.cim.CIMHelper;
56 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.CIMObjectFactory;
57 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
58 import org.xml.sax.Attributes;
59 import org.xml.sax.SAXException;
60
61
62
63
64
65
66
67
68
69
70
71
72 public class QualiDeclNode extends Node implements TypedIf, ValueIf {
73
74
75 private boolean iHasScope;
76
77 private int iScope;
78
79
80 private String iValueNodeName;
81
82 private Object iValue;
83
84
85 private String iName;
86
87 private CIMDataType iType;
88
89 private int iFlavor;
90
91
92
93
94 public QualiDeclNode() {
95 super(QUALIFIER_DECLARATION);
96 }
97
98
99
100
101
102
103 public String getName() {
104 return this.iName;
105 }
106
107 public CIMDataType getType() {
108 return this.iType;
109 }
110
111
112
113
114
115
116 public int getFlavor() {
117 return this.iFlavor;
118 }
119
120
121
122
123 @Override
124 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
125 this.iHasScope = false;
126 this.iScope = 0;
127 this.iValueNodeName = null;
128 this.iValue = null;
129 this.iName = getCIMName(pAttribs);
130 this.iType = getCIMType(pAttribs, true);
131 this.iFlavor = getQualifierFlavor(pAttribs);
132 }
133
134
135
136
137 @Override
138 public void parseData(String pData) {
139
140 }
141
142 @Override
143 public void testChild(String pNodeNameEnum) throws SAXException {
144 if (pNodeNameEnum == VALUE || pNodeNameEnum == VALUE_ARRAY) {
145 if (this.iValueNodeName != null) throw new SAXException(
146 "Cannot add " +
147 pNodeNameEnum +
148 " node, this " +
149 getNodeName() +
150 " node has already got a " +
151 this.iValueNodeName +
152 " node!"
153 );
154 } else if (pNodeNameEnum == SCOPE) {
155 if (this.iHasScope) throw new SAXException(
156 "Cannot add " + pNodeNameEnum + " node, this " + getNodeName() + " node has already got one!"
157 );
158 } else throw new SAXException(getNodeName() + " node cannot have " + pNodeNameEnum + " child node!");
159 }
160
161
162
163
164
165
166
167
168
169 private void setType(TypedIf pTypedIf) throws SAXException {
170 if (this.iType != null) return;
171 this.iType = pTypedIf.getType();
172 if (this.iType == null) throw new SAXException(
173 "Unknown type for Qualifier declaration in " + getNodeName() + " node!"
174 );
175 }
176
177 @Override
178 public void childParsed(Node pChild) throws SAXException {
179 if (pChild instanceof ScopeNode) {
180 this.iHasScope = true;
181 this.iScope = ((ScopeNode) pChild).getScope();
182 } else {
183 this.iValueNodeName = pChild.getNodeName();
184 if (pChild instanceof ValueArrayNode) {
185 ValueArrayNode valAChild = (ValueArrayNode) pChild;
186 setType(valAChild);
187 this.iValue = CIMObjectFactory.getObject(this.iType, valAChild);
188
189 if (!this.iType.isArray()) this.iType = CIMHelper.UnboundedArrayDataType(this.iType.getType());
190 } else if (pChild instanceof ValueNode) {
191 ValueNode valChild = (ValueNode) pChild;
192 setType(valChild);
193 this.iValue = CIMObjectFactory.getObject(this.iType, valChild);
194 } else {
195 this.iValue = null;
196 }
197 }
198 }
199
200 @Override
201 public void testCompletness() throws SAXException {
202 if (this.iType == null) throw new SAXException(
203 "Unknown type for Qualifier declaration in " + getNodeName() + " node!"
204 );
205 }
206
207
208
209
210
211
212 public CIMQualifierType<Object> getCIMQualifierType() {
213
214
215
216
217 return new CIMQualifierType<Object>(
218 new CIMObjectPath(null, null, null, null, this.iName, null),
219 this.iType,
220 this.iValue,
221 this.iScope,
222 this.iFlavor
223 );
224 }
225
226 public Object getValue() {
227 return getCIMQualifierType();
228 }
229 }