2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.ecovacs.internal.api.impl.dto.response.deviceapi.xml;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.ecovacs.internal.api.model.MoppingWaterAmount;
17 import org.openhab.binding.ecovacs.internal.api.util.DataParsingException;
18 import org.openhab.binding.ecovacs.internal.api.util.XPathUtils;
19 import org.w3c.dom.Node;
22 * @author Danny Baumann - Initial contribution
25 public class WaterSystemInfo {
27 * @return Whether water system is present
29 public static boolean parseWaterBoxInfo(String xml) throws DataParsingException {
30 Node node = XPathUtils.getFirstXPathMatch(xml, "//@on");
31 return Integer.valueOf(node.getNodeValue()) != 0;
34 public static MoppingWaterAmount parseWaterPermeabilityInfo(String xml) throws DataParsingException {
35 Node node = XPathUtils.getFirstXPathMatch(xml, "//@v");
37 return MoppingWaterAmount.fromApiValue(Integer.valueOf(node.getNodeValue()));
38 } catch (NumberFormatException e) {
39 throw new DataParsingException(e);