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 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 import java.util.ArrayList;
52 import org.metricshub.wbem.javax.cim.CIMDataType;
53 import org.metricshub.wbem.javax.cim.CIMMethod;
54 import org.metricshub.wbem.javax.cim.CIMParameter;
55 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.EmbObjHandler;
56 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
57 import org.xml.sax.Attributes;
58 import org.xml.sax.SAXException;
59
60
61
62
63
64
65
66
67
68
69
70
71 public class MethodNode extends Node {
72 private String iName;
73
74 private CIMDataType iType;
75
76 private String iClassOrigin;
77
78 private boolean iPropagated;
79
80 private QualifiedNodeHandler iQualiHandler;
81
82 private EmbObjHandler iEmbObjHandler;
83
84 private SAXSession iSession;
85
86
87
88
89 private ArrayList<CIMParameter<?>> iCIMParamAL;
90
91
92
93
94 public MethodNode() {
95 super(METHOD);
96 }
97
98 @Override
99 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
100 this.iSession = pSession;
101 this.iQualiHandler = QualifiedNodeHandler.init(this.iQualiHandler);
102 this.iEmbObjHandler =
103 EmbObjHandler.init(this.iEmbObjHandler, getNodeName(), pAttribs, this.iSession, this.iQualiHandler, true);
104
105 if (this.iCIMParamAL != null) this.iCIMParamAL.clear();
106
107 this.iName = getCIMName(pAttribs);
108
109 this.iType = getCIMType(pAttribs, true);
110 if (this.iType != null && this.iType.isArray()) throw new SAXException("METHOD node's TYPE cannot be an array!");
111 this.iClassOrigin = getClassOrigin(pAttribs);
112 this.iPropagated = getPropagated(pAttribs);
113 }
114
115
116
117
118 @Override
119 public void parseData(String pData) {
120
121 }
122
123 private static final String[] ALLOWED_CHILDREN = {
124 QUALIFIER,
125 PARAMETER,
126 PARAMETER_REFERENCE,
127 PARAMETER_ARRAY,
128 PARAMETER_REFARRAY
129 };
130
131 @Override
132 public void testChild(String pNodeNameEnum) throws SAXException {
133 for (int i = 0; i < ALLOWED_CHILDREN.length; i++) if (pNodeNameEnum.equalsIgnoreCase(ALLOWED_CHILDREN[i])) return;
134 throw new SAXException(getNodeName() + " node cannot have " + pNodeNameEnum + " child node!");
135 }
136
137 @Override
138 public void childParsed(Node pChild) {
139 if (this.iQualiHandler.addQualifierNode(pChild)) return;
140 if (this.iCIMParamAL == null) this.iCIMParamAL = new ArrayList<CIMParameter<?>>();
141 this.iCIMParamAL.add(((AbstractParameterNode) pChild).getCIMParameter());
142 }
143
144 @Override
145 public void testCompletness() throws SAXException {
146 this.iType = this.iEmbObjHandler.getType();
147 if (this.iType != null && this.iType.isArray()) throw new SAXException(
148 "METHOD node's TYPE attribute cannot be an array!"
149 );
150 }
151
152
153
154
155
156
157 public CIMMethod<?> getCIMMethod() {
158
159
160
161
162
163
164
165
166
167
168 return new CIMMethod<Object>(
169 this.iName,
170 this.iType,
171 this.iQualiHandler.getQualis(!this.iSession.strictEmbObjParsing()),
172 this.iCIMParamAL == null ? null : (CIMParameter<?>[]) this.iCIMParamAL.toArray(EMPTY_PA),
173 this.iPropagated,
174 this.iClassOrigin
175 );
176 }
177
178 private static final CIMParameter<?>[] EMPTY_PA = new CIMParameter[0];
179 }