2 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package oic.simulator.clientcontroller.utils;
19 import java.util.ArrayList;
20 import java.util.HashSet;
21 import java.util.Iterator;
22 import java.util.List;
25 import org.oic.simulator.SimulatorException;
28 * This class has common utility methods.
30 public class Utility {
31 public static List<String> convertSetToList(Set<String> typeSet) {
32 if (null == typeSet) {
35 List<String> list = new ArrayList<String>();
36 Iterator<String> typeItr = typeSet.iterator();
37 while (typeItr.hasNext()) {
38 list.add(typeItr.next());
43 public static String getObservableInString(boolean observable) {
51 public static String[] convertListToString(List<String> valueList) {
53 if (null != valueList && valueList.size() > 0) {
54 strArr = valueList.toArray(new String[1]);
56 strArr = new String[1];
61 public static Set<String> splitStringByComma(String text) {
62 Set<String> tokenSet = null;
64 String[] token = text.split(",");
66 tokenSet = new HashSet<String>();
67 for (String tok : token) {
69 if (tok.length() > 0) {
78 public static String getSimulatorErrorString(Exception e, String info) {
83 if (e instanceof SimulatorException) {
84 SimulatorException simEx = (SimulatorException) e;
85 detail = simEx.message() + "\n";
86 detail += "Exception Type: " + simEx.getClass().getSimpleName()
88 detail += "Error code: " + simEx.code().toString();
91 detail += "Exception Type: " + e.getClass().getSimpleName() + "\n";
92 detail += "Message: " + e.getMessage();