From eede8f6c0e0f61a0b8da02334fc24820eff8a5c0 Mon Sep 17 00:00:00 2001 From: mdb Date: Tue, 26 Nov 2002 09:16:53 +0000 Subject: [PATCH] Provide a version of parseStringArray() that intern()s the array elements. git-svn-id: https://samskivert.googlecode.com/svn/trunk@951 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/util/StringUtil.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/StringUtil.java b/projects/samskivert/src/java/com/samskivert/util/StringUtil.java index 6ee337d2..891de45d 100644 --- a/projects/samskivert/src/java/com/samskivert/util/StringUtil.java +++ b/projects/samskivert/src/java/com/samskivert/util/StringUtil.java @@ -1,5 +1,5 @@ // -// $Id: StringUtil.java,v 1.46 2002/11/24 04:50:10 mdb Exp $ +// $Id: StringUtil.java,v 1.47 2002/11/26 09:16:53 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -668,6 +668,16 @@ public class StringUtil * array will result in the function returning null. */ public static String[] parseStringArray (String source) + { + return parseStringArray(source, false); + } + + /** + * Like {@link #parseStringArray(String)} but can be instructed to + * invoke {@link String#intern} on the strings being parsed into the + * array. + */ + public static String[] parseStringArray (String source, boolean intern) { int tcount = 0, tpos = -1, tstart = 0; @@ -691,6 +701,9 @@ public class StringUtil while ((tpos = source.indexOf(",", tpos+1)) != -1) { tokens[tcount] = source.substring(tstart, tpos); tokens[tcount] = replace(tokens[tcount].trim(), "%COMMA%", ","); + if (intern) { + tokens[tcount] = tokens[tcount].intern(); + } tstart = tpos+1; tcount++; }