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 ******************************************************************/
21 * @file Capability.java
23 * @brief 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
36 * of the target resource. The attribute key and value are written in
37 * capability and status variables of Capability instance class,
38 * respectively. After filling the Capability instance, store it to
39 * listOfCapability vector variable of Action instance.
42 public class Capability {
44 * String Tag for Logging
46 private static final String LOG_TAG = "Capability";
48 * Attribute Key of target resource
50 public String capability;
52 * Attribute Value of target resource
57 * This function generates a Capability String.
59 * @return String for a specific Capability.
62 public String toString() {
63 StringBuilder result = new StringBuilder();
64 result.append(capability + "=" + status);
65 return result.toString();
69 * This function parses the Capability String.
71 * @param capabilityString
72 * Capability in String format.
74 * @return Capability class.
77 public static Capability toCapability(String capabilityString) {
78 StringTokenizer tokenizer = new StringTokenizer(capabilityString, "=");
79 if (2 != tokenizer.countTokens()) {
80 Log.e(LOG_TAG, "Invalid capability string = " + capabilityString);
84 Capability result = new Capability();
86 result.capability = tokenizer.nextToken();
87 result.status = tokenizer.nextToken();