01: /*
02: * Copyright 2005 jWic group (http://www.jwic.de)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: * de.jwic.util.StringTool
17: * Created on 28.08.2005
18: * $Id: StringTool.java,v 1.1 2006/01/16 08:31:13 lordsam Exp $
19: */
20: package de.jwic.util;
21:
22: /**
23: * Utility class for string processing.
24: * @author Florian Lippisch
25: * @version $Revision: 1.1 $
26: */
27: public class StringTool {
28:
29: /**
30: * Returns the values in an array as semmicolon seperated string. If the
31: * array is null or empty, an empty string is returned.
32: * @param values
33: * @return
34: */
35: public static String getSingleString(String[] values) {
36: if (values != null) {
37: if (values.length == 1) {
38: return values[0] == null ? "" : values[0];
39: } else if (values.length > 1) {
40: StringBuffer sb = new StringBuffer();
41: for (int i = 0; i < values.length; i++) {
42: if (i > 0) {
43: sb.append(";");
44: }
45: sb.append(values[i]);
46: }
47: return sb.toString();
48: }
49: }
50: return "";
51: }
52:
53: }
|