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.javax.cim.CIMClassProperty;
49 import org.metricshub.wbem.javax.cim.CIMProperty;
50 import org.metricshub.wbem.javax.cim.CIMQualifier;
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 abstract class AbstractPropertyNode extends Node implements TypedIf, ValueIf {
60
61 private String iName;
62
63 private String iClassOrigin;
64
65 private boolean iPropagated;
66
67 protected QualifiedNodeHandler iQualiHandler;
68
69
70
71
72
73
74 public AbstractPropertyNode(String pNameEnum) {
75 super(pNameEnum);
76 }
77
78
79
80
81
82
83 protected abstract boolean hasValueNode();
84
85 protected abstract void childValueNodeParsed(Node pChild) throws SAXException;
86
87 protected abstract void specificInit(Attributes pAttribs, SAXSession pSession) throws SAXException;
88
89 protected abstract String getChildValueNodeNameEnum();
90
91 @Override
92 public void init(Attributes pAttribs, SAXSession pSession) throws SAXException {
93 this.iQualiHandler = QualifiedNodeHandler.init(this.iQualiHandler);
94 this.iName = getCIMName(pAttribs);
95 this.iClassOrigin = getClassOrigin(pAttribs);
96 this.iPropagated = getPropagated(pAttribs);
97 specificInit(pAttribs, pSession);
98 }
99
100 @Override
101 public void testChild(String pNodeNameEnum) throws SAXException {
102 String valueNodeNameEnum = getChildValueNodeNameEnum();
103 if (pNodeNameEnum == valueNodeNameEnum) {
104 if (hasValueNode()) throw new SAXException(
105 getNodeName() + " node can have only one " + valueNodeNameEnum + " child node!"
106 );
107 } else if (pNodeNameEnum != QUALIFIER) throw new SAXException(
108 getNodeName() + " node cannot have " + pNodeNameEnum + " child node!"
109 );
110 }
111
112
113
114
115 @Override
116 public void parseData(String pData) {
117
118 }
119
120 @Override
121 public void childParsed(Node pChild) throws SAXException {
122 if (!this.iQualiHandler.addQualifierNode(pChild)) {
123 childValueNodeParsed(pChild);
124 }
125 }
126
127 protected CIMQualifier<?>[] getQualis() {
128
129 return this.iQualiHandler.getQualis(true);
130 }
131
132
133
134
135
136
137 public CIMProperty<Object> getCIMProperty() {
138
139
140
141
142 return new CIMProperty<Object>(
143 this.iName,
144 getType(),
145 getValue(),
146 this.iQualiHandler.isKeyed(),
147 this.iPropagated,
148 this.iClassOrigin
149 );
150 }
151
152
153
154
155
156
157 public CIMClassProperty<Object> getCIMClassProperty() {
158
159
160
161
162
163 return new CIMClassProperty<Object>(
164 this.iName,
165 getType(),
166 getValue(),
167 getQualis(),
168 this.iQualiHandler.isKeyed(),
169 this.iPropagated,
170 this.iClassOrigin
171 );
172 }
173 }