comparison flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java @ 5585:4b281c7046c8

Used DOM instead of XPath to extract main values.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Apr 2013 23:27:48 +0200
parents 42692d6868e6
children 966237892c9b
comparison
equal deleted inserted replaced
5584:d35a0bc153fa 5585:4b281c7046c8
129 129
130 List<WQInfoObject> objects = 130 List<WQInfoObject> objects =
131 new ArrayList<WQInfoObject>(num); 131 new ArrayList<WQInfoObject>(num);
132 132
133 for (int i = 0; i < num; i++) { 133 for (int i = 0; i < num; i++) {
134 WQInfoObject obj = buildWQInfoObject(list.item(i)); 134 WQInfoObject obj = buildWQInfoObject((Element)list.item(i));
135 135
136 if (obj != null) { 136 if (obj != null) {
137 objects.add(obj); 137 objects.add(obj);
138 } 138 }
139 } 139 }
174 * 174 *
175 * @param node The node that contains the information. 175 * @param node The node that contains the information.
176 * 176 *
177 * @return a valid WQInfoObject. 177 * @return a valid WQInfoObject.
178 */ 178 */
179 protected WQInfoObject buildWQInfoObject(Node node) { 179 protected static WQInfoObject buildWQInfoObject(Element node) {
180 180
181 // TODO: Replace this expensive XPaths with simpler use of DOM. 181 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
182 String name = XMLUtils.xpathString( 182
183 node, "@name", ArtifactNamespaceContext.INSTANCE); 183 String name = node.getAttributeNS(uri, "name");
184 184 String type = node.getAttributeNS(uri, "type");
185 String type = XMLUtils.xpathString( 185 String value = node.getAttributeNS(uri, "value");
186 node, "@type", ArtifactNamespaceContext.INSTANCE); 186
187 187 if (!name.isEmpty() && !type.isEmpty()) {
188 String value = XMLUtils.xpathString(
189 node, "@value", ArtifactNamespaceContext.INSTANCE);
190
191
192 if (name != null && type != null) {
193 try { 188 try {
194 return new WQInfoObjectImpl( 189 return new WQInfoObjectImpl(
195 name, 190 name,
196 type, 191 type,
197 new Double(value)); 192 new Double(value));

http://dive4elements.wald.intevation.org