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  
16  package example.localservice;
17  
18  import org.fourthline.cling.binding.AllowedValueProvider;
19  import org.fourthline.cling.binding.annotations.UpnpAction;
20  import org.fourthline.cling.binding.annotations.UpnpInputArgument;
21  import org.fourthline.cling.binding.annotations.UpnpOutputArgument;
22  import org.fourthline.cling.binding.annotations.UpnpService;
23  import org.fourthline.cling.binding.annotations.UpnpServiceId;
24  import org.fourthline.cling.binding.annotations.UpnpServiceType;
25  import org.fourthline.cling.binding.annotations.UpnpStateVariable;
26  
27  @UpnpService(
28          serviceId = @UpnpServiceId("MyService"),
29          serviceType = @UpnpServiceType(namespace = "mydomain", value = "MyService")
30  )
31  public class MyServiceWithAllowedValueProvider {
32  
33      // DOC:PROVIDER
34      public static class MyAllowedValueProvider implements AllowedValueProvider {
35          @Override
36          public String[] getValues() {
37              return new String[] {"Foo", "Bar", "Baz"};
38          }
39      }
40      // DOC:PROVIDER
41  
42      // DOC:VAR
43      @UpnpStateVariable(
44          allowedValueProvider= MyAllowedValueProvider.class
45      )
46      private String restricted;
47      // DOC:VAR
48  
49      @UpnpAction(out = @UpnpOutputArgument(name = "Out"))
50      public String getRestricted() {
51          return restricted;
52      }
53  
54      @UpnpAction
55      public void setRestricted(@UpnpInputArgument(name = "In") String restricted) {
56          this.restricted = restricted;
57      }
58  }
59