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 |
|
| 20 | import java.util.Dictionary;
|
| 21 | import java.util.Hashtable;
|
| 22 |
|
| 23 | import org.osgi.service.upnp.UPnPAction;
|
| 24 | import org.osgi.service.upnp.UPnPStateVariable;
|
Francesco Furfari | f2a6791 | 2006-07-17 17:08:02 +0000 | [diff] [blame^] | 25 | /*
|
| 26 | * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
|
| 27 | */
|
Francesco Furfari | c37181b | 2006-04-04 23:50:50 +0000 | [diff] [blame] | 28 |
|
| 29 | public class GetPowerAction implements UPnPAction {
|
| 30 |
|
| 31 | final private String NAME = "GetPower";
|
| 32 | final private String RESULT_STATUS = "Power";
|
| 33 | final private String[] OUT_ARG_NAMES = new String[]{RESULT_STATUS};
|
| 34 | private PowerStateVariable power;
|
| 35 |
|
| 36 |
|
| 37 | public GetPowerAction(PowerStateVariable power){
|
| 38 | this.power = power;
|
| 39 | }
|
| 40 |
|
| 41 | /* (non-Javadoc)
|
| 42 | * @see org.osgi.service.upnp.UPnPAction#getName()
|
| 43 | */
|
| 44 | public String getName() {
|
| 45 | return NAME;
|
| 46 | }
|
| 47 |
|
| 48 | /* (non-Javadoc)
|
| 49 | * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
|
| 50 | */
|
| 51 | public String getReturnArgumentName() {
|
| 52 | return null;
|
| 53 | }
|
| 54 |
|
| 55 | /* (non-Javadoc)
|
| 56 | * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
|
| 57 | */
|
| 58 | public String[] getInputArgumentNames() {
|
| 59 |
|
| 60 | return null;
|
| 61 | }
|
| 62 |
|
| 63 | /* (non-Javadoc)
|
| 64 | * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
|
| 65 | */
|
| 66 | public String[] getOutputArgumentNames() {
|
| 67 | return OUT_ARG_NAMES;
|
| 68 | }
|
| 69 |
|
| 70 | /* (non-Javadoc)
|
| 71 | * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
|
| 72 | */
|
| 73 | public UPnPStateVariable getStateVariable(String argumentName) {
|
| 74 | return power;
|
| 75 | }
|
| 76 |
|
| 77 | /* (non-Javadoc)
|
| 78 | * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
|
| 79 | */
|
| 80 | public Dictionary invoke(Dictionary args) throws Exception {
|
| 81 | Boolean value = power.getCurrentPower();
|
| 82 | Hashtable result = new Hashtable();
|
| 83 | result.put(RESULT_STATUS,value);
|
| 84 | return result;
|
| 85 | }
|
| 86 | }
|