blob: 54e68dfe55a2915cec1e56bb8d9a5364923ae9d6 [file] [log] [blame]
Francesco Furfariec7e1752006-10-02 13:37:04 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
Francesco Furfaric37181b2006-04-04 23:50:50 +00009 *
Francesco Furfariec7e1752006-10-02 13:37:04 +000010 * http://www.apache.org/licenses/LICENSE-2.0
Francesco Furfaric37181b2006-04-04 23:50:50 +000011 *
Francesco Furfariec7e1752006-10-02 13:37:04 +000012 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
Francesco Furfaric37181b2006-04-04 23:50:50 +000018 */
19
20package org.apache.felix.upnp.sample.tv;
21import java.beans.PropertyChangeEvent;
Francesco Furfarif2a67912006-07-17 17:08:02 +000022/*
Karl Paulsd312acc2007-06-18 20:38:33 +000023* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
Francesco Furfarif2a67912006-07-17 17:08:02 +000024*/
Francesco Furfaric37181b2006-04-04 23:50:50 +000025
26public class PowerStateVariable implements UPnPStateVariableDescriptor {
27
28 final private String NAME = "Power";
29 final private Boolean DEFAULT_VALUE = Boolean.FALSE;
30 private UPnPEventNotifier notifier;
31 private Boolean power = Boolean.FALSE;
32
33 public PowerStateVariable(){
34 }
35
36 /* (non-Javadoc)
37 * @see org.osgi.service.upnp.UPnPStateVariable#getName()
38 */
39 public String getName() {
40 return NAME;
41 }
42
43 /* (non-Javadoc)
44 * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
45 */
46 public Class getJavaDataType() {
47 return Boolean.class;
48 }
49
50 /* (non-Javadoc)
51 * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
52 */
53 public String getUPnPDataType() {
54 return TYPE_BOOLEAN;
55 }
56
57 /* (non-Javadoc)
58 * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
59 */
60 public Object getDefaultValue() {
61 return DEFAULT_VALUE;
62 }
63
64 /* (non-Javadoc)
65 * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
66 */
67 public String[] getAllowedValues() {
68 return null;
69 }
70
71 /* (non-Javadoc)
72 * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
73 */
74 public Number getMinimum() {
75 return null;
76 }
77
78 /* (non-Javadoc)
79 * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
80 */
81 public Number getMaximum() {
82 return null;
83 }
84
85 /* (non-Javadoc)
86 * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
87 */
88 public Number getStep() {
89 return null;
90 }
91
92 /* (non-Javadoc)
93 * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
94 */
95 public boolean sendsEvents() {
96 return true;
97 }
98
99 public Boolean getCurrentPower(){
100 return power;
101 }
102
103 public void setPower(Boolean value){
104 if (!value.equals(power)) {
105 Boolean oldValue = power;
106 power = value;
107 if (notifier != null)
108 notifier.propertyChange(new PropertyChangeEvent(this,"Power",oldValue,value));
109 }
110 }
111
112 public void setNotifier(UPnPEventNotifier notifier){
113 this.notifier = notifier;
114 }
115
Francesco Furfaric37181b2006-04-04 23:50:50 +0000116 public Object getValue() {
117 return power;
118 }
119}