1 /*
2 (C) Copyright IBM Corp. 2006, 2013
3
4 THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
5 ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
6 CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
7
8 You can obtain a current copy of the Eclipse Public License from
9 http://www.opensource.org/licenses/eclipse-1.0.php
10
11 @author : Endre Bak, ebak@de.ibm.com
12 *
13 * Flag Date Prog Description
14 * -------------------------------------------------------------------------------
15 * 1565892 2006-12-04 ebak Make SBLIM client JSR48 compliant
16 * 1663270 2007-02-19 ebak Minor performance problems
17 * 1660756 2007-02-22 ebak Embedded object support
18 * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL
19 * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1)
20 * 2531371 2009-02-10 raman_arora Upgrade client to JDK 1.5 (Phase 2)
21 * 2797550 2009-06-01 raman_arora JSR48 compliance - add Java Generics
22 * 2845211 2009-08-27 raman_arora Pull Enumeration Feature (SAX Parser)
23 * 3511454 2012-03-27 blaschke-oss SAX nodes not reinitialized properly
24 * 2672 2013-09-26 blaschke-oss Remove SIMPLEREQACK support
25 */
26
27 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
28
29 /*-
30 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
31 * WBEM Java Client
32 * ჻჻჻჻჻჻
33 * Copyright 2023 - 2025 MetricsHub
34 * ჻჻჻჻჻჻
35 * Licensed under the Apache License, Version 2.0 (the "License");
36 * you may not use this file except in compliance with the License.
37 * You may obtain a copy of the License at
38 *
39 * http://www.apache.org/licenses/LICENSE-2.0
40 *
41 * Unless required by applicable law or agreed to in writing, software
42 * distributed under the License is distributed on an "AS IS" BASIS,
43 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44 * See the License for the specific language governing permissions and
45 * limitations under the License.
46 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
47 */
48
49 import org.metricshub.wbem.javax.cim.CIMArgument;
50 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
51 import org.metricshub.wbem.sblim.cimclient.internal.wbem.CIMError;
52 import org.xml.sax.Attributes;
53 import org.xml.sax.SAXException;
54
55 /**
56 * <pre>
57 * ELEMENT SIMPLERSP (METHODRESPONSE | IMETHODRESPONSE)
58 *
59 * ELEMENT METHODRESPONSE (ERROR|(RETURNVALUE?,PARAMVALUE*))
60 * ELEMENT IMETHODRESPONSE (ERROR|IRETURNVALUE?) *
61 * </pre>
62 */
63 public class SimpleRspNode extends AbstractSimpleRspNode {
64 private Node iChildNode;
65
66 /**
67 * Ctor.
68 */
69 public SimpleRspNode() {
70 super(SIMPLERSP);
71 }
72
73 public void addChild(Node pChild) {
74 this.iChildNode = pChild;
75 }
76
77 /**
78 * @param pAttribs
79 * @param pSession
80 */
81 @Override
82 public void init(Attributes pAttribs, SAXSession pSession) {
83 this.iChildNode = null;
84 // no attributes
85 }
86
87 /**
88 * @param pData
89 */
90 @Override
91 public void parseData(String pData) {
92 // no data
93 }
94
95 @Override
96 public void testChild(String pNodeNameEnum) throws SAXException {
97 if (this.iChildNode != null) throw new SAXException(getNodeName() + " node can have only one child node!");
98 if (pNodeNameEnum != METHODRESPONSE && pNodeNameEnum != IMETHODRESPONSE) throw new SAXException(
99 getNodeName() + " node cannot have " + pNodeNameEnum + " child node!"
100 );
101 }
102
103 @Override
104 public void testCompletness() throws SAXException {
105 if (this.iChildNode == null) throw new SAXException(getNodeName() + " node must have a child node!");
106 }
107
108 @Override
109 public CIMError getCIMError() {
110 if (this.iChildNode instanceof ErrorIf) {
111 return ((ErrorIf) this.iChildNode).getCIMError();
112 }
113 return null;
114 }
115
116 /**
117 * getCIMArguments : returns the array of parsed parameters and their values
118 * : String name, CIMDataType type, Object value
119 *
120 * @return CIMArgument<?>[]
121 */
122 @Override
123 public CIMArgument<?>[] getCIMArguments() {
124 if (this.iChildNode instanceof MethodResponseNode) return (
125 (MethodResponseNode) this.iChildNode
126 ).getCIMArguments(); else if (this.iChildNode instanceof IMethodResponseNode) return (
127 (IMethodResponseNode) this.iChildNode
128 ).getCIMArguments();
129 return null;
130 }
131
132 public int getReturnValueCount() {
133 if (this.iChildNode instanceof RetValPipeIf) {
134 return ((RetValPipeIf) this.iChildNode).getReturnValueCount();
135 }
136 return 0;
137 }
138
139 public Object readReturnValue() {
140 return ((RetValPipeIf) this.iChildNode).readReturnValue();
141 }
142 }