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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.w3c.dom.Document;
17 import org.w3c.dom.Element;
18 import org.w3c.dom.Node;
19 import org.w3c.dom.NodeList;
22 * The {@link HPScannerStatus} is responsible for handling reading of scanner status data.
24 * @author Stewart Cossey - Initial contribution
27 public class HPFeatures {
28 public static final String ENDPOINT = "/DevMgmt/DiscoveryTree.xml";
30 private final boolean productStatus;
31 private final boolean productUsage;
32 private final boolean scannerStatus;
34 public HPFeatures(Document document) {
35 Element root = (Element) document.getDocumentElement();
37 boolean localProductStatus = false;
38 boolean localProductUsage = false;
39 boolean localScannerStatus = false;
41 for (Node n = root.getFirstChild(); n != null; n = n.getNextSibling()) {
42 if (n instanceof Element) {
43 Element feature = (Element) n;
45 NodeList resourceType = feature.getElementsByTagName("dd:ResourceType");
47 if (resourceType.getLength() > 0) {
48 switch (resourceType.item(0).getTextContent()) {
49 case "ledm:hpLedmProductStatusDyn":
50 localProductStatus = true;
53 case "ledm:hpLedmProductUsageDyn":
54 localProductUsage = true;
57 case "eSCL:eSclManifest":
58 localScannerStatus = true;
65 productStatus = localProductStatus;
66 productUsage = localProductUsage;
67 scannerStatus = localScannerStatus;
70 public boolean getProductStatusSupported() {
74 public boolean getProductUsageSupported() {
78 public boolean getScannerStatusSupported() {