View Javadoc
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   * 1720707    2007-05-17  ebak         Conventional Node factory for CIM-XML SAX parser
19   * 2003590    2008-06-30  blaschke-oss Change licensing from CPL to EPL
20   * 2524131    2009-01-21  raman_arora  Upgrade client to JDK 1.5 (Phase 1)
21   * 2797550    2009-06-01  raman_arora  JSR48 compliance - add Java Generics
22   * 3511454    2012-03-27  blaschke-oss SAX nodes not reinitialized properly
23   * 3602604    2013-01-29  blaschke-oss Clean up SAXException messages
24   */
25  
26  package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
27  
28  /*-
29   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
30   * WBEM Java Client
31   * ჻჻჻჻჻჻
32   * Copyright 2023 - 2025 MetricsHub
33   * ჻჻჻჻჻჻
34   * Licensed under the Apache License, Version 2.0 (the "License");
35   * you may not use this file except in compliance with the License.
36   * You may obtain a copy of the License at
37   *
38   *      http://www.apache.org/licenses/LICENSE-2.0
39   *
40   * Unless required by applicable law or agreed to in writing, software
41   * distributed under the License is distributed on an "AS IS" BASIS,
42   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43   * See the License for the specific language governing permissions and
44   * limitations under the License.
45   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
46   */
47  
48  import org.metricshub.wbem.javax.cim.CIMArgument;
49  import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
50  import org.metricshub.wbem.sblim.cimclient.internal.wbem.CIMError;
51  import org.xml.sax.Attributes;
52  import org.xml.sax.SAXException;
53  
54  /**
55   * <pre>
56   * ELEMENT SIMPLEEXPRSP (EXPMETHODRESPONSE)
57   * ELEMENT EXPMETHODRESPONSE (ERROR|IRETURNVALUE?)
58   * </pre>
59   */
60  public class SimpleExpRspNode extends AbstractSimpleRspNode {
61  	private ExpMethodResponseNode iExpMethodRspNode;
62  
63  	/**
64  	 * Ctor.
65  	 */
66  	public SimpleExpRspNode() {
67  		super(SIMPLEEXPRSP);
68  	}
69  
70  	public void addChild(Node pChild) {
71  		this.iExpMethodRspNode = (ExpMethodResponseNode) pChild;
72  	}
73  
74  	/**
75  	 * @param pAttribs
76  	 * @param pSession
77  	 */
78  	@Override
79  	public void init(Attributes pAttribs, SAXSession pSession) {
80  		this.iExpMethodRspNode = null;
81  		// no attribs
82  	}
83  
84  	/**
85  	 * @param pData
86  	 */
87  	@Override
88  	public void parseData(String pData) {
89  		// no data
90  	}
91  
92  	@Override
93  	public void testChild(String pNodeNameEnum) throws SAXException {
94  		if (this.iExpMethodRspNode != null) throw new SAXException(getNodeName() + " node can have only one child node!");
95  		if (pNodeNameEnum != EXPMETHODRESPONSE) throw new SAXException(
96  			getNodeName() + " node's child node can be EXPMETHODRESPONSE only! " + pNodeNameEnum + " is invalid!"
97  		);
98  	}
99  
100 	@Override
101 	public void testCompletness() throws SAXException {
102 		if (this.iExpMethodRspNode == null) throw new SAXException(
103 			getNodeName() + " node must have an EXPMETHODRESPONSE child node!"
104 		);
105 	}
106 
107 	@Override
108 	public CIMError getCIMError() {
109 		// can be null if it's value was read out before
110 		if (this.iExpMethodRspNode == null) return null;
111 		return this.iExpMethodRspNode.getCIMError();
112 	}
113 
114 	@Override
115 	public CIMArgument<?>[] getCIMArguments() {
116 		// no out arguments
117 		return null;
118 	}
119 
120 	public int getReturnValueCount() {
121 		return this.iExpMethodRspNode == null ? 0 : this.iExpMethodRspNode.getReturnValueCount();
122 	}
123 
124 	public Object readReturnValue() {
125 		return this.iExpMethodRspNode == null ? null : this.iExpMethodRspNode.readReturnValue();
126 	}
127 }