comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/StringUtils.java @ 806:2cea76f1112e

Added Javadoc in utils package. gnv-artifacts/trunk@888 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Apr 2010 13:10:39 +0000
parents 6cff63d0c434
children f953c9a559d8
comparison
equal deleted inserted replaced
805:bb7afd783321 806:2cea76f1112e
1 package de.intevation.gnv.utils; 1 package de.intevation.gnv.utils;
2 2
3 /** 3 /**
4 * Helper class which supports some methods for working with strings.
5 *
4 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> 6 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
5 */ 7 */
6 public final class StringUtils 8 public final class StringUtils
7 { 9 {
8 private StringUtils() { 10 private StringUtils() {
9 } 11 }
10 12
13 /**
14 * Append a string to a string array.
15 *
16 * @param haystack String array.
17 * @param straw String to append.
18 * @return the new string array.
19 */
11 public static final String [] append(String [] haystack, String straw) { 20 public static final String [] append(String [] haystack, String straw) {
12 if (haystack == null) { 21 if (haystack == null) {
13 return new String [] { straw }; 22 return new String [] { straw };
14 } 23 }
15 String [] nhaystack = new String[haystack.length + 1]; 24 String [] nhaystack = new String[haystack.length + 1];
16 System.arraycopy(haystack, 0, nhaystack, 0, haystack.length); 25 System.arraycopy(haystack, 0, nhaystack, 0, haystack.length);
17 nhaystack[haystack.length] = straw; 26 nhaystack[haystack.length] = straw;
18 return nhaystack; 27 return nhaystack;
19 } 28 }
20 29
30 /**
31 * Checks the existence of a string in a given string array.
32 *
33 * @param haystack String array.
34 * @param needle String for being checked.
35 * @return true, if the string is contained in <i>haystack</i> - else false.
36 */
21 public static final boolean contains(String [] haystack, String needle) { 37 public static final boolean contains(String [] haystack, String needle) {
22 if (haystack == null) { 38 if (haystack == null) {
23 return false; 39 return false;
24 } 40 }
25 41

http://dive4elements.wald.intevation.org