blob: cb938c35da93ba39ebb6e2a202210540abafe207 [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;
21import org.osgi.service.upnp.UPnPStateVariable;
22/*
Karl Paulsd312acc2007-06-18 20:38:33 +000023* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
Francesco Furfarid1072b52006-05-03 07:44:48 +000024*/
25
26public class TimeStateVariable implements UPnPStateVariable{
27
28 final private String NAME = "Time";
29 final private String DEFAULT_VALUE = "";
30 private Clock clock;
31
32
33 public TimeStateVariable(){
34 clock = Clock.getInstance();
35 }
36
37 /* (non-Javadoc)
38 * @see org.osgi.service.upnp.UPnPStateVariable#getName()
39 */
40 public String getName() {
41 return NAME;
42 }
43
44 /* (non-Javadoc)
45 * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
46 */
47 public Class getJavaDataType() {
48 return Long.class;
49 }
50
51 /* (non-Javadoc)
52 * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
53 */
54 public String getUPnPDataType() {
55 return TYPE_TIME;
56 }
57
58 /* (non-Javadoc)
59 * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
60 */
61 public Object getDefaultValue() {
62 return DEFAULT_VALUE;
63 }
64
65 /* (non-Javadoc)
66 * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
67 */
68 public String[] getAllowedValues() {
69 return null;
70 }
71
72 /* (non-Javadoc)
73 * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
74 */
75 public Number getMinimum() {
76 return null;
77 }
78
79 /* (non-Javadoc)
80 * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
81 */
82 public Number getMaximum() {
83 return null;
84 }
85
86 /* (non-Javadoc)
87 * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
88 */
89 public Number getStep() {
90 return null;
91 }
92
93 /* (non-Javadoc)
94 * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
95 */
96 public boolean sendsEvents() {
97 return true;
98 }
99
100 public String getCurrentTime(){
101 return clock.getTimeString();
102 }
103
104 public void setCurrentTime(long milliseconds){
105 clock.getCalendar().setTimeInMillis(milliseconds);
106 }
107}