]> git.basschouten.com Git - openhab-addons.git/blob
3a231b798dfd257f90cab8a05472e68a6445750f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.helios.internal.ws.soap;
14
15 import javax.xml.bind.annotation.XmlElement;
16 import javax.xml.bind.annotation.adapters.XmlAdapter;
17
18 /**
19  * The {@link SOAPDataFieldAdapter} is a helper class that is used to
20  * unmarshal some 'variable' SOAP messages
21  *
22  * @author Karel Goderis - Initial contribution
23  */
24 public class SOAPDataFieldAdapter extends XmlAdapter<SOAPDataFieldAdapter.AdaptedHeliosDataField, SOAPDataField> {
25
26     public static class AdaptedHeliosDataField {
27
28         @XmlElement
29         public String State;
30
31         @XmlElement
32         public String Direction;
33
34         @XmlElement
35         public String Code;
36
37         @XmlElement
38         public String Valid;
39
40         @XmlElement
41         public String Key;
42
43         @XmlElement
44         public String Card;
45     }
46
47     @Override
48     public AdaptedHeliosDataField marshal(SOAPDataField arg0) throws Exception {
49         return null;
50     }
51
52     @Override
53     public SOAPDataField unmarshal(AdaptedHeliosDataField arg0) throws Exception {
54         if (null == arg0) {
55             return null;
56         }
57         if (null != arg0.Card && null != arg0.Valid) {
58             SOAPCardEntered heliosCardEntered = new SOAPCardEntered();
59             heliosCardEntered.setCard(arg0.Card);
60             heliosCardEntered.setValid(arg0.Valid);
61             return heliosCardEntered;
62         }
63         if (null != arg0.Code && null != arg0.Valid) {
64             SOAPCodeEntered heliosCodeEntered = new SOAPCodeEntered();
65             heliosCodeEntered.setCode(arg0.Code);
66             heliosCodeEntered.setValid(arg0.Valid);
67             return heliosCodeEntered;
68         }
69         if (null != arg0.Key) {
70             SOAPKeyPressed heliosKeyPressed = new SOAPKeyPressed();
71             heliosKeyPressed.setKeyCode(arg0.Key);
72             return heliosKeyPressed;
73         }
74         if (null != arg0.State && null != arg0.Direction) {
75             SOAPCallStateChanged heliosCallStateChanged = new SOAPCallStateChanged();
76             heliosCallStateChanged.setState(arg0.State);
77             heliosCallStateChanged.setDirection(arg0.Direction);
78             return heliosCallStateChanged;
79         }
80         if (null != arg0.State) {
81             SOAPDeviceState heliosDeviceState = new SOAPDeviceState();
82             heliosDeviceState.setState(arg0.State);
83             return heliosDeviceState;
84         }
85         return null;
86     }
87 }