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