View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  package example.localservice;
16  
17  import org.fourthline.cling.binding.annotations.*;
18  import java.net.URI;
19  import java.net.URL;
20  import java.util.List;
21  import org.fourthline.cling.model.types.csv.CSV;        // DOC:INC1
22  import org.fourthline.cling.model.types.csv.CSVInteger;
23  
24  @UpnpService(
25          serviceId = @UpnpServiceId("MyService"),
26          serviceType = @UpnpServiceType(namespace = "mydomain", value = "MyService"),
27          stringConvertibleTypes = MyStringConvertible.class
28  )
29  public class MyServiceWithStringConvertibles {
30  
31      @UpnpStateVariable
32      private URL myURL;
33  
34      @UpnpStateVariable
35      private URI myURI;
36  
37      @UpnpStateVariable(datatype = "string")
38      private List<Integer> myNumbers;
39  
40      @UpnpStateVariable
41      private MyStringConvertible myStringConvertible;
42  
43      @UpnpAction(out = @UpnpOutputArgument(name = "Out"))
44      public URL getMyURL() {
45          return myURL;
46      }
47  
48      @UpnpAction
49      public void setMyURL(@UpnpInputArgument(name = "In") URL myURL) {
50          this.myURL = myURL;
51      }
52  
53      @UpnpAction(out = @UpnpOutputArgument(name = "Out"))
54      public URI getMyURI() {
55          return myURI;
56      }
57  
58      @UpnpAction
59      public void setMyURI(@UpnpInputArgument(name = "In") URI myURI) {
60          this.myURI = myURI;
61      }
62  
63      @UpnpAction(out = @UpnpOutputArgument(name = "Out"))
64      public CSV<Integer> getMyNumbers() {
65          CSVInteger wrapper = new CSVInteger();
66          if (myNumbers != null)
67              wrapper.addAll(myNumbers);
68          return wrapper;
69      }
70  
71      @UpnpAction
72      public void setMyNumbers(
73              @UpnpInputArgument(name = "In")
74              CSVInteger myNumbers
75      ) {
76          this.myNumbers = myNumbers;
77      }
78  
79      @UpnpAction(out = @UpnpOutputArgument(name = "Out"))
80      public MyStringConvertible getMyStringConvertible() {
81          return myStringConvertible;
82      }
83  
84      @UpnpAction
85      public void setMyStringConvertible(
86              @UpnpInputArgument(name = "In")
87              MyStringConvertible myStringConvertible
88      ) {
89          this.myStringConvertible = myStringConvertible;
90      }
91  } // DOC:INC1