1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 import org.metricshub.wbem.javax.cim.CIMDataType;
42 import org.metricshub.wbem.javax.cim.CIMInstance;
43 import org.metricshub.wbem.javax.cim.CIMObjectPath;
44 import org.metricshub.wbem.sblim.cimclient.internal.cim.CIMHelper;
45 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
46 import org.metricshub.wbem.sblim.cimclient.internal.util.WBEMConfiguration;
47 import org.xml.sax.Attributes;
48 import org.xml.sax.SAXException;
49
50
51
52
53
54
55
56
57
58
59
60
61
62 public class ValueInstanceWithPathNode extends AbstractScalarValueNode {
63
64 private CIMObjectPath iCIMInstPath;
65
66
67 private CIMInstance iCIMInstance;
68
69
70
71
72 public ValueInstanceWithPathNode() {
73 super(VALUE_INSTANCEWITHPATH);
74 }
75
76
77
78
79
80 @Override
81 public void init(Attributes pAttribs, SAXSession pSession) {
82
83 this.iCIMInstPath = null;
84 this.iCIMInstance = null;
85 }
86
87
88
89
90 @Override
91 public void parseData(String pData) {
92
93 }
94
95 @Override
96 public void testChild(String pNodeNameEnum) throws SAXException {
97 if (pNodeNameEnum == INSTANCEPATH) {
98 if (this.iCIMInstPath != null) throw new SAXException(
99 "VALUE.INSTANCEWITHPATH node can have only one INSTANCEPATH node, but another one was found!"
100 );
101 } else if (pNodeNameEnum == INSTANCE) {
102 if (this.iCIMInstance != null) throw new SAXException(
103 "VALUE.INSTANCEWITHPATH node can have only one INSTANCE node, but another one was found!"
104 );
105 } else {
106 throw new SAXException("VALUE.INSTANCEWITHPATH node cannot have " + pNodeNameEnum + " child node!");
107 }
108 }
109
110 @Override
111 public void childParsed(Node pChild) {
112 if (pChild instanceof InstancePathNode) {
113 this.iCIMInstPath = ((InstancePathNode) pChild).getCIMObjectPath();
114 } else {
115 this.iCIMInstance = ((InstanceNode) pChild).getCIMInstance();
116 }
117 }
118
119 @Override
120 public void testCompletness() throws SAXException {
121 if (this.iCIMInstPath == null) throw new SAXException(
122 "VALUE.INSTANCEWITHPATH node must have an INSTANCEPATH child node!"
123 );
124 if (this.iCIMInstance == null) throw new SAXException(
125 "VALUE.INSTANCEWITHPATH node must have an INSTANCE child node!"
126 );
127 }
128
129
130
131
132
133 public Object getValue() {
134
135
136
137
138 if (
139 WBEMConfiguration.getGlobalConfiguration().synchronizeNumericKeyDataTypes()
140 ) return CIMHelper.CIMInstanceWithSynchonizedNumericKeyDataTypes(
141 this.iCIMInstPath,
142 this.iCIMInstance.getProperties()
143 );
144 return new CIMInstance(this.iCIMInstPath, this.iCIMInstance.getProperties());
145 }
146
147 public CIMDataType getType() {
148 return CIMDataType.OBJECT_T;
149 }
150 }