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