1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.start;
20
21 import java.util.Collection;
22
23 public final class Utils
24 {
25 public static String join(Object[] arr, String delim)
26 {
27 if (arr == null)
28 {
29 return "";
30 }
31
32 return join(arr,0,arr.length,delim);
33 }
34
35 public static String join(Object[] arr, int start, int end, String delim)
36 {
37 if (arr == null)
38 {
39 return "";
40 }
41 StringBuilder str = new StringBuilder();
42 for (int i = start; i < end; i++)
43 {
44 if (i > start)
45 {
46 str.append(delim);
47 }
48 str.append(arr[i]);
49 }
50 return str.toString();
51 }
52
53 public static String join(Collection<?> objs, String delim)
54 {
55 if (objs == null)
56 {
57 return "";
58 }
59 StringBuilder str = new StringBuilder();
60 boolean needDelim = false;
61 for (Object obj : objs)
62 {
63 if (needDelim)
64 {
65 str.append(delim);
66 }
67 str.append(obj);
68 needDelim = true;
69 }
70 return str.toString();
71 }
72
73
74
75
76
77
78
79
80 public static boolean isBlank(String value)
81 {
82 if (value == null)
83 {
84 return true;
85 }
86 int len = value.length();
87 for (int i = 0; i < len; i++)
88 {
89 int c = value.codePointAt(i);
90 if (!Character.isWhitespace(c))
91 {
92 return false;
93 }
94 }
95 return true;
96 }
97
98
99
100
101
102
103
104
105 public static boolean isNotBlank(String value)
106 {
107 if (value == null)
108 {
109 return false;
110 }
111 int len = value.length();
112 for (int i = 0; i < len; i++)
113 {
114 int c = value.codePointAt(i);
115 if (!Character.isWhitespace(c))
116 {
117 return true;
118 }
119 }
120 return false;
121 }
122 }