]> git.basschouten.com Git - openhab-addons.git/blob
b26440a9475d5dfe2cc14584e310889cd1facb0c
[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 WSSegmentationSize complex type.
23  *
24  * @author Pauli Anttila - Initial contribution
25  */
26 public class WSSegmentationSize {
27
28     private int size;
29
30     public WSSegmentationSize() {
31     }
32
33     public WSSegmentationSize(int size) {
34         this.size = size;
35     }
36
37     /**
38      * Gets the segmentation size value.
39      *
40      * @return segmentation size
41      */
42     public int getSegmentationSize() {
43         return size;
44     }
45
46     /**
47      * Sets the segmentation size value.
48      *
49      * @param size
50      */
51     public void setSegmentationSize(int size) {
52         this.size = size;
53     }
54
55     public WSSegmentationSize parseXMLData(String data) throws IhcExecption {
56         try {
57             String value = XPathUtils.parseXMLValue(data,
58                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getIHCProjectSegmentationSize1");
59             setSegmentationSize(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 }