2 *******************************************************************
4 * Copyright 2015 Intel Corporation.
6 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 package org.iotivity.base.examples;
24 import org.iotivity.base.OcException;
25 import org.iotivity.base.OcRepresentation;
30 * This class is used by SimpleClient to create an object representation of a remote light resource
31 * and update the values depending on the server response
34 public static final String NAME_KEY = "name";
35 public static final String STATE_KEY = "state";
36 public static final String POWER_KEY = "power";
39 private boolean mState;
48 public void setOcRepresentation(OcRepresentation rep) throws OcException {
49 mName = rep.getValue(NAME_KEY);
50 mState = rep.getValue(Light.STATE_KEY);
51 mPower = rep.getValue(Light.POWER_KEY);
54 public OcRepresentation getOcRepresentation() throws OcException {
55 OcRepresentation rep = new OcRepresentation();
56 rep.setValue(NAME_KEY, mName);
57 rep.setValue(STATE_KEY, mState);
58 rep.setValue(POWER_KEY, mPower);
62 public String getName() {
66 public void setName(String name) {
70 public boolean getState() {
74 public void setState(boolean state) {
78 public int getPower() {
82 public void setPower(int power) {
87 public String toString() {
88 return "\t" + NAME_KEY + ": " + mName +
89 "\n\t" + STATE_KEY + ": " + mState +
90 "\n\t" + POWER_KEY + ": " + mPower;