]> git.basschouten.com Git - openhab-addons.git/blob
6835668fa6866f887810c6bb85b28d9553ddb93e
[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.ihc.internal.ws.datatypes;
14
15 import java.io.IOException;
16
17 import javax.xml.xpath.XPathExpressionException;
18
19 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
20
21 /**
22  * Class for WSNumberOfSegments complex type.
23  *
24  * @author Pauli Anttila - Initial contribution
25  */
26 public class WSNumberOfSegments {
27
28     private int segments;
29
30     public WSNumberOfSegments() {
31     }
32
33     public WSNumberOfSegments(int segments) {
34         this.segments = segments;
35     }
36
37     /**
38      * Gets the number of segments.
39      *
40      * @return segmentation size
41      */
42     public int getNumberOfSegments() {
43         return segments;
44     }
45
46     /**
47      * Sets the number of segmentations.
48      *
49      * @param value
50      */
51     public void setNumberOfSegments(int segments) {
52         this.segments = segments;
53     }
54
55     public WSNumberOfSegments parseXMLData(String data) throws IhcExecption {
56         try {
57             String value = XPathUtils.parseXMLValue(data,
58                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getIHCProjectNumberOfSegments1");
59             setNumberOfSegments(Integer.parseInt(value));
60             return this;
61         } catch (IOException | XPathExpressionException | NumberFormatException e) {
62             throw new IhcExecption("Error occured during XML data parsing", e);
63         }
64     }
65 }