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.sentrysoftware.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
49
50 import org.sentrysoftware.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
51 import org.xml.sax.Attributes;
52 import org.xml.sax.SAXException;
53
54
55
56
57
58
59
60
61
62 public class CIMNode extends Node implements NonVolatileIf {
63
64
65
66
67 public CIMNode() {
68 super(CIM);
69 }
70
71 private Node iContent;
72
73 private String iCimVersion, iDtdVersion;
74
75 public void addChild(Node pChild) {
76 this.iContent = pChild;
77 }
78
79
80
81
82 @Override
83 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
84 this.iCimVersion = pAttribs.getValue("CIMVERSION");
85 if (this.iCimVersion == null) { throw new SAXException(
86 "CIMVERSION attribute is mandatory for " + getNodeName() + " node!"); }
87 this.iDtdVersion = pAttribs.getValue("DTDVERSION");
88 if (this.iDtdVersion == null) { throw new SAXException(
89 "DTDVERSION attribute is mandatory for " + getNodeName() + " node!"); }
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) ? "DECLARATION child node not supported by CIM node!"
109 : pNodeNameEnum + " cannot be a child node of CIM node!";
110 throw new SAXException(msg);
111 }
112
113 @Override
114 public void testCompletness() throws SAXException {
115 if (this.iContent == null) throw new SAXException(
116 "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
157 }