froehlich 01/12/17 08:00:30
Modified: apps/db/src/java/org/apache/avalon/db/utils StringUtils.java
Log:
create, insert, select + criteria is working 90%
Revision Changes Path
1.3 +73 -51
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/utils/StringUtils.java
Index: StringUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/utils/StringUtils.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StringUtils.java 2001/11/03 08:21:00 1.2
+++ StringUtils.java 2001/12/17 16:00:30 1.3
@@ -1,110 +1,132 @@
-/*****************************************************************************
- * Copyright (C) The Apache Software Foundation. All rights reserved.
*
- * -------------------------------------------------------------------------
*
- * This software is published under the terms of the Apache Software License
*
- * version 1.1, a copy of which has been included with this distribution in
*
- * the LICENSE file.
*
-
*****************************************************************************/
+/**
+ * Copyright (C) The Apache Software Foundation. All rights reserved. *
+ *
------------------------------------------------------------------------- *
+ * This software is published under the terms of the Apache Software
License *
+ * version 1.1, a copy of which has been included with this distribution in
*
+ * the LICENSE file. *
+ */
package org.apache.avalon.db.utils;
-
-
/**
- * A collection of <code>String</code> handling utility methods.
+ * A collection of <code>String</code> handling utility methods.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.2 $ $Date: 2001/11/03 08:21:00 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
+ * @version CVS $Revision: 1.3 $ $Date: 2001/12/17 16:00:30 $
*/
public class StringUtils {
-
+
/**
- * Split a string as an array using whitespace as separator
+ * Tests whether a given character is alphabetic, numeric or underscore
*
- * @param line The string to be split
- * @return An array of whitespace-separated tokens
+ * @param c The character to be tested
+ * @return whether the given character is alphameric or not
*/
+ public static boolean isAlphaNumeric(char c) {
+ return c == '_' ||
+ (c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9');
+ }
+
+
+ /**
+ * 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
+ * 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
+ * @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) {
Tokenizer tokenizer = new Tokenizer(line, delimiter);
int tokenCount = tokenizer.countTokens();
String[] result = new String[tokenCount];
-
+
for (int i = 0; i < tokenCount; i++) {
result[i] = tokenizer.nextToken();
}
-
+
return result;
}
- /**
- * Tests whether a given character is alphabetic, numeric or
- * underscore
- *
- * @param c The character to be tested
- * @return whether the given character is alphameric or not
- */
- public static boolean isAlphaNumeric(char c) {
- return c == '_' ||
- (c >= 'a' && c <= 'z') ||
- (c >= 'A' && c <= 'Z') ||
- (c >= '0' && c <= '9');
- }
/**
- * Counts the occurrence of the given char in the string.
+ * 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.
+ * @param str The string to be tested
+ * @param c the char to be counted
+ * @return the occurrence of the character in the 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++;
+ if (chars[i] == c) {
+ index++;
+ }
}
return index;
}
+
/**
- * Matches two strings.
+ * 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
+ * @param a The first string
+ * @param b The second string
+ * @return the index where the two strings stop matching starting
from 0
*/
public static int matchStrings(String a, String b) {
int i;
char[] ca = a.toCharArray();
char[] cb = b.toCharArray();
for (i = 0; (i < ca.length) || (i < cb.length); i++) {
- if (ca[i] != cb[i]) break;
+ if (ca[i] != cb[i]) {
+ break;
+ }
}
return i;
}
+
/**
- * Replaces tokens in input with Value present in System.getProperty
+ * Replaces tokens in input with Value present in System.getProperty
+ *
+ * @param s Description of Parameter
+ * @return Description of the Returned Value
*/
public static String replaceToken(String s) {
int startToken = s.indexOf("${");
- int endToken = s.indexOf("}",startToken);
- String token = s.substring(startToken+2,endToken);
+ int endToken = s.indexOf("}", startToken);
+ String token = s.substring(startToken + 2, endToken);
StringBuffer value = new StringBuffer();
- value.append(s.substring(0,startToken));
+ value.append(s.substring(0, startToken));
value.append(System.getProperty(token));
- value.append(s.substring(endToken+1));
+ value.append(s.substring(endToken + 1));
return value.toString();
}
+
+
+ /**
+ * Description of the Method
+ *
+ * @param str Description of Parameter
+ * @return Description of the Returned Value
+ */
+ public static String normalize(String str) {
+ return str.toLowerCase().trim();
+ }
+
}
+
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>