1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.node;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
47 import org.xml.sax.Attributes;
48 import org.xml.sax.SAXException;
49
50
51
52
53
54
55
56
57
58
59 public class MessageNode extends Node implements NonVolatileIf {
60 private String iID;
61
62 private String iProtocolVersion;
63
64 private AbstractMessageNode iAbstractMsgNode;
65
66
67
68
69 public MessageNode() {
70 super(MESSAGE);
71 }
72
73 public void addChild(Node pChild) {
74 this.iAbstractMsgNode = (AbstractMessageNode) pChild;
75 }
76
77
78
79
80 @Override
81 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
82 this.iID = pAttribs.getValue("ID");
83 if (this.iID == null) throw new SAXException("ID attribute is mandatory for MESSAGE node!");
84 this.iProtocolVersion = pAttribs.getValue("PROTOCOLVERSION");
85 if (this.iProtocolVersion == null) throw new SAXException(
86 "PROTOCOLVERSION attribute is mandatory for MESSAGE node!"
87 );
88 this.iAbstractMsgNode = null;
89 }
90
91
92
93
94 @Override
95 public void parseData(String pData) {
96
97 }
98
99 private static final String[] ALLOWED_CHILDREN = {
100 SIMPLEREQ,
101 MULTIREQ,
102 SIMPLERSP,
103 MULTIRSP,
104 SIMPLEEXPREQ,
105 MULTIEXPREQ,
106 SIMPLEEXPRSP,
107 MULTIEXPRSP
108 };
109
110 @Override
111 public void testChild(String pNodeNameEnum) throws SAXException {
112 if (this.iAbstractMsgNode != null) throw new SAXException("MESSAGE node can have only one child node!");
113 for (int i = 0; i < ALLOWED_CHILDREN.length; i++) if (pNodeNameEnum == ALLOWED_CHILDREN[i]) return;
114 throw new SAXException("MESSAGE node cannot have " + pNodeNameEnum + " child node!");
115 }
116
117
118
119
120 @Override
121 public void childParsed(Node pChild) {
122
123 }
124
125 @Override
126 public void testCompletness() throws SAXException {
127 if (this.iAbstractMsgNode == null) throw new SAXException("MESSAGE node must have a child node!");
128 }
129
130
131
132
133
134
135 public AbstractMessageNode getAbstractMessageNode() {
136 return this.iAbstractMsgNode;
137 }
138 }