1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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 ******************************************************************/
23 * This file contains class which provides functions to specify an attribute key and value
24 * of the target resource.
28 package org.iotivity.service.tm;
30 import java.util.StringTokenizer;
32 import android.util.Log;
35 * This class needs to be created to specify an attribute key and value of the
36 * target resource. The attribute key and value are written in capability and
37 * status variables of Capability instance class, respectively. After filling
38 * the Capability instance, store it to listOfCapability vector variable of
41 public class Capability {
43 * String Tag for Logging
45 private static final String LOG_TAG = "Capability";
47 * Attribute Key of target resource
49 public String capability;
51 * Attribute Value of target resource
56 * This function generates a Capability String.
58 * @return String for a specific Capability.
60 public String toString() {
61 StringBuilder result = new StringBuilder();
62 result.append(capability + "=" + status);
63 return result.toString();
67 * This function parses the Capability String.
69 * @param capabilityString
70 * Capability in String format.
72 * @return Capability class.
74 public static Capability toCapability(String capabilityString) {
75 StringTokenizer tokenizer = new StringTokenizer(capabilityString, "=");
76 if (2 != tokenizer.countTokens()) {
77 Log.e(LOG_TAG, "Invalid capability string = " + capabilityString);
81 Capability result = new Capability();
83 result.capability = tokenizer.nextToken();
84 result.status = tokenizer.nextToken();