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.CIMDataType;
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 ValueReferenceNode extends AbstractScalarValueNode implements ObjectPathIf {
60 private CIMObjectPath iCIMObjPath;
61
62 private String iChildNodeName = null;
63
64
65
66
67 public ValueReferenceNode() {
68 super(VALUE_REFERENCE);
69 }
70
71 @Override
72 public void childParsed(Node pChild) {
73 this.iCIMObjPath = ((AbstractPathNode) pChild).getCIMObjectPath();
74 if (
75 (CLASSNAME.equalsIgnoreCase(this.iChildNodeName) || INSTANCENAME.equalsIgnoreCase(this.iChildNodeName)) &&
76 this.iCIMObjPath.getNamespace() != null
77 ) {
78
79
80 this.iCIMObjPath =
81 new CIMObjectPath(
82 this.iCIMObjPath.getScheme(),
83 this.iCIMObjPath.getHost(),
84 this.iCIMObjPath.getPort(),
85 null,
86 this.iCIMObjPath.getObjectName(),
87 this.iCIMObjPath.getKeys(),
88 this.iCIMObjPath.getXmlSchemaName()
89 );
90 }
91 }
92
93
94
95
96
97 @Override
98 public void init(Attributes pAttribs, SAXSession pSession) {
99 this.iCIMObjPath = null;
100 this.iChildNodeName = null;
101
102 }
103
104
105
106
107 @Override
108 public void parseData(String pData) {
109
110 }
111
112 private static final String[] ALLOWED_CHILDREN = {
113 CLASSPATH,
114 LOCALCLASSPATH,
115 CLASSNAME,
116 INSTANCEPATH,
117 LOCALINSTANCEPATH,
118 INSTANCENAME
119 };
120
121 @Override
122 public void testChild(String pNodeNameEnum) throws SAXException {
123 if (this.iCIMObjPath != null) throw new SAXException(
124 "Child node " + pNodeNameEnum + " is illegal, since VALUE.REFERENCE already has a child!"
125 );
126 for (int i = 0; i < ALLOWED_CHILDREN.length; i++) if (ALLOWED_CHILDREN[i] == pNodeNameEnum) {
127 this.iChildNodeName = pNodeNameEnum;
128 return;
129 }
130 throw new SAXException(
131 "Invalid child node in " +
132 getNodeName() +
133 " node: " +
134 pNodeNameEnum +
135 "! Valid nodes are CLASSPATH, LOCALCLASSPATH, CLASSNAME, " +
136 "INSTANCEPATH, LOCALINSTANCEPATH, INSTANCENAME"
137 );
138 }
139
140 @Override
141 public void testCompletness() throws SAXException {
142 if (this.iCIMObjPath == null) throw new SAXException("VALUE.REFERENCE node must have a child node!");
143 }
144
145
146
147
148
149 public Object getValue() {
150 return this.iCIMObjPath;
151 }
152
153 public CIMDataType getType() {
154 return this.iCIMObjPath == null ? null : new CIMDataType(this.iCIMObjPath.getObjectName());
155 }
156
157 public CIMObjectPath getCIMObjectPath() {
158 return this.iCIMObjPath;
159 }
160 }