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