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 * 2531371 2009-02-10 raman_arora Upgrade client to JDK 1.5 (Phase 2) 22 * 2750520 2009-04-10 blaschke-oss Code cleanup from empty statement et al 23 * 3511454 2012-03-27 blaschke-oss SAX nodes not reinitialized properly 24 * 3513349 2012-03-31 blaschke-oss TCK: CIMDataType must not accept null string 25 * 3602604 2013-01-29 blaschke-oss Clean up SAXException messages 26 * 2604 2013-07-01 blaschke-oss SAXException messages should contain node name 27 * 2715 2013-11-26 blaschke-oss Add VALUE.NULL support 28 */ 29 30 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node; 31 32 /*- 33 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ 34 * WBEM Java Client 35 * ჻჻჻჻჻჻ 36 * Copyright 2023 - 2025 MetricsHub 37 * ჻჻჻჻჻჻ 38 * Licensed under the Apache License, Version 2.0 (the "License"); 39 * you may not use this file except in compliance with the License. 40 * You may obtain a copy of the License at 41 * 42 * http://www.apache.org/licenses/LICENSE-2.0 43 * 44 * Unless required by applicable law or agreed to in writing, software 45 * distributed under the License is distributed on an "AS IS" BASIS, 46 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 47 * See the License for the specific language governing permissions and 48 * limitations under the License. 49 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ 50 */ 51 52 import java.util.ArrayList; 53 import org.metricshub.wbem.javax.cim.CIMDataType; 54 import org.metricshub.wbem.javax.cim.CIMObjectPath; 55 import org.metricshub.wbem.sblim.cimclient.GenericExts; 56 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession; 57 import org.xml.sax.Attributes; 58 import org.xml.sax.SAXException; 59 60 /** 61 * ELEMENT VALUE.REFARRAY (VALUE.REFERENCE|VALUE.NULL)* 62 */ 63 public class ValueRefArrayNode extends AbstractArrayValueNode { 64 private ArrayList<CIMObjectPath> iCIMObjPathAL; 65 66 /** 67 * Ctor. 68 */ 69 public ValueRefArrayNode() { 70 super(VALUE_REFARRAY); 71 } 72 73 /** 74 * @param pAttribs 75 * @param pSession 76 */ 77 @Override 78 public void init(Attributes pAttribs, SAXSession pSession) { 79 this.iCIMObjPathAL = GenericExts.initClearArrayList(this.iCIMObjPathAL); 80 // no attributes 81 } 82 83 /** 84 * @param pData 85 */ 86 @Override 87 public void parseData(String pData) { 88 // no data 89 } 90 91 @Override 92 public void testChild(String pNodeNameEnum) throws SAXException { 93 if (pNodeNameEnum != VALUE_REFERENCE && pNodeNameEnum != VALUE_NULL) throw new SAXException( 94 getNodeName() + " node child node can be VALUE.REFERENCE or VALUE.NULL only while it is " + pNodeNameEnum + "!" 95 ); 96 } 97 98 @Override 99 public void childParsed(Node pChild) { 100 if (this.iCIMObjPathAL == null) this.iCIMObjPathAL = new ArrayList<CIMObjectPath>(); 101 if (pChild instanceof ValueReferenceNode) this.iCIMObjPathAL.add( 102 ((ValueReferenceNode) pChild).getCIMObjectPath() 103 ); else if (pChild instanceof ValueNullNode) this.iCIMObjPathAL.add(null); 104 } 105 106 @Override 107 public void testCompletness() { 108 // child nodes are not mandatory 109 } 110 111 /** 112 * @see ArrayIf#elementAt(int) 113 * @return CIMObjectPath 114 */ 115 public Object elementAt(int pIdx) { 116 return this.iCIMObjPathAL == null ? null : this.iCIMObjPathAL.get(pIdx); 117 } 118 119 public int size() { 120 return this.iCIMObjPathAL == null ? 0 : this.iCIMObjPathAL.size(); 121 } 122 123 public CIMDataType getType() { 124 return new CIMDataType("", 0); 125 } 126 127 private static final CIMObjectPath[] EMPTY_OPA = new CIMObjectPath[0]; 128 129 /** 130 * @see ValueIf#getValue() 131 * @return CIMObjectPath[] 132 */ 133 public Object getValue() { 134 return size() == 0 ? null : this.iCIMObjPathAL.toArray(EMPTY_OPA); 135 } 136 }