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
59 public class ValueObjectWithLocalPathNode extends AbstractScalarValueNode {
60
61 private String iPathNodeNameEnum;
62
63 private CIMObjectPath iObjPath;
64
65
66 private String iObjNodeNameEnum;
67
68 private CIMNamedElementInterface iCIMObj;
69
70
71
72
73 public ValueObjectWithLocalPathNode() {
74 super(VALUE_OBJECTWITHLOCALPATH);
75 }
76
77
78
79
80
81 @Override
82 public void init(Attributes pAttribs, SAXSession pSession) {
83 this.iPathNodeNameEnum = this.iObjNodeNameEnum = null;
84 this.iObjPath = null;
85 this.iCIMObj = null;
86
87 }
88
89
90
91
92 @Override
93 public void parseData(String pData) {
94
95 }
96
97 @Override
98 public void testChild(String pNodeNameEnum) throws SAXException {
99 if (pNodeNameEnum == LOCALCLASSPATH) {
100 if (this.iPathNodeNameEnum != null) duplicatedNode(this.iPathNodeNameEnum, LOCALCLASSPATH);
101 if (this.iObjNodeNameEnum == INSTANCE) illegalChildNodePair(LOCALCLASSPATH, INSTANCE);
102 } else if (pNodeNameEnum == CLASS) {
103 if (this.iObjNodeNameEnum != null) duplicatedNode(this.iObjNodeNameEnum, CLASS);
104 if (this.iPathNodeNameEnum == LOCALINSTANCEPATH) illegalChildNodePair(LOCALINSTANCEPATH, CLASS);
105 } else if (pNodeNameEnum == LOCALINSTANCEPATH) {
106 if (this.iPathNodeNameEnum != null) duplicatedNode(this.iPathNodeNameEnum, LOCALINSTANCEPATH);
107 if (this.iObjNodeNameEnum == CLASS) illegalChildNodePair(LOCALINSTANCEPATH, CLASS);
108 } else if (pNodeNameEnum == INSTANCE) {
109 if (this.iObjNodeNameEnum != null) duplicatedNode(this.iObjNodeNameEnum, INSTANCE);
110 if (this.iPathNodeNameEnum == LOCALCLASSPATH) illegalChildNodePair(LOCALCLASSPATH, INSTANCE);
111 } else throw new SAXException(getNodeName() + " node cannot have " + pNodeNameEnum + " child!");
112 }
113
114 @Override
115 public void childParsed(Node pChild) throws SAXException {
116 if (pChild instanceof AbstractObjectPathNode) {
117 this.iPathNodeNameEnum = pChild.getNodeName();
118 this.iObjPath = ((AbstractObjectPathNode) pChild).getCIMObjectPath();
119 } else {
120
121 this.iObjNodeNameEnum = pChild.getNodeName();
122 if (this.iPathNodeNameEnum == null) throw new SAXException(
123 getNodeName() + " first child should contain an object path!"
124 );
125 if (pChild instanceof ClassNode) {
126 this.iCIMObj = ((ClassNode) pChild).getCIMClass(this.iObjPath);
127 } else {
128 this.iCIMObj = ((InstanceNode) pChild).getCIMInstance(this.iObjPath);
129 }
130 }
131 }
132
133 @Override
134 public void testCompletness() throws SAXException {
135 if (this.iPathNodeNameEnum == null) throw new SAXException(
136 getNodeName() + " node must have a LOCALCLASSPATH or a LOCALINSTANCEPATH child node!"
137 );
138 if (this.iObjNodeNameEnum == null) throw new SAXException(
139 getNodeName() + " node must have a CLASS or INSTANCE child node!"
140 );
141 }
142
143
144
145
146
147 public Object getValue() {
148 return this.iCIMObj;
149 }
150
151 public CIMDataType getType() {
152 if (this.iCIMObj instanceof CIMClass) return CIMDataType.CLASS_T;
153 return CIMDataType.OBJECT_T;
154 }
155 }