Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ClientControllerPlugin / src / oic / simulator / clientcontroller / utils / Utility.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package oic.simulator.clientcontroller.utils;
18
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22 import java.util.Set;
23
24 /**
25  * This class has common utility methods.
26  */
27 public class Utility {
28     public static List<String> convertSetToList(Set<String> typeSet) {
29         if (null == typeSet) {
30             return null;
31         }
32         List<String> list = new ArrayList<String>();
33         Iterator<String> typeItr = typeSet.iterator();
34         while (typeItr.hasNext()) {
35             list.add(typeItr.next());
36         }
37         return list;
38     }
39
40     public static String getObservableInString(boolean observable) {
41         if (observable) {
42             return Constants.YES;
43         } else {
44             return Constants.NO;
45         }
46     }
47
48     public static String[] convertListToString(List<String> valueList) {
49         String[] strArr;
50         if (null != valueList && valueList.size() > 0) {
51             strArr = valueList.toArray(new String[1]);
52         } else {
53             strArr = new String[1];
54         }
55         return strArr;
56     }
57
58     /*
59      * public static List<Object> converArrayToList(int[] arr) { if(null == arr
60      * || arr.length < 1) { return null; } List<Object> valueList = new
61      * ArrayList<Object>(); for(Object val:arr) { valueList.add(val); } return
62      * valueList; }
63      * 
64      * public static List<Object> converArrayToList(double[] arr) { if(null ==
65      * arr || arr.length < 1) { return null; } List<Object> valueList = new
66      * ArrayList<Object>(); for(Object val:arr) { valueList.add(val); } return
67      * valueList; }
68      * 
69      * public static List<Object> converArrayToList(boolean[] arr) { if(null ==
70      * arr || arr.length < 1) { return null; } List<Object> valueList = new
71      * ArrayList<Object>(); for(Object val:arr) { valueList.add(val); } return
72      * valueList; }
73      * 
74      * public static List<Object> converArrayToList(String[] arr) { if(null ==
75      * arr || arr.length < 1) { return null; } List<Object> valueList = new
76      * ArrayList<Object>(); for(Object val:arr) { valueList.add(val); } return
77      * valueList; }
78      */
79 }