blob: f2f4abb4c48cbfd8485b2d0ffe15022cf526d130 [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 Furfarid1072b52006-05-03 07:44:48 +00009 *
Francesco Furfariec7e1752006-10-02 13:37:04 +000010 * http://www.apache.org/licenses/LICENSE-2.0
Francesco Furfarid1072b52006-05-03 07:44:48 +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 Furfarid1072b52006-05-03 07:44:48 +000018 */
Francesco Furfariec7e1752006-10-02 13:37:04 +000019
Francesco Furfarid1072b52006-05-03 07:44:48 +000020package org.apache.felix.upnp.sample.clock;
21
22import java.util.Dictionary;
23import java.util.Hashtable;
24
25import org.osgi.service.upnp.UPnPAction;
26import org.osgi.service.upnp.UPnPStateVariable;
27
28/*
Karl Paulsd312acc2007-06-18 20:38:33 +000029* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
Francesco Furfarid1072b52006-05-03 07:44:48 +000030*/
31
32public class GetTimeAction implements UPnPAction {
33
34 final private String NAME = "GetTime";
35 final private String RESULT_STATUS = "CurrentTime";
36 final private String[] OUT_ARG_NAMES = new String[]{RESULT_STATUS};
37 private TimeStateVariable time;
38
39
40 public GetTimeAction(TimeStateVariable time){
41 this.time = time;
42 }
43
44 /* (non-Javadoc)
45 * @see org.osgi.service.upnp.UPnPAction#getName()
46 */
47 public String getName() {
48 return NAME;
49 }
50
51 /* (non-Javadoc)
52 * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
53 */
54 public String getReturnArgumentName() {
55 return null;
56 }
57
58 /* (non-Javadoc)
59 * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
60 */
61 public String[] getInputArgumentNames() {
62
63 return null;
64 }
65
66 /* (non-Javadoc)
67 * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
68 */
69 public String[] getOutputArgumentNames() {
70 return OUT_ARG_NAMES;
71 }
72
73 /* (non-Javadoc)
74 * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
75 */
76 public UPnPStateVariable getStateVariable(String argumentName) {
77 return time;
78 }
79
80 /* (non-Javadoc)
81 * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
82 */
83 public Dictionary invoke(Dictionary args) throws Exception {
84 String value = time.getCurrentTime();
85 Hashtable result = new Hashtable();
86 result.put(RESULT_STATUS,value);
87 return result;
88 }
89}