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 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
49 import org.xml.sax.Attributes;
50 import org.xml.sax.SAXException;
51
52
53
54
55
56
57
58
59
60 public class CIMNode extends Node implements NonVolatileIf {
61
62
63
64
65 public CIMNode() {
66 super(CIM);
67 }
68
69 private Node iContent;
70
71 private String iCimVersion, iDtdVersion;
72
73 public void addChild(Node pChild) {
74 this.iContent = pChild;
75 }
76
77
78
79
80 @Override
81 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
82 this.iCimVersion = pAttribs.getValue("CIMVERSION");
83 if (this.iCimVersion == null) {
84 throw new SAXException("CIMVERSION attribute is mandatory for " + getNodeName() + " node!");
85 }
86 this.iDtdVersion = pAttribs.getValue("DTDVERSION");
87 if (this.iDtdVersion == null) {
88 throw new SAXException("DTDVERSION attribute is mandatory for " + getNodeName() + " node!");
89 }
90 this.iContent = null;
91 }
92
93
94
95
96 @Override
97 public void parseData(String pData) {
98 return;
99 }
100
101 @Override
102 public void testChild(String pNodeNameEnum) throws SAXException {
103 if (this.iContent != null) {
104 String msg = "CIM node also has a " + this.iContent.getNodeName() + " child node!";
105 throw new SAXException(msg);
106 }
107 if (pNodeNameEnum == MESSAGE) return;
108 String msg = (pNodeNameEnum == DECLARATION)
109 ? "DECLARATION child node not supported by CIM node!"
110 : pNodeNameEnum + " cannot be a child node of CIM node!";
111 throw new SAXException(msg);
112 }
113
114 @Override
115 public void testCompletness() throws SAXException {
116 if (this.iContent == null) throw new SAXException("CIM node must have a MESSAGE or a DECLARATION child!");
117 }
118
119
120
121
122 @Override
123 public void childParsed(Node pChild) {
124
125 }
126
127
128
129
130
131
132 public String getCimVersion() {
133 return this.iCimVersion;
134 }
135
136
137
138
139
140
141 public String getDtdVersion() {
142 return this.iDtdVersion;
143 }
144
145
146
147
148
149
150 public MessageNode getMessageNode() {
151 return (this.iContent instanceof MessageNode) ? (MessageNode) this.iContent : null;
152 }
153
154
155
156 }