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 org.metricshub.wbem.javax.cim.CIMDataType;
49 import org.metricshub.wbem.javax.cim.CIMInstance;
50 import org.metricshub.wbem.javax.cim.CIMObjectPath;
51 import org.metricshub.wbem.sblim.cimclient.internal.cim.CIMHelper;
52 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
53 import org.metricshub.wbem.sblim.cimclient.internal.util.WBEMConfiguration;
54 import org.xml.sax.Attributes;
55 import org.xml.sax.SAXException;
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 public class ValueNamedInstanceNode extends AbstractScalarValueNode {
74
75 private CIMObjectPath iCIMInstPath;
76
77
78 private CIMInstance iCIMInstance;
79
80
81
82
83 public ValueNamedInstanceNode() {
84 super(VALUE_NAMEDINSTANCE);
85 }
86
87
88
89
90
91 @Override
92 public void init(Attributes pAttribs, SAXSession pSession) {
93 this.iCIMInstPath = null;
94 this.iCIMInstance = null;
95
96 }
97
98
99
100
101 @Override
102 public void parseData(String pData) {
103
104 }
105
106 @Override
107 public void testChild(String pNodeNameEnum) throws SAXException {
108 if (pNodeNameEnum == INSTANCENAME) {
109 if (this.iCIMInstPath != null) throw new SAXException(
110 "VALUE.NAMEDINSTANCE node can have only one INSTANCENAME node, but another one was found!"
111 );
112 } else if (pNodeNameEnum == INSTANCE) {
113 if (this.iCIMInstance != null) throw new SAXException(
114 "VALUE.NAMEDINSTANCE node can have only one INSTANCE node, but another one was found!"
115 );
116 } else {
117 throw new SAXException("VALUE.NAMEDINSTANCE node cannot have " + pNodeNameEnum + " child node!");
118 }
119 }
120
121 @Override
122 public void childParsed(Node pChild) {
123 if (pChild instanceof InstanceNameNode) {
124 this.iCIMInstPath = ((InstanceNameNode) pChild).getCIMObjectPath();
125 } else {
126 this.iCIMInstance = ((InstanceNode) pChild).getCIMInstance();
127 }
128 }
129
130 @Override
131 public void testCompletness() throws SAXException {
132 if (this.iCIMInstPath == null) throw new SAXException(
133 "VALUE.NAMEDINSTANCE node must have an INSTANCENAME child node!"
134 );
135 if (this.iCIMInstance == null) throw new SAXException("VALUE.NAMEDINSTANCE node must have an INSTANCE child node!");
136 }
137
138
139
140
141
142 public Object getValue() {
143
144
145
146
147
148 if (
149 WBEMConfiguration.getGlobalConfiguration().synchronizeNumericKeyDataTypes()
150 ) return CIMHelper.CIMInstanceWithSynchonizedNumericKeyDataTypes(
151 this.iCIMInstPath,
152 this.iCIMInstance.getProperties()
153 );
154 return new CIMInstance(this.iCIMInstPath, this.iCIMInstance.getProperties());
155 }
156
157 public CIMDataType getType() {
158 return CIMDataType.OBJECT_T;
159 }
160 }