1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.hivemind; |
16 |
| |
17 |
| import java.util.Collection; |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| public final class HiveMind |
25 |
| { |
26 |
| |
27 |
| |
28 |
| |
29 |
| public static final String THREAD_EVENT_NOTIFIER_SERVICE = "hivemind.ThreadEventNotifier"; |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| public static final String THREAD_LOCALE_SERVICE = "hivemind.ThreadLocale"; |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| public static final String INTERFACE_SYNTHESIZER_SERVICE = "hivemind.InterfaceSynthesizer"; |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
| |
54 |
| public static final Object INTROSPECTOR_MUTEX = new Object(); |
55 |
| |
56 |
0
| private HiveMind()
|
57 |
| { |
58 |
| |
59 |
| } |
60 |
| |
61 |
8
| public static ApplicationRuntimeException createRegistryShutdownException()
|
62 |
| { |
63 |
8
| return new ApplicationRuntimeException(HiveMindMessages.registryShutdown());
|
64 |
| } |
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
| |
71 |
132
| public static Location findLocation(Object[] locations)
|
72 |
| { |
73 |
132
| for (int i = 0; i < locations.length; i++)
|
74 |
| { |
75 |
350
| Object location = locations[i];
|
76 |
| |
77 |
350
| Location result = getLocation(location);
|
78 |
| |
79 |
350
| if (result != null)
|
80 |
25
| return result;
|
81 |
| |
82 |
| } |
83 |
| |
84 |
107
| return null;
|
85 |
| } |
86 |
| |
87 |
| |
88 |
| |
89 |
| |
90 |
| |
91 |
| |
92 |
| |
93 |
363
| public static Location getLocation(Object object)
|
94 |
| { |
95 |
363
| if (object == null)
|
96 |
275
| return null;
|
97 |
| |
98 |
88
| if (object instanceof Location)
|
99 |
18
| return (Location) object;
|
100 |
| |
101 |
70
| if (object instanceof Locatable)
|
102 |
| { |
103 |
15
| Locatable locatable = (Locatable) object;
|
104 |
| |
105 |
15
| return locatable.getLocation();
|
106 |
| } |
107 |
| |
108 |
55
| return null;
|
109 |
| } |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
| |
115 |
4
| public static String getLocationString(Object object)
|
116 |
| { |
117 |
4
| Location l = getLocation(object);
|
118 |
| |
119 |
4
| if (l != null)
|
120 |
0
| return l.toString();
|
121 |
| |
122 |
4
| return HiveMindMessages.unknownLocation();
|
123 |
| } |
124 |
| |
125 |
| |
126 |
| |
127 |
| |
128 |
| |
129 |
| |
130 |
| |
131 |
64854
| public static boolean isBlank(String string)
|
132 |
| { |
133 |
64836
| if (string == null || string.length() == 0)
|
134 |
61326
| return true;
|
135 |
| |
136 |
3528
| if (string.trim().length() == 0)
|
137 |
0
| return true;
|
138 |
| |
139 |
3528
| return false;
|
140 |
| } |
141 |
| |
142 |
| |
143 |
| |
144 |
| |
145 |
61
| public static boolean isNonBlank(String string)
|
146 |
| { |
147 |
61
| return !isBlank(string);
|
148 |
| } |
149 |
| |
150 |
| |
151 |
| |
152 |
| |
153 |
| |
154 |
| |
155 |
| |
156 |
| |
157 |
| |
158 |
74060
| public static void setLocation(Object holder, Location location)
|
159 |
| { |
160 |
74030
| if (holder != null && holder instanceof LocationHolder)
|
161 |
| { |
162 |
47688
| LocationHolder lh = (LocationHolder) holder;
|
163 |
| |
164 |
47688
| lh.setLocation(location);
|
165 |
| } |
166 |
| } |
167 |
| |
168 |
| |
169 |
| |
170 |
| |
171 |
917
| public static boolean isEmpty(Collection c)
|
172 |
| { |
173 |
917
| return c == null || c.isEmpty();
|
174 |
| } |
175 |
| } |