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 java.util.ArrayList;
50 import org.metricshub.wbem.javax.cim.CIMInstance;
51 import org.metricshub.wbem.sblim.cimclient.internal.cimxml.sax.SAXSession;
52 import org.metricshub.wbem.sblim.cimclient.internal.wbem.CIMError;
53 import org.xml.sax.Attributes;
54 import org.xml.sax.SAXException;
55
56
57
58
59
60
61
62
63
64 public class ErrorNode extends Node implements ErrorIf {
65 private int iCode;
66
67 private String iDesc;
68
69 private ArrayList<CIMInstance> iCIMInstAL;
70
71
72
73
74 public ErrorNode() {
75 super(ERROR);
76 }
77
78
79
80
81 @Override
82 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
83 this.iCIMInstAL = null;
84 String code = pAttribs.getValue("CODE");
85 if (code == null) throw new SAXException(getNodeName() + " node must have a CODE attribute!");
86 try {
87 this.iCode = Integer.parseInt(code);
88 } catch (NumberFormatException e) {
89 throw new SAXException("Failed to parse CODE attribute in " + getNodeName() + " node!", e);
90 }
91 this.iDesc = pAttribs.getValue("DESCRIPTION");
92 }
93
94
95
96
97 @Override
98 public void parseData(String pData) {
99
100 }
101
102 @Override
103 public void testChild(String pNodeNameEnum) throws SAXException {
104 if (pNodeNameEnum != INSTANCE) throw new SAXException(
105 getNodeName() + " node cannot have " + pNodeNameEnum + " child node!"
106 );
107 }
108
109 @Override
110 public void childParsed(Node pChild) {
111 if (this.iCIMInstAL == null) this.iCIMInstAL = new ArrayList<CIMInstance>();
112 this.iCIMInstAL.add(((InstanceNode) pChild).getCIMInstance());
113 }
114
115 @Override
116 public void testCompletness() {
117
118 }
119
120 private static final CIMInstance[] EMPTY_IA = new CIMInstance[0];
121
122 public CIMError getCIMError() {
123 if (this.iCIMInstAL != null) {
124 return new CIMError(this.iCode, this.iDesc, this.iCIMInstAL.toArray(EMPTY_IA));
125 }
126 return new CIMError(this.iCode, this.iDesc);
127 }
128 }