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 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 import org.metricshub.wbem.javax.cim.CIMClass;
48 import org.metricshub.wbem.javax.cim.CIMDataType;
49 import org.metricshub.wbem.javax.cim.CIMNamedElementInterface;
50 import org.metricshub.wbem.javax.cim.CIMObjectPath;
51 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
52 import org.xml.sax.Attributes;
53 import org.xml.sax.SAXException;
54
55
56
57
58 public class ValueObjectWithPathNode extends AbstractScalarValueNode {
59
60 private String iPathNodeNameEnum;
61
62 private CIMObjectPath iObjPath;
63
64
65 private String iObjNodeNameEnum;
66
67 private CIMNamedElementInterface iCIMObj;
68
69
70
71
72 public ValueObjectWithPathNode() {
73 super(VALUE_OBJECTWITHPATH);
74 }
75
76
77
78
79
80 @Override
81 public void init(Attributes pAttribs, SAXSession pSession) {
82 this.iPathNodeNameEnum = this.iObjNodeNameEnum = null;
83 this.iObjPath = null;
84 this.iCIMObj = null;
85
86 }
87
88
89
90
91 @Override
92 public void parseData(String pData) {
93
94 }
95
96 @Override
97 public void testChild(String pNodeNameEnum) throws SAXException {
98 if (pNodeNameEnum == CLASSPATH) {
99 if (this.iPathNodeNameEnum != null) duplicatedNode(this.iPathNodeNameEnum, CLASSPATH);
100 if (this.iObjNodeNameEnum == INSTANCE) illegalChildNodePair(CLASSPATH, INSTANCE);
101 } else if (pNodeNameEnum == CLASS) {
102 if (this.iObjNodeNameEnum != null) duplicatedNode(this.iObjNodeNameEnum, CLASS);
103 if (this.iPathNodeNameEnum == INSTANCEPATH) illegalChildNodePair(INSTANCEPATH, CLASS);
104 } else if (pNodeNameEnum == INSTANCEPATH) {
105 if (this.iPathNodeNameEnum != null) duplicatedNode(this.iPathNodeNameEnum, INSTANCEPATH);
106 if (this.iObjNodeNameEnum == CLASS) illegalChildNodePair(INSTANCEPATH, CLASS);
107 } else if (pNodeNameEnum == INSTANCE) {
108 if (this.iObjNodeNameEnum != null) duplicatedNode(this.iObjNodeNameEnum, INSTANCE);
109 if (this.iPathNodeNameEnum == CLASSPATH) illegalChildNodePair(CLASSPATH, INSTANCE);
110 } else throw new SAXException(getNodeName() + " node cannot have " + pNodeNameEnum + " child!");
111 }
112
113 @Override
114 public void childParsed(Node pChild) throws SAXException {
115 if (pChild instanceof AbstractObjectPathNode) {
116 this.iPathNodeNameEnum = pChild.getNodeName();
117 this.iObjPath = ((AbstractObjectPathNode) pChild).getCIMObjectPath();
118 } else {
119
120 this.iObjNodeNameEnum = pChild.getNodeName();
121 if (this.iPathNodeNameEnum == null) throw new SAXException(
122 getNodeName() + " first child should contain an object path!"
123 );
124 if (pChild instanceof ClassNode) {
125 this.iCIMObj = ((ClassNode) pChild).getCIMClass(this.iObjPath);
126 } else {
127 this.iCIMObj = ((InstanceNode) pChild).getCIMInstance(this.iObjPath);
128 }
129 }
130 }
131
132 @Override
133 public void testCompletness() throws SAXException {
134 if (this.iPathNodeNameEnum == null) throw new SAXException(
135 getNodeName() + " node must have a CLASSPATH or a INSTANCEPATH child node!"
136 );
137 if (this.iObjNodeNameEnum == null) throw new SAXException(
138 getNodeName() + " node must have a CLASS or INSTANCE child node!"
139 );
140 }
141
142
143
144
145
146 public Object getValue() {
147 return this.iCIMObj;
148 }
149
150 public CIMDataType getType() {
151 if (this.iCIMObj instanceof CIMClass) return CIMDataType.CLASS_T;
152 return CIMDataType.OBJECT_T;
153 }
154 }