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
27 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 import org.metricshub.wbem.javax.cim.CIMClass;
50 import org.metricshub.wbem.javax.cim.CIMDataType;
51 import org.metricshub.wbem.javax.cim.CIMNamedElementInterface;
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
58
59 public class ValueObjectNode extends AbstractScalarValueNode {
60 private CIMNamedElementInterface iCIMObject;
61
62
63
64
65 public ValueObjectNode() {
66 super(VALUE_OBJECT);
67 }
68
69
70
71
72
73 @Override
74 public void init(Attributes pAttribs, SAXSession pSession) {
75 this.iCIMObject = null;
76
77 }
78
79
80
81
82 @Override
83 public void parseData(String pData) {
84
85 }
86
87 @Override
88 public void testChild(String pNodeNameEnum) throws SAXException {
89 if (this.iCIMObject != null) throw new SAXException(
90 "This " + getNodeName() + " node can have only one child but an additional " + pNodeNameEnum + " node found!"
91 );
92 if (pNodeNameEnum != CLASS && pNodeNameEnum != INSTANCE) throw new SAXException(
93 getNodeName() + " node child node can be CLASS or INSTANCE but a " + pNodeNameEnum + " node was found!"
94 );
95 }
96
97 @Override
98 public void childParsed(Node pChild) {
99 AbstractObjectNode objNode = (AbstractObjectNode) pChild;
100 if (objNode instanceof ClassNode) this.iCIMObject = ((ClassNode) objNode).getCIMClass(); else this.iCIMObject =
101 ((InstanceNode) objNode).getCIMInstance();
102 }
103
104 @Override
105 public void testCompletness() throws SAXException {
106 if (this.iCIMObject == null) throw new SAXException("VALUE.OBJECT node must have a CLASS or INSTANCE child node!");
107 }
108
109
110
111
112
113 public Object getValue() {
114 return this.iCIMObject;
115 }
116
117 public CIMDataType getType() {
118 if (this.iCIMObject instanceof CIMClass) return CIMDataType.CLASS_T;
119 return CIMDataType.OBJECT_T;
120 }
121 }