usr/src/java/util/org/opensolaris/os/vp/util/misc/TextUtil.java
changeset 253 f219d4576960
parent 243 979bb698977b
child 304 6630c8b85735
--- a/usr/src/java/util/org/opensolaris/os/vp/util/misc/TextUtil.java	Thu Apr 02 19:32:40 2009 -0400
+++ b/usr/src/java/util/org/opensolaris/os/vp/util/misc/TextUtil.java	Fri Apr 03 12:57:16 2009 -0400
@@ -26,7 +26,7 @@
 
 package org.opensolaris.os.vp.util.misc;
 
-import java.util.*;
+import java.util.Collection;
 import java.util.regex.*;
 
 public class TextUtil {
@@ -308,117 +308,6 @@
 	return groups;
     }
 
-    /**
-     * Splits the given text into fields.
-     *
-     * @param	    delim
-     *		    the regular expression delimiter for each field
-     *
-     * @param	    text
-     *		    the text to split
-     *
-     * @param	    quotes
-     *		    the characters that indicate a grouping of text,
-     *		    eg. single quotes ("<code>'</code>") or double
-     *		    quotes ("<code>"</code>"), etc., or
-     *		    <code>null</code> for no quotes
-     *
-     * @param	    quoteEsc
-     *		    an expression that can precede a quote character
-     *		    so that it is interpreted normally, rather than as
-     *		    a quote character, or <code>null</code> if no such
-     *		    escape character is used
-     *
-     * @return	    the resulting fields
-     */
-    public static String[] split(
-	String delim, String text, String quotes, String quoteEsc) {
-
-	// Create the matching regular expression
-	int ngroups = 0;
-	int quoteGroup = -1;
-	int quoteEscGroup = -1;
-
-	StringBuffer reBuffer = new StringBuffer("^(.*?)(");
-	int fieldGroup = ++ngroups;
-	ngroups++;
-
-	if (quotes != null) {
-	    if (quoteEsc != null) {
-		reBuffer.append("(\\Q").append(quoteEsc).append("\\E").
-		    append("[").append(quotes).append("])|");
-		quoteEscGroup = ++ngroups;
-	    }
-	    reBuffer.append("([").append(quotes).append("])|");
-	    quoteGroup = ++ngroups;
-	}
-	reBuffer.append("(").append(delim).append("))(.*)");
-	int delimGroup = ++ngroups;
-	int textGroup = ++ngroups;
-
-	String regex = reBuffer.toString();
-
-	List<String> fields = new ArrayList<String>();
-
-	// Build the field
-	StringBuffer field = new StringBuffer();
-
-	boolean inQuote = false;
-	String curQuote = null;
-	while (text != null && text.length() > 0) {
-
-	    String[] groups = match(text, regex);
-
-	    if (groups == null) {
-		field.append(text);
-		text = null;
-	    } else {
-
-		field.append(groups[fieldGroup]);
-
-		// Remaining text
-		text = groups[textGroup];
-
-		// Was a delimiter reached?
-		if (groups[delimGroup] != null) {
-		    if (inQuote) {
-			field.append(groups[delimGroup]);
-		    } else {
-			fields.add(field.toString());
-			field.setLength(0);
-		    }
-		} else
-
-		try {
-		    String quote = groups[quoteGroup];
-		   // Was a quote reached?
-		    if (quote != null) {
-			if (inQuote) {
-			    if (quote.equals(curQuote)) {
-				inQuote = false;
-			    } else {
-				field.append(quote);
-			    }
-			} else {
-			    inQuote = true;
-			    curQuote = quote;
-			}
-		    } else
-
-		    // Was an escaped quote reached?
-		    if (groups[quoteEscGroup] != null) {
-			field.append(quotes);
-		    }
-		}
-		catch (ArrayIndexOutOfBoundsException ignore) {}
-	    }
-	}
-
-	fields.add(field.toString());
-
-	return fields.toArray(new String[fields.size()]);
-    }
-
     public static String toJavaMethodName(String... words) {
 	StringBuffer buffer = new StringBuffer();
 	for (String word : words) {