1 /*
2 (C) Copyright IBM Corp. 2006, 2012
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 * 2531371 2009-02-10 raman_arora Upgrade client to JDK 1.5 (Phase 2)
22 * 3511454 2012-03-27 blaschke-oss SAX nodes not reinitialized properly
23 */
24
25 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
26
27 /*-
28 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
29 * WBEM Java Client
30 * ჻჻჻჻჻჻
31 * Copyright 2023 - 2025 MetricsHub
32 * ჻჻჻჻჻჻
33 * Licensed under the Apache License, Version 2.0 (the "License");
34 * you may not use this file except in compliance with the License.
35 * You may obtain a copy of the License at
36 *
37 * http://www.apache.org/licenses/LICENSE-2.0
38 *
39 * Unless required by applicable law or agreed to in writing, software
40 * distributed under the License is distributed on an "AS IS" BASIS,
41 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 * See the License for the specific language governing permissions and
43 * limitations under the License.
44 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
45 */
46
47 import java.util.ArrayList;
48 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
49 import org.xml.sax.Attributes;
50 import org.xml.sax.SAXException;
51
52 /**
53 * ELEMENT MULTIREQ (SIMPLEREQ, SIMPLEREQ+)
54 */
55 public class MultiReqNode extends AbstractMessageNode {
56 private ArrayList<Node> iSimpleReqAList;
57
58 /**
59 * Ctor.
60 */
61 public MultiReqNode() {
62 super(MULTIREQ);
63 }
64
65 public void addChild(Node pChild) {
66 if (this.iSimpleReqAList == null) this.iSimpleReqAList = new ArrayList<Node>();
67 this.iSimpleReqAList.add(pChild);
68 }
69
70 /**
71 * @param pAttribs
72 * @param pSession
73 */
74 @Override
75 public void init(Attributes pAttribs, SAXSession pSession) {
76 if (this.iSimpleReqAList != null) this.iSimpleReqAList.clear();
77 // no attributes
78 }
79
80 /**
81 * @param pData
82 */
83 @Override
84 public void parseData(String pData) {
85 // no data
86 }
87
88 @Override
89 public void testChild(String pNodeNameEnum) throws SAXException {
90 if (pNodeNameEnum != SIMPLEREQ) throw new SAXException(
91 "MULTIREQ node can have SIMPLEREQ child nodes only! " + pNodeNameEnum + " child node is invalid!"
92 );
93 }
94
95 @Override
96 public void testCompletness() throws SAXException {
97 if (this.iSimpleReqAList == null || this.iSimpleReqAList.size() < 2) throw new SAXException(
98 "MULTIREQ node must have at least 2 SIMPLEREQ child nodes!"
99 );
100 }
101
102 /**
103 * size
104 *
105 * @return int
106 */
107 public int size() {
108 return this.iSimpleReqAList == null ? 0 : this.iSimpleReqAList.size();
109 }
110 }