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 * 1689085 2007-04-10 ebak Embedded object enhancements for Pegasus
19 * 1714878 2007-05-08 ebak Empty string property values are parsed as nulls
20 * 1720707 2007-05-17 ebak Conventional Node factory for CIM-XML SAX parser
21 * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL
22 * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1)
23 * 2797550 2009-06-01 raman_arora JSR48 compliance - add Java Generics
24 * 2700 2013-11-07 blaschke-oss PROPERTY does not require TYPE attribute
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.CIMDataType;
50 import org.metricshub.wbem.javax.cim.CIMQualifier;
51 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.EmbObjHandler;
52 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
53 import org.xml.sax.Attributes;
54 import org.xml.sax.SAXException;
55
56 /**
57 * <pre>
58 * ELEMENT PROPERTY (QUALIFIER*, VALUE?)
59 * ATTLIST PROPERTY
60 * %CIMName;
61 * %ClassOrigin;
62 * %Propagated;
63 * %CIMType; #REQUIRED
64 * %EmbeddedObject; #IMPLIED - new
65 * xml:lang NMTOKEN #IMPLIED
66 * </pre>
67 */
68 public class PropertyNode extends AbstractPropertyNode {
69 private CIMDataType iType;
70
71 // VALUE element
72 private boolean iHasValue;
73
74 private boolean iHasTypeAttribute;
75
76 private Object iValue;
77
78 private EmbObjHandler iEmbObjHandler;
79
80 /**
81 * Ctor.
82 */
83 public PropertyNode() {
84 super(PROPERTY);
85 }
86
87 @Override
88 protected void specificInit(Attributes pAttribs, SAXSession pSession) throws SAXException {
89 this.iHasTypeAttribute = (getCIMType(pAttribs, true) != null);
90 this.iEmbObjHandler =
91 EmbObjHandler.init(this.iEmbObjHandler, getNodeName(), pAttribs, pSession, this.iQualiHandler, true);
92 this.iHasValue = false;
93 }
94
95 @Override
96 public void childValueNodeParsed(Node pChild) throws SAXException {
97 this.iHasValue = true;
98 if (!this.iHasTypeAttribute && ((ValueNode) pChild).getType() == null) throw new SAXException(
99 "PROPERTY element missing TYPE attribute!"
100 );
101 this.iEmbObjHandler.addValueNode((ValueNode) pChild);
102 }
103
104 @Override
105 protected String getChildValueNodeNameEnum() {
106 return VALUE;
107 }
108
109 @Override
110 protected boolean hasValueNode() {
111 return this.iHasValue;
112 }
113
114 @Override
115 protected CIMQualifier<?>[] getQualis() {
116 return this.iQualiHandler.getQualis(getType() == CIMDataType.STRING_T);
117 }
118
119 @Override
120 public void testCompletness() throws SAXException {
121 /*
122 * Value and type conversion are placed here. It can throw Exception.
123 */
124 this.iType = this.iEmbObjHandler.getType();
125 this.iValue = this.iEmbObjHandler.getValue();
126 }
127
128 public CIMDataType getType() {
129 return this.iType;
130 }
131
132 public Object getValue() {
133 return this.iValue;
134 }
135 }