Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 91831 invoked from network); 5 May 2004 22:28:24 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 5 May 2004 22:28:24 -0000 Received: (qmail 2841 invoked by uid 500); 5 May 2004 22:28:10 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 2779 invoked by uid 500); 5 May 2004 22:28:09 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 2767 invoked by uid 500); 5 May 2004 22:28:09 -0000 Delivered-To: apmail-cocoon-2.2-cvs@apache.org Received: (qmail 2763 invoked from network); 5 May 2004 22:28:09 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 5 May 2004 22:28:09 -0000 Received: (qmail 91799 invoked by uid 1707); 5 May 2004 22:28:22 -0000 Date: 5 May 2004 22:28:22 -0000 Message-ID: <20040505222822.91798.qmail@minotaur.apache.org> From: ugo@apache.org To: cocoon-2.2-cvs@apache.org Subject: cvs commit: cocoon-2.2/src/java/org/apache/cocoon/util Tokenizer.java IOUtils.java StringUtils.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ugo 2004/05/05 15:28:22 Modified: src/test/org/apache/cocoon/util/test IOUtilsTestCase.java src/java/org/apache/cocoon/util IOUtils.java StringUtils.java Added: src/java/org/apache/cocoon/util Tokenizer.java Log: Porting fixes from 2.1 Revision Changes Path 1.6 +1 -1 cocoon-2.2/src/test/org/apache/cocoon/util/test/IOUtilsTestCase.java Index: IOUtilsTestCase.java =================================================================== RCS file: /home/cvs/cocoon-2.2/src/test/org/apache/cocoon/util/test/IOUtilsTestCase.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 1.5 +2 -2 cocoon-2.2/src/java/org/apache/cocoon/util/IOUtils.java Index: IOUtils.java =================================================================== RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/util/IOUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- IOUtils.java 20 Apr 2004 16:10:52 -0000 1.4 +++ IOUtils.java 5 May 2004 22:28:22 -0000 1.5 @@ -196,7 +196,7 @@ */ public static String normalizedFilename(String filename) { if ("".equals(filename)) { - return ""; + return ""; } if(File.separatorChar == '\\') filename = filename.replace('/','\\'); 1.4 +60 -1 cocoon-2.2/src/java/org/apache/cocoon/util/StringUtils.java Index: StringUtils.java =================================================================== RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/util/StringUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- StringUtils.java 28 Mar 2004 21:01:20 -0000 1.3 +++ StringUtils.java 5 May 2004 22:28:22 -0000 1.4 @@ -25,6 +25,27 @@ public class StringUtils { /** + * Split a string as an array using whitespace as separator + * + * @param line The string to be split + * @return An array of whitespace-separated tokens + */ + public static String[] split(String line) { + return split(line, " \t\n\r"); + } + + /** + * Split a string as an array using a given set of separators + * + * @param line The string to be split + * @param delimiter A string containing token separators + * @return An array of token + */ + public static String[] split(String line, String delimiter) { + return Tokenizer.tokenize(line, delimiter, false); + } + + /** * Tests whether a given character is alphabetic, numeric or * underscore * @@ -36,6 +57,44 @@ (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); + } + + /** + * Counts the occurrence of the given char in the string. + * + * @param str The string to be tested + * @param c the char to be counted + * @return the occurrence of the character in the string. + * @deprecated Use {@link org.apache.commons.lang.StringUtils#countMatches(String, String)} + */ + public static int count(String str, char c) { + int index = 0; + char[] chars = str.toCharArray(); + for (int i = 0; i < chars.length; i++) { + if (chars[i] == c) index++; + } + return index; + } + + /** + * Matches two strings. + * + * @param a The first string + * @param b The second string + * @return the index where the two strings stop matching starting from 0 + * @deprecated Use {@link org.apache.commons.lang.StringUtils#indexOfDifference(String, String)} + */ + public static int matchStrings(String a, String b) { + int i; + char[] ca = a.toCharArray(); + char[] cb = b.toCharArray(); + int len = ( ca.length < cb.length ) ? ca.length : cb.length; + + for (i = 0; i < len; i++) { + if (ca[i] != cb[i]) break; + } + + return i; } /** 1.4 +2 -2 cocoon-2.2/src/java/org/apache/cocoon/util/Tokenizer.java