1 /*
2 (C) Copyright IBM Corp. 2006, 2009
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 * 1820763 2007-10-29 ebak Supporting the EmbeddedInstance qualifier
19 * 1848607 2007-12-11 ebak Strict EmbeddedObject types
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 * 2531371 2009-02-10 raman_arora Upgrade client to JDK 1.5 (Phase 2)
23 * 2797550 2009-06-01 raman_arora JSR48 compliance - add Java Generics
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.CIMParameter;
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 * Class AbstractParameterNode is the superclass of ParameterArrayNode,
55 * ParameterNode, ParameterRefArrayNode and ParameterReferenceNode classes.
56 */
57 public abstract class AbstractParameterNode extends Node implements TypedIf {
58 private String iName;
59
60 protected QualifiedNodeHandler iQualiHandler;
61
62 protected SAXSession iSession;
63
64 /**
65 * Ctor.
66 *
67 * @param pNameEnum
68 */
69 public AbstractParameterNode(String pNameEnum) {
70 super(pNameEnum);
71 }
72
73 @Override
74 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
75 this.iSession = pSession;
76 this.iQualiHandler = QualifiedNodeHandler.init(this.iQualiHandler);
77 this.iName = getCIMName(pAttribs);
78 specificInit(pAttribs);
79 }
80
81 protected abstract void specificInit(Attributes pAttribs) throws SAXException;
82
83 @Override
84 public void testChild(String pNodeNameEnum) throws SAXException {
85 if (pNodeNameEnum != QUALIFIER) throw new SAXException(
86 getNodeName() + " cannot have " + pNodeNameEnum + " child node!"
87 );
88 }
89
90 @Override
91 public void childParsed(Node pChild) {
92 this.iQualiHandler.addQualifierNode(pChild);
93 }
94
95 /**
96 * @param pData
97 */
98 @Override
99 public void parseData(String pData) {
100 // no data
101 }
102
103 /**
104 * getCIMParameter
105 *
106 * @return CIMParameter
107 */
108 public CIMParameter<Object> getCIMParameter() {
109 /*
110 * CIMParameter(String name, CIMDataType type, CIMQualifier[]
111 * qualifiers)
112 *
113 * Not dealing with embedded object is faster. Here we don't have to do
114 * anything with embedded object qualifier, since parameter doesn't have
115 * value.
116 *
117 * Strict embObj type parsing requires different behavior.
118 */
119 return new CIMParameter<Object>(
120 this.iName,
121 getType(),
122 this.iQualiHandler.getQualis(!this.iSession.strictEmbObjParsing())
123 );
124 }
125 }