comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/StringUtils.java @ 439:8975de9d7483

Loop through configuration to chart generation. gnv-artifacts/trunk@487 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 28 Dec 2009 16:24:05 +0000
parents
children 52e031261eaa
comparison
equal deleted inserted replaced
438:7399bb8f83ea 439:8975de9d7483
1 package de.intevation.gnv.utils;
2
3 /**
4 * @author Sascha L. Teichmann <sascha.teichmann@intevation.de>
5 */
6 public final class StringUtils
7 {
8 private StringUtils() {
9 }
10
11 public static final String [] append(String [] haystack, String straw) {
12 if (haystack == null) {
13 return new String [] { straw };
14 }
15 String [] nhaystack = new String[haystack.length];
16 System.arraycopy(haystack, 0, nhaystack, 0, haystack.length);
17 nhaystack[haystack.length] = straw;
18 return nhaystack;
19 }
20
21 public static final boolean contains(String [] haystack, String needle) {
22 if (haystack == null) {
23 return false;
24 }
25
26 if (needle == null) {
27 for (int i = haystack.length - 1; i >= 0; --i) {
28 if (haystack[i] == null) {
29 return true;
30 }
31 }
32 }
33 else {
34 for (int i = haystack.length - 1; i >= 0; --i) {
35 String straw = haystack[i];
36 if (straw != null && straw.equals(needle)) {
37 return true;
38 }
39 }
40 }
41
42 return false;
43 }
44 }
45 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org