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   * 1686000    2007-04-20  ebak         modifyInstance() missing from WBEMClient
19   * 1720707    2007-05-17  ebak         Conventional Node factory for CIM-XML SAX parser
20   * 2003590    2008-06-30  blaschke-oss Change licensing from CPL to EPL
21   * 2524131    2009-01-21  raman_arora  Upgrade client to JDK 1.5 (Phase 1)
22   * 3511454    2012-03-27  blaschke-oss SAX nodes not reinitialized properly
23   *    2712    2013-11-14  blaschke-oss SimpleReqNode allows any CIM element as child
24   *    2538    2013-11-28  blaschke-oss CR14: Support new CORRELATOR element
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.sblim.cimclient.internal.cimxml.sax.SAXSession;
50  import org.xml.sax.Attributes;
51  import org.xml.sax.SAXException;
52  
53  /**
54   * ELEMENT SIMPLEREQ (CORRELATOR*, (METHODCALL | IMETHODCALL))
55   */
56  public class SimpleReqNode extends AbstractMessageNode {
57  	private AbstractMethodCallNode iMethodCallNode;
58  
59  	/**
60  	 * Ctor.
61  	 */
62  	public SimpleReqNode() {
63  		super(SIMPLEREQ);
64  	}
65  
66  	public void addChild(Node pChild) {
67  		if (pChild instanceof AbstractMethodCallNode) {
68  			this.iMethodCallNode = (AbstractMethodCallNode) pChild;
69  		} else if (pChild instanceof CorrelatorNode) {
70  			// TODO: return to WBEMClient API if JSR48 changes
71  		}
72  	}
73  
74  	/**
75  	 * @param pAttribs
76  	 * @param pSession
77  	 */
78  	@Override
79  	public void init(Attributes pAttribs, SAXSession pSession) {
80  		this.iMethodCallNode = null;
81  		// no attributes
82  	}
83  
84  	/**
85  	 * @param pData
86  	 */
87  	@Override
88  	public void parseData(String pData) {
89  		// no data
90  	}
91  
92  	/**
93  	 * @param pNodeNameEnum
94  	 */
95  	@Override
96  	public void testChild(String pNodeNameEnum) throws SAXException {
97  		if (pNodeNameEnum == IMETHODCALL || pNodeNameEnum == METHODCALL) {
98  			if (this.iMethodCallNode != null) throw new SAXException("SIMPLEREQ node can have only one child node!");
99  		} else if (pNodeNameEnum != CORRELATOR) throw new SAXException(
100 			"SIMPLEREQ node cannot have " + pNodeNameEnum + " child node!"
101 		);
102 	}
103 
104 	@Override
105 	public void testCompletness() throws SAXException {
106 		if (this.iMethodCallNode == null) throw new SAXException("SIMPLEREQ node must have a child node!");
107 	}
108 
109 	/**
110 	 * getAbstractMethodCallNode
111 	 *
112 	 * @return AbstractMethodCallNode
113 	 */
114 	public AbstractMethodCallNode getAbstractMethodCallNode() {
115 		return this.iMethodCallNode;
116 	}
117 }