Francesco Furfari | ec7e175 | 2006-10-02 13:37:04 +0000 | [diff] [blame] | 1 | /*
|
| 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 Furfari | c37181b | 2006-04-04 23:50:50 +0000 | [diff] [blame] | 9 | *
|
Francesco Furfari | ec7e175 | 2006-10-02 13:37:04 +0000 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0
|
Francesco Furfari | c37181b | 2006-04-04 23:50:50 +0000 | [diff] [blame] | 11 | *
|
Francesco Furfari | ec7e175 | 2006-10-02 13:37:04 +0000 | [diff] [blame] | 12 | * 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 Furfari | c37181b | 2006-04-04 23:50:50 +0000 | [diff] [blame] | 18 | */
|
| 19 |
|
| 20 | package org.apache.felix.upnp.sample.tv;
|
| 21 |
|
| 22 | import java.util.Dictionary;
|
| 23 | import java.util.Hashtable;
|
| 24 |
|
| 25 | import org.osgi.service.upnp.UPnPAction;
|
| 26 | import org.osgi.service.upnp.UPnPStateVariable;
|
Francesco Furfari | f2a6791 | 2006-07-17 17:08:02 +0000 | [diff] [blame] | 27 | /*
|
Karl Pauls | d312acc | 2007-06-18 20:38:33 +0000 | [diff] [blame^] | 28 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
|
Francesco Furfari | f2a6791 | 2006-07-17 17:08:02 +0000 | [diff] [blame] | 29 | */
|
Francesco Furfari | c37181b | 2006-04-04 23:50:50 +0000 | [diff] [blame] | 30 |
|
| 31 | public class SetPowerAction implements UPnPAction {
|
| 32 |
|
| 33 | final private String NAME = "SetPower";
|
| 34 | final private String NEW_TIME_VALUE = "Power";
|
| 35 | final private String NEW_RESULT_VALUE = "Result";
|
| 36 | final private String[] IN_ARG_NAMES = new String[]{NEW_TIME_VALUE};
|
| 37 | final private String[] OUT_ARG_NAMES = new String[]{NEW_RESULT_VALUE};
|
| 38 | private PowerStateVariable power;
|
| 39 | private ResultStateVariable result;
|
| 40 |
|
| 41 |
|
| 42 | public SetPowerAction(PowerStateVariable power,ResultStateVariable result){
|
| 43 | this.power = power;
|
| 44 | this.result=result;
|
| 45 | }
|
| 46 |
|
| 47 | /* (non-Javadoc)
|
| 48 | * @see org.osgi.service.upnp.UPnPAction#getName()
|
| 49 | */
|
| 50 | public String getName() {
|
| 51 | return NAME;
|
| 52 | }
|
| 53 |
|
| 54 | /* (non-Javadoc)
|
| 55 | * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
|
| 56 | */
|
| 57 | public String getReturnArgumentName() {
|
| 58 | return "Result";
|
| 59 | }
|
| 60 |
|
| 61 | /* (non-Javadoc)
|
| 62 | * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
|
| 63 | */
|
| 64 | public String[] getInputArgumentNames() {
|
| 65 | return IN_ARG_NAMES;
|
| 66 | }
|
| 67 |
|
| 68 | /* (non-Javadoc)
|
| 69 | * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
|
| 70 | */
|
| 71 | public String[] getOutputArgumentNames() {
|
| 72 | return OUT_ARG_NAMES;
|
| 73 | }
|
| 74 |
|
| 75 | /* (non-Javadoc)
|
| 76 | * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
|
| 77 | */
|
| 78 | public UPnPStateVariable getStateVariable(String argumentName) {
|
| 79 | if (argumentName.equals("Power")) return power;
|
| 80 | else if (argumentName.equals("Result")) return result;
|
| 81 | else return null;
|
| 82 | }
|
| 83 |
|
| 84 | /* (non-Javadoc)
|
| 85 | * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
|
| 86 | */
|
| 87 | public Dictionary invoke(Dictionary args) throws Exception {
|
| 88 | Boolean value = (Boolean) args.get(NEW_TIME_VALUE);
|
| 89 | power.setPower(value);
|
| 90 | Hashtable result = new Hashtable();
|
| 91 | result.put(NEW_RESULT_VALUE,Boolean.TRUE);
|
| 92 | return result;
|
| 93 | }
|
| 94 | }
|