01: /*
02: * $Id: StringUtils.java,v 1.3 2004/11/22 08:48:03 kowap Exp $
03: *
04: * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
05: * Berne University of Applied Sciences
06: * School of Engineering and Information Technology
07: * All rights reserved.
08: */
09: package bexee.util;
10:
11: /**
12: * Utility class for String values.
13: *
14: * @version $Revision: 1.3 $, $Date: 2004/11/22 08:48:03 $
15: * @author Pawel Kowalski
16: */
17: public class StringUtils {
18:
19: /**
20: * The separator used for splitting.
21: */
22: private static final String separator = ":";
23:
24: /**
25: * Test whether a given String is null or empty.
26: *
27: * @param stringToTest
28: * @return boolean
29: */
30: public static boolean isNullOrEmpty(String stringToTest) {
31: return (stringToTest == null || stringToTest.equals(""));
32: }
33:
34: /**
35: * Split a String using the ":" separator. A null or empty String will
36: * result in a String array containing two empty Strings. A unseparable
37: * String (without the separator) will result in a String array with the
38: * values: {"", value}.
39: *
40: * @param string
41: * @return String[] with splitted Strings
42: */
43: public static String[] split(String string) {
44: if (isNullOrEmpty(string)) {
45: return new String[] { "", "" };
46: } else if (string.indexOf(separator) == -1) {
47: return new String[] { "", string };
48: }
49: return org.apache.commons.lang.StringUtils.split(string,
50: separator);
51:
52: }
53:
54: }
|