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