src/org/objectweb/cjdbc/common/util/Strings.java

説明を見る。
00001 00025 package org.objectweb.cjdbc.common.util; 00026 00033 public class Strings 00034 { 00035 00045 public static String replace(String sourceString, String replace, String with) 00046 { 00047 if (sourceString == null || replace == null || with == null 00048 || "".equals(replace)) 00049 { 00050 return sourceString; 00051 } 00052 00053 StringBuffer buf = new StringBuffer(sourceString.length()); 00054 int start = 0, end = 0; 00055 while ((end = sourceString.indexOf(replace, start)) != -1) 00056 { 00057 buf.append(sourceString.substring(start, end)).append(with); 00058 start = end + replace.length(); 00059 } 00060 buf.append(sourceString.substring(start)); 00061 return buf.toString(); 00062 } 00063 00075 public static String replaceCasePreserving(String sourceString, 00076 String replace, String with) 00077 { 00078 if (sourceString == null || replace == null || with == null) 00079 { 00080 return sourceString; 00081 } 00082 String lower = sourceString.toLowerCase(); 00083 int shift = 0; 00084 int idx = lower.indexOf(replace); 00085 int length = replace.length(); 00086 StringBuffer resultString = new StringBuffer(sourceString); 00087 do 00088 { 00089 resultString = resultString.replace(idx + shift, idx + shift + length, 00090 with); 00091 shift += with.length() - length; 00092 idx = lower.indexOf(with, idx + length); 00093 } 00094 while (idx > 0); 00095 00096 return resultString.toString(); 00097 } 00098 00099 }

CJDBCversion1.0.4に対してTue Oct 12 15:15:58 2004に生成されました。 doxygen 1.3.8