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 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 import java.util.ArrayList;
51 import org.metricshub.wbem.javax.cim.CIMArgument;
52 import org.metricshub.wbem.javax.cim.CIMObjectPath;
53 import org.metricshub.wbem.sblim.cimclient.internal.cim.CIMElementSorter;
54 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
55 import org.xml.sax.Attributes;
56 import org.xml.sax.SAXException;
57
58
59
60
61
62
63
64
65
66
67
68
69 public abstract class AbstractMethodCallNode extends Node implements NonVolatileIf, ObjectPathIf {
70 private String iName;
71
72 protected CIMObjectPath iPath;
73
74
75
76
77 private ArrayList<CIMArgument<?>> iArgAL;
78
79
80
81
82 private CIMArgument<?>[] iArgA;
83
84
85
86
87
88
89 public AbstractMethodCallNode(String pNameEnum) {
90 super(pNameEnum);
91 }
92
93
94
95
96 @Override
97 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
98 this.iName = getCIMName(pAttribs);
99 this.iPath = null;
100 this.iArgAL = null;
101 this.iArgA = null;
102 }
103
104
105
106
107 public void addChild(Node pChild) {
108
109 }
110
111 @Override
112 public void childParsed(Node pChild) {
113 if (pChild instanceof AbstractPathNode) {
114 this.iPath = ((AbstractPathNode) pChild).getCIMObjectPath();
115 } else if (pChild instanceof AbstractParamValueNode) {
116 if (this.iArgAL == null) this.iArgAL = new ArrayList<CIMArgument<?>>();
117 this.iArgAL.add(((AbstractParamValueNode) pChild).getCIMArgument());
118 }
119 }
120
121
122
123
124 @Override
125 public void parseData(String pData) {
126
127 }
128
129 protected abstract void testSpecChild(String pNodeNameEnum) throws SAXException;
130
131 @Override
132 public void testChild(String pNodeNameEnum) throws SAXException {
133 testSpecChild(pNodeNameEnum);
134 }
135
136
137
138
139
140
141 public String getName() {
142 return this.iName;
143 }
144
145 public CIMObjectPath getCIMObjectPath() {
146 return this.iPath;
147 }
148
149 private static final CIMArgument<?>[] EMPTY_ARG_A = new CIMArgument[0];
150
151
152
153
154
155
156 public CIMArgument<?>[] getCIMArguments() {
157 if (this.iArgA != null) return this.iArgA;
158 this.iArgA = this.iArgAL == null ? null : (CIMArgument[]) this.iArgAL.toArray(EMPTY_ARG_A);
159 return (CIMArgument[]) CIMElementSorter.sort(this.iArgA);
160 }
161
162
163
164
165
166
167 public int getArgumentCount() {
168 getCIMArguments();
169 return this.iArgA == null ? 0 : this.iArgA.length;
170 }
171
172
173
174
175
176
177
178 public CIMArgument<?> getArgument(String pName) {
179 getCIMArguments();
180 return (CIMArgument<?>) CIMElementSorter.find(this.iArgA, pName);
181 }
182
183
184
185
186
187
188
189 public CIMArgument<?> getArgument(int pIdx) {
190 getCIMArguments();
191 return this.iArgA == null ? null : this.iArgA[pIdx];
192 }
193
194 @Override
195 public String toString() {
196 StringBuffer buf = new StringBuffer("Name: " + getName() + "\nPath: " + getCIMObjectPath() + "\nParamValues:\n");
197 for (int i = 0; i < getArgumentCount(); i++) {
198 buf.append(" " + getArgument(i) + "\n");
199 }
200 return buf.toString();
201 }
202 }