1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 import java.util.ArrayList;
49 import org.metricshub.wbem.javax.cim.CIMInstance;
50 import org.metricshub.wbem.javax.cim.CIMObjectPath;
51 import org.metricshub.wbem.javax.cim.CIMProperty;
52 import org.metricshub.wbem.sblim.cimclient.internal.cim.CIMHelper;
53 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.LocalPathBuilder;
54 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
55 import org.metricshub.wbem.sblim.cimclient.internal.util.WBEMConfiguration;
56 import org.xml.sax.Attributes;
57 import org.xml.sax.SAXException;
58
59
60
61
62
63
64
65
66
67 public class InstanceNode extends AbstractObjectNode {
68 private String iClassName;
69
70
71
72
73
74 private QualifiedNodeHandler iQualiHandler;
75
76 private ArrayList<CIMProperty<?>> iCIMPropAL;
77
78
79
80
81 public InstanceNode() {
82 super(INSTANCE);
83 }
84
85 @Override
86 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
87 this.iLocalPath = pSession.getDefLocalPath();
88 this.iQualiHandler = new QualifiedNodeHandler();
89 this.iCIMPropAL = null;
90 this.iClassName = getClassName(pAttribs);
91 }
92
93
94
95
96 @Override
97 public void parseData(String pData) {
98
99 }
100
101 private static final String[] ALLOWED_CHILDREN = { QUALIFIER, PROPERTY, PROPERTY_ARRAY, PROPERTY_REFERENCE };
102
103 @Override
104 public void testChild(String pNodeNameEnum) throws SAXException {
105 for (int i = 0; i < ALLOWED_CHILDREN.length; i++) if (ALLOWED_CHILDREN[i] == pNodeNameEnum) return;
106 throw new SAXException(getNodeName() + " node cannot have " + pNodeNameEnum + " child node!");
107 }
108
109 @Override
110 public void childParsed(Node pChild) {
111 if (this.iQualiHandler.addQualifierNode(pChild)) return;
112 if (this.iCIMPropAL == null) this.iCIMPropAL = new ArrayList<CIMProperty<?>>();
113 this.iCIMPropAL.add(((AbstractPropertyNode) pChild).getCIMProperty());
114 }
115
116 @Override
117 public void testCompletness() {
118
119 }
120
121
122
123
124
125
126 public CIMInstance getCIMInstance() {
127 return new CIMInstance(LocalPathBuilder.build(this.iLocalPath, this.iClassName, null), getProps());
128 }
129
130
131
132
133
134
135
136 public CIMInstance getCIMInstance(CIMObjectPath pObjPath) {
137 if (
138 WBEMConfiguration.getGlobalConfiguration().synchronizeNumericKeyDataTypes()
139 ) return CIMHelper.CIMInstanceWithSynchonizedNumericKeyDataTypes(pObjPath, getProps());
140 return new CIMInstance(pObjPath, getProps());
141 }
142
143
144
145
146
147 public Object getValue() {
148 return getCIMInstance();
149 }
150
151 private static final CIMProperty<?>[] EMPTY_PA = new CIMProperty[0];
152
153 private CIMProperty<?>[] getProps() {
154 if (this.iCIMPropAL == null) return null;
155 return this.iCIMPropAL.toArray(EMPTY_PA);
156 }
157 }