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.CIMArgument;
49 import org.metricshub.wbem.javax.cim.CIMDataType;
50 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
51 import org.xml.sax.Attributes;
52 import org.xml.sax.SAXException;
53
54
55
56
57
58
59
60
61
62
63
64
65
66 public class IParamValueNode extends AbstractParamValueNode {
67 private String iName;
68
69
70
71
72 private Object iValue;
73
74 private boolean iIsArray;
75
76 private CIMDataType iType;
77
78
79
80
81 public IParamValueNode() {
82 super(IPARAMVALUE);
83 }
84
85
86
87
88 @Override
89 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
90 this.iValue = null;
91 this.iType = null;
92 this.iName = getCIMName(pAttribs);
93 }
94
95
96
97
98 @Override
99 public void parseData(String pData) {
100
101 }
102
103 private static final String[] ALLOWED_CHILDREN = {
104 VALUE,
105 VALUE_ARRAY,
106 VALUE_REFERENCE,
107 INSTANCENAME,
108 CLASSNAME,
109 QUALIFIER_DECLARATION,
110 CLASS,
111 INSTANCE,
112 VALUE_NAMEDINSTANCE
113 };
114
115 @Override
116 public void testChild(String pNodeNameEnum) throws SAXException {
117 boolean allowed = false;
118 for (int i = 0; i < ALLOWED_CHILDREN.length; i++) {
119 if (ALLOWED_CHILDREN[i] == pNodeNameEnum) {
120 allowed = true;
121 break;
122 }
123 }
124 if (!allowed) throw new SAXException(getNodeName() + " node cannot have " + pNodeNameEnum + " child node!");
125
126
127
128
129 if (this.iValue != null) throw new SAXException(getNodeName() + " node cannot have more than one child node!");
130 }
131
132 @Override
133 public void childParsed(Node pChild) {
134 this.iValue = ((ValueIf) pChild).getValue();
135 this.iIsArray = pChild instanceof ArrayIf;
136 if (pChild instanceof TypedIf) this.iType = ((TypedIf) pChild).getType(); else if (
137 pChild instanceof ObjectPathIf
138 ) this.iType = CIMDataType.getDataType(((ObjectPathIf) pChild).getCIMObjectPath()); else if (
139 pChild instanceof ValueIf
140 ) this.iType = CIMDataType.getDataType(((ValueIf) pChild).getValue());
141 }
142
143 @Override
144 public void testCompletness() {
145
146 }
147
148 @Override
149 public CIMArgument<Object> getCIMArgument() {
150 return new CIMArgument<Object>(this.iName, getType(), this.iValue);
151 }
152
153
154
155
156
157
158 public String getName() {
159 return this.iName;
160 }
161
162 public CIMDataType getType() {
163 return this.iType == null ? (this.iIsArray ? CIMDataType.STRING_ARRAY_T : CIMDataType.STRING_T) : this.iType;
164 }
165
166 public Object getValue() {
167 return this.iValue;
168 }
169 }