]> git.basschouten.com Git - openhab-addons.git/blob
d803d48f0b74ed9135d2054a5881105431f28faa
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.hpprinter.internal.api;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.w3c.dom.Document;
17 import org.w3c.dom.Element;
18
19 /**
20  * The {@link HPScannerStatusFeatures} is responsible for determining what type of printer scanner
21  * status features the Web Interface supports.
22  *
23  * @author Stewart Cossey - Initial contribution
24  */
25 @NonNullByDefault
26 public class HPScannerStatusFeatures {
27     public static final String ENDPOINT = "/eSCL/ScannerStatus";
28
29     private final boolean hasStatus;
30     private final boolean hasAdf;
31
32     public HPScannerStatusFeatures(Document document) {
33         boolean localHasStatus = false;
34         boolean localHasAdf = false;
35
36         Element nodes = (Element) document.getDocumentElement();
37         localHasStatus = (nodes.getElementsByTagName("pwg:State").getLength() > 0);
38         localHasAdf = (nodes.getElementsByTagName("scan:AdfState").getLength() > 0);
39
40         hasStatus = localHasStatus;
41         hasAdf = localHasAdf;
42     }
43
44     public boolean hasStatus() {
45         return hasStatus;
46     }
47
48     public boolean hasAdf() {
49         return hasAdf;
50     }
51 }