1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 package org.iotivity.resourcecontainer.bundle.api;
23 import java.util.HashMap;
27 * Basic BundleResource that should be used as a base class
28 * by a bundle resources. A concrete technology has
29 * to override the setAttribute and getAttribute method
30 * and map the according reads and writes to the technology specific
33 public abstract class BundleResource {
34 protected String m_name, m_uri, m_resourceType, m_address;
36 protected HashMap<String, String> m_attributes;
39 * Initialize the internal attribute structure.
41 protected abstract void initAttributes();
44 * Set the attribute (map to a send command for the according protocol)
45 * @param key name of the attribute to be set
46 * @param value new value of the attribute
48 public abstract void setAttribute(String key, String value);
51 * Retrieve the attribute (map to read command for the according protocol)
52 * @param key name of the attribute to be read
53 * @return Value of the attribute
55 public abstract String getAttribute(String key);
58 * Attribute keys provided through by the bundle resource.
59 * @return Name of attribute keys as string array
61 public String[] getAttributeKeys() {
62 Set<String> keys = m_attributes.keySet();
63 return keys.toArray(new String[keys.size()]);
67 * Setter for the uri property
68 * @param uri URI of the resource
70 public void setURI(String uri) {
75 * Returns the URI of the resource
78 public String getURI() {
83 * Sets the resource type property
84 * @param resourceType OIC resource type
86 public void setResourceType(String resourceType) {
87 this.m_resourceType = resourceType;
91 * Getter for the resource type
92 * @return OIC resource type
94 public String getResourceType() {
95 return m_resourceType;
99 * Sets the technology specific address information (e.g., ZigBee short or long identifier)
102 public void setAddress(String address) {
103 this.m_address = address;
107 * Returns the technology specific address information
110 public String getAddress() {
115 * Sets the name property of the resource
118 public void setName(String name) {
123 * Returns the name property of the resource
126 public String getName() {