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.eclipse.jdt.annotation.Nullable;
17 import org.w3c.dom.Document;
18 import org.w3c.dom.Element;
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 HPScannerStatus {
28 public static final String ENDPOINT = "/eSCL/ScannerStatus";
30 private final String status;
31 private final Boolean adfLoaded;
33 public HPScannerStatus(Document document) {
34 String localScannerStatus = "Unknown";
35 Boolean localAdfLoaded = false;
37 Element nodes = (Element) document.getDocumentElement();
39 NodeList state = nodes.getElementsByTagName("pwg:State");
40 if (state.getLength() > 0) {
41 localScannerStatus = state.item(0).getTextContent();
44 NodeList adfState = nodes.getElementsByTagName("scan:AdfState");
45 if (adfState.getLength() > 0) {
46 String adfStatus = adfState.item(0).getTextContent();
47 localAdfLoaded = convertAdfStatus(adfStatus);
50 adfLoaded = localAdfLoaded;
51 status = localScannerStatus;
54 private static Boolean convertAdfStatus(String status) {
55 return "ScannerAdfLoaded".equals(status);
58 public Boolean getAdfLoaded() {
62 public @Nullable String getScannerStatus() {