2 * Copyright (c) 2010-2020 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.hpprinter.internal.api;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.core.thing.Thing;
20 import org.w3c.dom.Document;
21 import org.w3c.dom.Element;
22 import org.w3c.dom.Node;
23 import org.w3c.dom.NodeList;
26 * The {@link HPProperties} is responsible for returning the
27 * reading of data from the HP Embedded Web Server.
29 * @author Martin van Wingerden - Initial contribution
32 public class HPProperties {
33 public static final String ENDPOINT = "/DevMgmt/ProductConfigDyn.xml";
34 private final Map<String, String> properties = new HashMap<>();
36 public HPProperties(Document document) {
37 NodeList nodes = document.getDocumentElement().getElementsByTagName("prdcfgdyn:ProductInformation");
39 for (int i = 0; i < nodes.getLength(); i++) {
40 Element element = (Element) nodes.item(i);
41 properties.put(Thing.PROPERTY_SERIAL_NUMBER,
42 element.getElementsByTagName("dd:SerialNumber").item(0).getTextContent());
43 properties.put(Thing.PROPERTY_MODEL_ID,
44 element.getElementsByTagName("dd:ProductNumber").item(0).getTextContent());
45 Node firmwareDate = element.getElementsByTagName("dd:Version").item(0);
46 properties.put(Thing.PROPERTY_FIRMWARE_VERSION, firmwareDate.getChildNodes().item(0).getTextContent());
50 public Map<String, String> getProperties() {