added Clock and BinaryLight UPnP examples

git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@399191 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.upnp.sample.binaryLight/src/main/java/org/apache/felix/upnp/sample/binaryLight/PowerSwitchService.java b/org.apache.felix.upnp.sample.binaryLight/src/main/java/org/apache/felix/upnp/sample/binaryLight/PowerSwitchService.java
new file mode 100644
index 0000000..1d0989f
--- /dev/null
+++ b/org.apache.felix.upnp.sample.binaryLight/src/main/java/org/apache/felix/upnp/sample/binaryLight/PowerSwitchService.java
@@ -0,0 +1,111 @@
+/*

+ *   Copyright 2006 The Apache Software Foundation

+ *

+ *   Licensed under the Apache License, Version 2.0 (the "License");

+ *   you may not use this file except in compliance with the License.

+ *   You may obtain a copy of the License at

+ *

+ *       http://www.apache.org/licenses/LICENSE-2.0

+ *

+ *   Unless required by applicable law or agreed to in writing, software

+ *   distributed under the License is distributed on an "AS IS" BASIS,

+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ *   See the License for the specific language governing permissions and

+ *   limitations under the License.

+ *

+ */

+

+

+

+package org.apache.felix.upnp.sample.binaryLight;

+

+import java.util.HashMap;

+

+import org.osgi.service.upnp.UPnPAction;

+import org.osgi.service.upnp.UPnPService;

+import org.osgi.service.upnp.UPnPStateVariable;

+

+/* 

+* @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>

+*/

+

+public class PowerSwitchService implements UPnPService{

+	

+	final private String SERVICE_ID = "urn:upnp-org:serviceId:SwitchPower:1";

+	final private String SERVICE_TYPE = "urn:schemas-upnp-org:service:SwitchPower:1";

+	final private String VERSION ="1";

+

+	private LightModel model;

+	private UPnPStateVariable status,target;

+	private UPnPStateVariable[] states;

+	private HashMap actions = new HashMap();

+	

+	

+	public PowerSwitchService(LightModel model){

+		this.model = model;

+		status = new StatusStateVariable();

+		target = new TargetStateVariable();

+		this.states = new UPnPStateVariable[]{status,target};

+		

+		UPnPAction setTarget = new SetTargetAction(model,target);

+		UPnPAction getTarget = new GetTargetAction(model,target);

+		UPnPAction getStatus = new GetStatusAction(model,status);

+		actions.put(setTarget.getName(),setTarget);

+		actions.put(getTarget.getName(),getTarget);

+		actions.put(getStatus.getName(),getStatus);

+		

+	}

+

+	/* (non-Javadoc)

+	 * @see org.osgi.service.upnp.UPnPService#getId()

+	 */

+	public String getId() {

+		return SERVICE_ID;

+	}

+

+	/* (non-Javadoc)

+	 * @see org.osgi.service.upnp.UPnPService#getType()

+	 */

+	public String getType() {

+		return SERVICE_TYPE;

+	}

+

+	/* (non-Javadoc)

+	 * @see org.osgi.service.upnp.UPnPService#getVersion()

+	 */

+	public String getVersion() {

+		return VERSION;

+	}

+

+	/* (non-Javadoc)

+	 * @see org.osgi.service.upnp.UPnPService#getAction(java.lang.String)

+	 */

+	public UPnPAction getAction(String name) {

+		return (UPnPAction)actions.get(name);

+	}

+

+	/* (non-Javadoc)

+	 * @see org.osgi.service.upnp.UPnPService#getActions()

+	 */

+	public UPnPAction[] getActions() {

+		return (UPnPAction[])(actions.values()).toArray(new UPnPAction[]{});

+	}

+

+	/* (non-Javadoc)

+	 * @see org.osgi.service.upnp.UPnPService#getStateVariables()

+	 */

+	public UPnPStateVariable[] getStateVariables() {

+		return states;

+	}

+

+	/* (non-Javadoc)

+	 * @see org.osgi.service.upnp.UPnPService#getStateVariable(java.lang.String)

+	 */

+	public UPnPStateVariable getStateVariable(String name) {

+		if (name.equals("Status"))

+			return status;

+		else if (name.equals("Target"))

+			return target;

+		else return null;

+	}

+}