@Test public void testGetValueString() { Object data; data = "Hello World"; assertEquals("Hello World", ShellUtil.getValueString(data)); data = new int[] { 1, 2, 3, 5, 7, 9 }; assertEquals("[1, 2, 3, 5, 7, 9]", ShellUtil.getValueString(data)); data = new short[] { 1, 2, 3, 5, 7, 9 }; assertEquals("[1, 2, 3, 5, 7, 9]", ShellUtil.getValueString(data)); data = new long[] { 1, 2, 3, 5, 7, 9 }; assertEquals("[1, 2, 3, 5, 7, 9]", ShellUtil.getValueString(data)); data = new byte[] { 1, 2, 3, 5, 7, 9 }; assertEquals("[1, 2, 3, 5, 7, 9]", ShellUtil.getValueString(data)); data = new float[] { 1, 2, 3, 5, 7, 9 }; assertEquals("[1.0, 2.0, 3.0, 5.0, 7.0, 9.0]", ShellUtil.getValueString(data)); data = new double[] { 1, 2, 3, 5, 7, 9 }; assertEquals("[1.0, 2.0, 3.0, 5.0, 7.0, 9.0]", ShellUtil.getValueString(data)); data = new boolean[] { true, true, false }; assertEquals("[true, true, false]", ShellUtil.getValueString(data)); data = new char[] { 'a', 'c', 'e' }; assertEquals("[a, c, e]", ShellUtil.getValueString(data)); data = new Object[] { new int[] { 1, 2, 3, 5, 8 }, new char[] { 'h', 'e', 'l', 'l', 'o' }, "World" }; assertEquals("[[1, 2, 3, 5, 8], [h, e, l, l, o], World]", ShellUtil.getValueString(data)); data = Arrays.asList(5, 10, 15, 25); assertEquals("[5, 10, 15, 25]", ShellUtil.getValueString(data)); data = new LinkedHashSet<>(Arrays.asList(5, 10, 15, 25)); assertEquals("[5, 10, 15, 25]", ShellUtil.getValueString(data)); data = new int[][] { { 1, 2, 3 }, { 5, 7, 9 } }; assertEquals("[[1, 2, 3], [5, 7, 9]]", ShellUtil.getValueString(data)); }
public static String getValueString(Object obj) { if (obj == null) { return "null"; } else if (obj instanceof boolean[]) { return Arrays.toString((boolean[]) obj); } else if (obj instanceof byte[]) { return Arrays.toString((byte[]) obj); } else if (obj instanceof char[]) { return Arrays.toString((char[]) obj); } else if (obj instanceof double[]) { return Arrays.toString((double[]) obj); } else if (obj instanceof float[]) { return Arrays.toString((float[]) obj); } else if (obj instanceof int[]) { return Arrays.toString((int[]) obj); } else if (obj instanceof long[]) { return Arrays.toString((long[]) obj); } else if (obj instanceof short[]) { return Arrays.toString((short[]) obj); } else if (obj instanceof Collection<?>) { Object[] array = ((Collection<?>) obj).toArray(); return getValueString(array); } else if (obj.getClass().isArray()) { Object[] array = (Object[]) obj; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(getValueString(array[i])); } sb.append("]"); return sb.toString(); } else { return obj.toString(); } }
ShellUtil { public static String getValueString(Object obj) { if (obj == null) { return "null"; } else if (obj instanceof boolean[]) { return Arrays.toString((boolean[]) obj); } else if (obj instanceof byte[]) { return Arrays.toString((byte[]) obj); } else if (obj instanceof char[]) { return Arrays.toString((char[]) obj); } else if (obj instanceof double[]) { return Arrays.toString((double[]) obj); } else if (obj instanceof float[]) { return Arrays.toString((float[]) obj); } else if (obj instanceof int[]) { return Arrays.toString((int[]) obj); } else if (obj instanceof long[]) { return Arrays.toString((long[]) obj); } else if (obj instanceof short[]) { return Arrays.toString((short[]) obj); } else if (obj instanceof Collection<?>) { Object[] array = ((Collection<?>) obj).toArray(); return getValueString(array); } else if (obj.getClass().isArray()) { Object[] array = (Object[]) obj; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(getValueString(array[i])); } sb.append("]"); return sb.toString(); } else { return obj.toString(); } } }
ShellUtil { public static String getValueString(Object obj) { if (obj == null) { return "null"; } else if (obj instanceof boolean[]) { return Arrays.toString((boolean[]) obj); } else if (obj instanceof byte[]) { return Arrays.toString((byte[]) obj); } else if (obj instanceof char[]) { return Arrays.toString((char[]) obj); } else if (obj instanceof double[]) { return Arrays.toString((double[]) obj); } else if (obj instanceof float[]) { return Arrays.toString((float[]) obj); } else if (obj instanceof int[]) { return Arrays.toString((int[]) obj); } else if (obj instanceof long[]) { return Arrays.toString((long[]) obj); } else if (obj instanceof short[]) { return Arrays.toString((short[]) obj); } else if (obj instanceof Collection<?>) { Object[] array = ((Collection<?>) obj).toArray(); return getValueString(array); } else if (obj.getClass().isArray()) { Object[] array = (Object[]) obj; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(getValueString(array[i])); } sb.append("]"); return sb.toString(); } else { return obj.toString(); } }  }
ShellUtil { public static String getValueString(Object obj) { if (obj == null) { return "null"; } else if (obj instanceof boolean[]) { return Arrays.toString((boolean[]) obj); } else if (obj instanceof byte[]) { return Arrays.toString((byte[]) obj); } else if (obj instanceof char[]) { return Arrays.toString((char[]) obj); } else if (obj instanceof double[]) { return Arrays.toString((double[]) obj); } else if (obj instanceof float[]) { return Arrays.toString((float[]) obj); } else if (obj instanceof int[]) { return Arrays.toString((int[]) obj); } else if (obj instanceof long[]) { return Arrays.toString((long[]) obj); } else if (obj instanceof short[]) { return Arrays.toString((short[]) obj); } else if (obj instanceof Collection<?>) { Object[] array = ((Collection<?>) obj).toArray(); return getValueString(array); } else if (obj.getClass().isArray()) { Object[] array = (Object[]) obj; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(getValueString(array[i])); } sb.append("]"); return sb.toString(); } else { return obj.toString(); } }  static String getBundleName(Bundle bundle); static String getUnderlineString(String s); static String getValueString(Object obj); static boolean isASystemBundle(BundleContext bundleContext, Bundle bundle); static boolean getBoolean(Session session, String name); static void logException(Session session, Throwable t); static String getCurrentUserName(); static Map<String, String> getKsColorMap(Session session); static Map<String, String> getColorMap(Session session, String name, String def); }
ShellUtil { public static String getValueString(Object obj) { if (obj == null) { return "null"; } else if (obj instanceof boolean[]) { return Arrays.toString((boolean[]) obj); } else if (obj instanceof byte[]) { return Arrays.toString((byte[]) obj); } else if (obj instanceof char[]) { return Arrays.toString((char[]) obj); } else if (obj instanceof double[]) { return Arrays.toString((double[]) obj); } else if (obj instanceof float[]) { return Arrays.toString((float[]) obj); } else if (obj instanceof int[]) { return Arrays.toString((int[]) obj); } else if (obj instanceof long[]) { return Arrays.toString((long[]) obj); } else if (obj instanceof short[]) { return Arrays.toString((short[]) obj); } else if (obj instanceof Collection<?>) { Object[] array = ((Collection<?>) obj).toArray(); return getValueString(array); } else if (obj.getClass().isArray()) { Object[] array = (Object[]) obj; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < array.length; i++) { if (i != 0) { sb.append(", "); } sb.append(getValueString(array[i])); } sb.append("]"); return sb.toString(); } else { return obj.toString(); } }  static String getBundleName(Bundle bundle); static String getUnderlineString(String s); static String getValueString(Object obj); static boolean isASystemBundle(BundleContext bundleContext, Bundle bundle); static boolean getBoolean(Session session, String name); static void logException(Session session, Throwable t); static String getCurrentUserName(); static Map<String, String> getKsColorMap(Session session); static Map<String, String> getColorMap(Session session, String name, String def); static final String DEFAULT_KS_COLORS; }