From 17935e7fdd5cfbfc408063dda0b9ae3321ab8e5a Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 26 Feb 2002 12:08:41 +0000 Subject: [PATCH 1/1] add split/join methods. no StringUtils is complete without them. taken from Jakarta Turbine StringUtils --- source/mir/misc/StringUtil.java | 62 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/source/mir/misc/StringUtil.java b/source/mir/misc/StringUtil.java index a59b84a2..24de3ab6 100755 --- a/source/mir/misc/StringUtil.java +++ b/source/mir/misc/StringUtil.java @@ -185,6 +185,49 @@ public final class StringUtil { return returnDate.toString(); } + /** + * Splits the provided CSV text into a list. stolen wholesale from + * from Jakarta Turbine StrinUtils.java -mh + * + * @param text The CSV list of values to split apart. + * @param separator The separator character. + * @return The list of values. + */ + public static String[] split(String text, String separator) + { + StringTokenizer st = new StringTokenizer(text, separator); + String[] values = new String[st.countTokens()]; + int pos = 0; + while (st.hasMoreTokens()) + { + values[pos++] = st.nextToken(); + } + return values; + } + + /** + * Joins the elements of the provided array into a single string + * containing a list of CSV elements. Stolen wholesale from Jakarta + * Turbine StringUtils.java. -mh + * + * @param list The list of values to join together. + * @param separator The separator character. + * @return The CSV text. + */ + public static String join(String[] list, String separator) + { + StringBuffer csv = new StringBuffer(); + for (int i = 0; i < list.length; i++) + { + if (i > 0) + { + csv.append(separator); + } + csv.append(list[i]); + } + return csv.toString(); + } + /** * schließt einen String in Anführungsszeichen ein, falls er Leerzeichen o.ä. enthält @@ -946,12 +989,25 @@ public final class StringUtil { * @param width, width of the image * @return a String containing the url */ - public static String createIMGLinks(String haystack, String title, String height,String width) { + public static String createIMGLinks(String haystack, String title, + String height,String width) { + String wh=""; + if ( (height != null) && (width != null) ) + { + wh = "width=\""+width+"\" height=\""+height+"\""; + } if (title != null) { title = removeHTMLTags(title); - return re_url.substituteAll(haystack,"\""+title+"\"/ 
"+title+""); + return re_url.substituteAll(haystack, + "\""+title+"\"/ 
"+ + title+""); } else { - return re_url.substituteAll(haystack,"\"\"/ "); + return re_url.substituteAll(haystack, + "\"\"/ "); } } -- 2.11.0