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
31 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 import org.metricshub.wbem.javax.cim.CIMDataType;
54 import org.metricshub.wbem.javax.cim.CIMQualifier;
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 QualifierNode extends Node {
73 private String iName;
74
75 private CIMDataType iType;
76
77 private boolean iPropagated;
78
79 private int iFlavor;
80
81
82
83 private CIMQualifier<Object> iQuali;
84
85
86
87
88 public QualifierNode() {
89 super(QUALIFIER);
90 }
91
92
93
94
95 @Override
96 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
97 this.iQuali = null;
98 this.iName = getCIMName(pAttribs);
99
100
101
102 this.iType = getCIMType(pAttribs, true);
103
104 this.iPropagated = getPropagated(pAttribs);
105 this.iFlavor = getQualifierFlavor(pAttribs);
106 }
107
108
109
110
111 @Override
112 public void parseData(String pData) {
113
114 }
115
116 @Override
117 public void testChild(String pNodeNameEnum) throws SAXException {
118 if (this.iQuali != null) throw new SAXException(
119 getNodeName() + " node can have only one VALUE or VALUE.ARRAY child node!"
120 );
121 if (pNodeNameEnum != VALUE && pNodeNameEnum != VALUE_ARRAY) throw new SAXException(
122 pNodeNameEnum + " child node is not valid for " + getNodeName() + " node!"
123 );
124 }
125
126 @Override
127 public void childParsed(Node pChild) throws SAXException {
128 AbstractValueNode absValNode = (AbstractValueNode) pChild;
129 Object value;
130 CIMDataType type;
131 if (absValNode instanceof ValueArrayNode) {
132 ValueArrayNode valANode = (ValueArrayNode) absValNode;
133 setType(valANode);
134
135 value = CIMObjectFactory.getObject(this.iType, valANode);
136
137 type = this.iType.isArray() ? this.iType : CIMHelper.UnboundedArrayDataType(this.iType.getType());
138 } else if (absValNode instanceof ValueNode) {
139 ValueNode valNode = (ValueNode) absValNode;
140 setType(valNode);
141 String valueStr = (String) valNode.getValue();
142 type = this.iType;
143 value = CIMObjectFactory.getObject(type, valueStr);
144 } else {
145 type = CIMDataType.STRING_T;
146 value = null;
147 }
148 this.iQuali = new CIMQualifier<Object>(this.iName, type, value, this.iFlavor, this.iPropagated);
149 }
150
151 @Override
152 public void testCompletness() {
153
154
155
156
157
158
159 }
160
161
162
163
164
165
166 public CIMQualifier<Object> getQualifier() {
167 return this.iQuali;
168 }
169
170
171
172
173
174
175
176
177
178 private void setType(TypedIf pTypedIf) throws SAXException {
179 if (this.iType != null) return;
180 this.iType = pTypedIf.getType();
181 if (this.iType == null) throw new SAXException(
182 "Unknown type for Qualifier declaration in " + getNodeName() + " node!"
183 );
184 }
185 }