提交 fd31e277 authored 作者: Thomas Mueller's avatar Thomas Mueller

StringUtils.replaceAllIgnoreCase

上级 19633328
......@@ -10,7 +10,6 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.util.Locale;
import java.util.Properties;
import org.h2.engine.Constants;
......@@ -58,8 +57,8 @@ public class Driver implements java.sql.Driver {
if (!acceptsURL(url)) {
return null;
}
boolean noUpgrade = url.toUpperCase(Locale.ENGLISH).contains(";NO_UPGRADE=TRUE");
url = StringUtils.replaceAll(url, ";NO_UPGRADE=TRUE", "", true);
boolean noUpgrade = StringUtils.toUpperEnglish(url).indexOf(";NO_UPGRADE=TRUE") >= 0;
url = StringUtils.replaceAllIgnoreCase(url, ";NO_UPGRADE=TRUE", "");
if (DbUpgrade.areV1dot1ClassesPresent()) {
if (noUpgrade) {
Connection connection = DbUpgrade.connectWithOldVersion(url, info);
......
......@@ -230,21 +230,21 @@ public class Bnf {
private String[] tokenize() {
ArrayList<String> list = New.arrayList();
syntax = StringUtils.replaceAll(syntax, "yyyy-MM-dd", "@ymd@", false);
syntax = StringUtils.replaceAll(syntax, "hh:mm:ss", "@hms@", false);
syntax = StringUtils.replaceAll(syntax, "nnnnnnnnn", "@nanos@", false);
syntax = StringUtils.replaceAll(syntax, "function", "@func@", false);
syntax = StringUtils.replaceAll(syntax, "0x", "@hexStart@", false);
syntax = StringUtils.replaceAll(syntax, ",...", "@commaDots@", false);
syntax = StringUtils.replaceAll(syntax, "...", "@dots@", false);
syntax = StringUtils.replaceAll(syntax, "||", "@concat@", false);
syntax = StringUtils.replaceAll(syntax, "a-z|_", "@az_@", false);
syntax = StringUtils.replaceAll(syntax, "A-Z|_", "@az_@", false);
syntax = StringUtils.replaceAll(syntax, "a-f", "@af@", false);
syntax = StringUtils.replaceAll(syntax, "A-F", "@af@", false);
syntax = StringUtils.replaceAll(syntax, "0-9", "@digit@", false);
syntax = StringUtils.replaceAll(syntax, "'['", "@openBracket@", false);
syntax = StringUtils.replaceAll(syntax, "']'", "@closeBracket@", false);
syntax = StringUtils.replaceAll(syntax, "yyyy-MM-dd", "@ymd@");
syntax = StringUtils.replaceAll(syntax, "hh:mm:ss", "@hms@");
syntax = StringUtils.replaceAll(syntax, "nnnnnnnnn", "@nanos@");
syntax = StringUtils.replaceAll(syntax, "function", "@func@");
syntax = StringUtils.replaceAll(syntax, "0x", "@hexStart@");
syntax = StringUtils.replaceAll(syntax, ",...", "@commaDots@");
syntax = StringUtils.replaceAll(syntax, "...", "@dots@");
syntax = StringUtils.replaceAll(syntax, "||", "@concat@");
syntax = StringUtils.replaceAll(syntax, "a-z|_", "@az_@");
syntax = StringUtils.replaceAll(syntax, "A-Z|_", "@az_@");
syntax = StringUtils.replaceAll(syntax, "a-f", "@af@");
syntax = StringUtils.replaceAll(syntax, "A-F", "@af@");
syntax = StringUtils.replaceAll(syntax, "0-9", "@digit@");
syntax = StringUtils.replaceAll(syntax, "'['", "@openBracket@");
syntax = StringUtils.replaceAll(syntax, "']'", "@closeBracket@");
StringTokenizer tokenizer = getTokenizer(syntax);
while (tokenizer.hasMoreTokens()) {
String s = tokenizer.nextToken();
......
......@@ -2380,7 +2380,7 @@ public class Parser {
String text = currentValue.getString();
// the PostgreSQL ODBC driver uses
// LIKE E'PROJECT\\_DATA' instead of LIKE 'PROJECT\_DATA'
text = StringUtils.replaceAll(text, "\\\\", "\\", false);
text = StringUtils.replaceAll(text, "\\\\", "\\");
read();
r = ValueExpression.get(ValueString.get(text));
} else {
......
......@@ -63,7 +63,7 @@ public class CreateFunctionAlias extends SchemaCommand {
* @param method the qualified method name
*/
public void setJavaClassMethod(String method) {
this.javaClassMethod = StringUtils.replaceAll(method, " ", "", false);
this.javaClassMethod = StringUtils.replaceAll(method, " ", "");
}
public void setIfNotExists(boolean ifNotExists) {
......
......@@ -304,9 +304,9 @@ public class WebApp {
value = space + value;
}
key = StringUtils.urlEncode(key);
key = StringUtils.replaceAll(key, "+", " ", false);
key = StringUtils.replaceAll(key, "+", " ");
value = StringUtils.urlEncode(value);
value = StringUtils.replaceAll(value, "+", " ", false);
value = StringUtils.replaceAll(value, "+", " ");
list.add(type + "#" + key + "#" + value);
}
Collections.sort(list);
......@@ -738,7 +738,7 @@ public class WebApp {
if (isH2) {
stackTrace = linkToSource(stackTrace);
}
stackTrace = StringUtils.replaceAll(stackTrace, "\t", "&nbsp;&nbsp;&nbsp;&nbsp;", false);
stackTrace = StringUtils.replaceAll(stackTrace, "\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
String message = PageParser.escapeHtml(e.getMessage());
String error = "<a class=\"error\" href=\"#\" onclick=\"var x=document.getElementById('st" + id
+ "').style;x.display=x.display==''?'none':'';\">" + message + "</a>";
......
......@@ -221,9 +221,9 @@ public class RunScript extends Tool {
for (int i = 0; i < columns; i++) {
String s = rs.getString(i + 1);
if (s != null) {
s = StringUtils.replaceAll(s, "\r\n", "\n", false);
s = StringUtils.replaceAll(s, "\n", "\n--> ", false);
s = StringUtils.replaceAll(s, "\r", "\r--> ", false);
s = StringUtils.replaceAll(s, "\r\n", "\n");
s = StringUtils.replaceAll(s, "\n", "\n--> ");
s = StringUtils.replaceAll(s, "\r", "\r--> ");
}
buff.append(' ').append(s);
}
......@@ -235,11 +235,11 @@ public class RunScript extends Tool {
}
if (checkResults) {
String expected = r.readStatement() + ";";
expected = StringUtils.replaceAll(expected, "\r\n", "\n", false);
expected = StringUtils.replaceAll(expected, "\r", "\n", false);
expected = StringUtils.replaceAll(expected, "\r\n", "\n");
expected = StringUtils.replaceAll(expected, "\r", "\n");
if (!expected.equals(result)) {
expected = StringUtils.replaceAll(expected, " ", "+", false);
result = StringUtils.replaceAll(result, " ", "+", false);
expected = StringUtils.replaceAll(expected, " ", "+");
result = StringUtils.replaceAll(result, " ", "+");
throw new SQLException("Unexpected output for:\n" + sql.trim() + "\nGot:\n" + result + "\nExpected:\n" + expected);
}
}
......
......@@ -473,7 +473,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
if (browser.indexOf("%url") >= 0) {
String[] args = StringUtils.arraySplit(browser, ',', false);
for (int i = 0; i < args.length; i++) {
args[i] = StringUtils.replaceAll(args[i], "%url", url, false);
args[i] = StringUtils.replaceAll(args[i], "%url", url);
}
rt.exec(args);
} else if (osName.indexOf("windows") >= 0) {
......
......@@ -56,10 +56,10 @@ public class DbUpgrade {
public static Connection connectWithOldVersion(String url, Properties info) throws SQLException {
try {
String oldStartUrlPrefix = (String) Utils.getStaticField("org.h2.upgrade.v1_1.engine.Constants.START_URL");
url = StringUtils.replaceAll(url, org.h2.engine.Constants.START_URL, oldStartUrlPrefix, false);
url = StringUtils.replaceAll(url, ";IGNORE_UNKNOWN_SETTINGS=TRUE", "", true);
url = StringUtils.replaceAll(url, ";IGNORE_UNKNOWN_SETTINGS=FALSE", "", true);
url = StringUtils.replaceAll(url, ";PAGE_STORE=TRUE", "", true);
url = StringUtils.replaceAll(url, org.h2.engine.Constants.START_URL, oldStartUrlPrefix);
url = StringUtils.replaceAllIgnoreCase(url, ";IGNORE_UNKNOWN_SETTINGS=TRUE", "");
url = StringUtils.replaceAllIgnoreCase(url, ";IGNORE_UNKNOWN_SETTINGS=FALSE", "");
url = StringUtils.replaceAllIgnoreCase(url, ";PAGE_STORE=TRUE", "");
url += ";IGNORE_UNKNOWN_SETTINGS=TRUE";
Object ci = Utils.newInstance("org.h2.upgrade.v1_1.engine.ConnectionInfo", url, info);
boolean isRemote = (Boolean) Utils.callMethod(ci, "isRemote");
......
......@@ -62,17 +62,17 @@ public class DbUpgradeNonPageStoreToCurrent {
private void init() throws SQLException {
try {
newUrl = url;
newUrl = StringUtils.replaceAll(newUrl, ";UNDO_LOG=1", "", true);
newUrl = StringUtils.replaceAll(newUrl, ";UNDO_LOG=0", "", true);
newUrl = StringUtils.replaceAllIgnoreCase(newUrl, ";UNDO_LOG=1", "");
newUrl = StringUtils.replaceAllIgnoreCase(newUrl, ";UNDO_LOG=0", "");
newUrl += ";UNDO_LOG=0";
String oldStartUrlPrefix = (String) Utils.getStaticField("org.h2.upgrade.v1_1.engine.Constants.START_URL");
oldUrl = url;
oldUrl = StringUtils.replaceAll(oldUrl, org.h2.engine.Constants.START_URL, oldStartUrlPrefix, false);
oldUrl = StringUtils.replaceAll(oldUrl, ";IGNORE_UNKNOWN_SETTINGS=TRUE", "", true);
oldUrl = StringUtils.replaceAll(oldUrl, ";IGNORE_UNKNOWN_SETTINGS=FALSE", "", true);
oldUrl = StringUtils.replaceAll(oldUrl, ";IFEXISTS=TRUE", "", true);
oldUrl = StringUtils.replaceAll(oldUrl, ";IFEXISTS=FALSE", "", true);
oldUrl = StringUtils.replaceAll(oldUrl, ";PAGE_STORE=TRUE", "", true);
oldUrl = StringUtils.replaceAll(oldUrl, org.h2.engine.Constants.START_URL, oldStartUrlPrefix);
oldUrl = StringUtils.replaceAllIgnoreCase(oldUrl, ";IGNORE_UNKNOWN_SETTINGS=TRUE", "");
oldUrl = StringUtils.replaceAllIgnoreCase(oldUrl, ";IGNORE_UNKNOWN_SETTINGS=FALSE", "");
oldUrl = StringUtils.replaceAllIgnoreCase(oldUrl, ";IFEXISTS=TRUE", "");
oldUrl = StringUtils.replaceAllIgnoreCase(oldUrl, ";IFEXISTS=FALSE", "");
oldUrl = StringUtils.replaceAllIgnoreCase(oldUrl, ";PAGE_STORE=TRUE", "");
oldUrl += ";IGNORE_UNKNOWN_SETTINGS=TRUE";
Object ci = Utils.newInstance("org.h2.upgrade.v1_1.engine.ConnectionInfo", oldUrl, info);
boolean isRemote = (Boolean) Utils.callMethod(ci, "isRemote");
......
......@@ -146,7 +146,7 @@ public class JdbcUtils {
if (pattern == null || pattern.length() == 0) {
return pattern;
}
return StringUtils.replaceAll(pattern, "\\", "\\\\", false);
return StringUtils.replaceAll(pattern, "\\", "\\\\");
}
/**
......
......@@ -210,7 +210,7 @@ public class SourceCompiler {
private void throwSyntaxError(ByteArrayOutputStream out) {
String err = StringUtils.utf8Decode(out.toByteArray());
if (err.length() > 0) {
err = StringUtils.replaceAll(err, compileDir, "", false);
err = StringUtils.replaceAll(err, compileDir, "");
throw DbException.get(ErrorCode.SYNTAX_ERROR_1, err);
}
}
......
......@@ -697,18 +697,27 @@ public class StringUtils {
* @param s the string
* @param before the old text
* @param after the new text
* @param caseInsensitive true if it should be case insensitive
* @return the string with the before string replaced
*/
public static String replaceAll(String s, String before, String after, boolean caseInsensitive) {
String testString;
if (caseInsensitive) {
testString = s.toLowerCase(Locale.ENGLISH);
before = before.toLowerCase(Locale.ENGLISH);
} else {
testString = s;
}
int next = testString.indexOf(before);
public static String replaceAll(String s, String before, String after) {
return replaceAll(s, s, before, after);
}
/**
* Replace all occurrences of the "before" string with the "after" string.
* A case-insensitive comparison is made.
*
* @param s the string
* @param before the old text
* @param after the new text
* @return the string with the before string replaced
*/
public static String replaceAllIgnoreCase(String s, String before, String after) {
return replaceAll(s, toUpperEnglish(s), toUpperEnglish(before), after);
}
private static String replaceAll(String s, String test, String before, String after) {
int next = test.indexOf(before);
if (next < 0) {
return s;
}
......@@ -717,7 +726,7 @@ public class StringUtils {
while (true) {
buff.append(s.substring(index, next)).append(after);
index = next + before.length();
next = testString.indexOf(before, index);
next = test.indexOf(before, index);
if (next < 0) {
buff.append(s.substring(index));
break;
......@@ -763,8 +772,8 @@ public class StringUtils {
* @return the resulting string
*/
public static String quoteRemarkSQL(String sql) {
sql = replaceAll(sql, "*/", "++/", false);
return replaceAll(sql, "/*", "/++", false);
sql = replaceAll(sql, "*/", "++/");
return replaceAll(sql, "/*", "/++");
}
/**
......
......@@ -63,18 +63,18 @@ public class Newsfeed {
*/
private static String convertHtml2Text(String html) {
String s = html;
s = StringUtils.replaceAll(s, "<b>", "", false);
s = StringUtils.replaceAll(s, "</b>", "", false);
s = StringUtils.replaceAll(s, "<ul>", "", false);
s = StringUtils.replaceAll(s, "</ul>", "", false);
s = StringUtils.replaceAll(s, "<li>", "- ", false);
s = StringUtils.replaceAll(s, "</li>", "", false);
s = StringUtils.replaceAll(s, "<a href=\"", "( ", false);
s = StringUtils.replaceAll(s, "\">", " ) ", false);
s = StringUtils.replaceAll(s, "</a>", "", false);
s = StringUtils.replaceAll(s, "<br />", "", false);
s = StringUtils.replaceAll(s, "<br/>", "", false);
s = StringUtils.replaceAll(s, "<br>", "", false);
s = StringUtils.replaceAll(s, "<b>", "");
s = StringUtils.replaceAll(s, "</b>", "");
s = StringUtils.replaceAll(s, "<ul>", "");
s = StringUtils.replaceAll(s, "</ul>", "");
s = StringUtils.replaceAll(s, "<li>", "- ");
s = StringUtils.replaceAll(s, "</li>", "");
s = StringUtils.replaceAll(s, "<a href=\"", "( ");
s = StringUtils.replaceAll(s, "\">", " ) ");
s = StringUtils.replaceAll(s, "</a>", "");
s = StringUtils.replaceAll(s, "<br />", "");
s = StringUtils.replaceAll(s, "<br/>", "");
s = StringUtils.replaceAll(s, "<br>", "");
if (s.indexOf('<') >= 0 || s.indexOf('>') >= 0) {
throw new RuntimeException("Unsupported HTML Tag: < or > in " + s);
}
......
......@@ -247,7 +247,7 @@ class Database {
String key = (String) k;
if (key.startsWith(databaseType + ".")) {
String pattern = key.substring(databaseType.length() + 1);
pattern = StringUtils.replaceAll(pattern, "_", " ", false);
pattern = StringUtils.replaceAll(pattern, "_", " ");
pattern = StringUtils.toUpperEnglish(pattern);
String replacement = prop.getProperty(key);
replace.add(new String[]{pattern, replacement});
......@@ -270,7 +270,7 @@ class Database {
for (String[] pair : replace) {
String pattern = pair[0];
String replacement = pair[1];
sql = StringUtils.replaceAll(sql, pattern, replacement, false);
sql = StringUtils.replaceAll(sql, pattern, replacement);
}
return sql;
}
......
......@@ -208,7 +208,7 @@ public class TestCsv extends TestBase {
stat.execute("call csvwrite('"+fileName+"', 'select 1 id, ''Hello'' name', null, '|', '', null, null, chr(10))");
InputStreamReader reader = new InputStreamReader(IOUtils.openFileInputStream(fileName));
String text = IOUtils.readStringAndClose(reader, -1).trim();
text = StringUtils.replaceAll(text, "\n", " ", false);
text = StringUtils.replaceAll(text, "\n", " ");
assertEquals("ID|NAME 1|Hello", text);
ResultSet rs = stat.executeQuery("select * from csvread('" + fileName + "', null, null, '|', '')");
ResultSetMetaData meta = rs.getMetaData();
......
......@@ -92,7 +92,7 @@ public class TestSampleApps extends TestBase {
System.setOut(oldOut);
System.setErr(oldErr);
String s = new String(buff.toByteArray(), "UTF-8");
s = StringUtils.replaceAll(s, "\r\n", "\n", false);
s = StringUtils.replaceAll(s, "\r\n", "\n");
s = s.trim();
expected = expected.trim();
if (expected.endsWith("*")) {
......
......@@ -169,19 +169,19 @@ public class TestStringUtils extends TestBase {
}
private void testReplaceAll() {
assertEquals("def", StringUtils.replaceAll("abc def", "abc ", "", false));
assertEquals("af", StringUtils.replaceAll("abc def", "bc de", "", false));
assertEquals("abc def", StringUtils.replaceAll("abc def", "bc ", "bc ", false));
assertEquals("abc ", StringUtils.replaceAll("abc def", "def", "", false));
assertEquals(" ", StringUtils.replaceAll("abc abc", "abc", "", false));
assertEquals("xyz xyz", StringUtils.replaceAll("abc abc", "abc", "xyz", false));
assertEquals("abc def", StringUtils.replaceAll("abc def", "xyz", "abc", false));
assertEquals("", StringUtils.replaceAll("abcabcabc", "abc", "", false));
assertEquals("abcabcabc", StringUtils.replaceAll("abcabcabc", "aBc", "", false));
assertEquals("d", StringUtils.replaceAll("abcd", "aBc", "", true));
assertEquals("d", StringUtils.replaceAll("abcd", "abc", "", true));
assertEquals("D", StringUtils.replaceAll("abcD", "aBc", "", true));
assertEquals("D", StringUtils.replaceAll("abcD", "abc", "", true));
assertEquals("def", StringUtils.replaceAll("abc def", "abc ", ""));
assertEquals("af", StringUtils.replaceAll("abc def", "bc de", ""));
assertEquals("abc def", StringUtils.replaceAll("abc def", "bc ", "bc "));
assertEquals("abc ", StringUtils.replaceAll("abc def", "def", ""));
assertEquals(" ", StringUtils.replaceAll("abc abc", "abc", ""));
assertEquals("xyz xyz", StringUtils.replaceAll("abc abc", "abc", "xyz"));
assertEquals("abc def", StringUtils.replaceAll("abc def", "xyz", "abc"));
assertEquals("", StringUtils.replaceAll("abcabcabc", "abc", ""));
assertEquals("abcabcabc", StringUtils.replaceAll("abcabcabc", "aBc", ""));
assertEquals("d", StringUtils.replaceAllIgnoreCase("abcd", "aBc", ""));
assertEquals("d", StringUtils.replaceAllIgnoreCase("abcd", "abc", ""));
assertEquals("D", StringUtils.replaceAllIgnoreCase("abcD", "aBc", ""));
assertEquals("D", StringUtils.replaceAllIgnoreCase("abcD", "abc", ""));
}
}
......@@ -34,12 +34,12 @@ public class BnfRailroad implements BnfVisitor {
public String getHtml(Bnf bnf, String syntaxLines) {
syntaxVisitor = new BnfSyntax();
this.config = bnf;
syntaxLines = StringUtils.replaceAll(syntaxLines, "\n ", " ", false);
syntaxLines = StringUtils.replaceAll(syntaxLines, "\n ", " ");
String[] syntaxList = StringUtils.arraySplit(syntaxLines, '\n', true);
StringBuilder buff = new StringBuilder();
for (String s : syntaxList) {
bnf.visit(this, s);
html = StringUtils.replaceAll(html, "</code></td><td class=\"d\"><code class=\"c\">", " ", false);
html = StringUtils.replaceAll(html, "</code></td><td class=\"d\"><code class=\"c\">", " ");
if (buff.length() > 0) {
buff.append("<br />");
}
......
......@@ -30,7 +30,7 @@ public class BnfSyntax implements BnfVisitor {
* @return the HTML
*/
public String getHtml(Bnf bnf, String syntaxLines) {
syntaxLines = StringUtils.replaceAll(syntaxLines, "\n ", "\n", false);
syntaxLines = StringUtils.replaceAll(syntaxLines, "\n ", "\n");
StringTokenizer tokenizer = bnf.getTokenizer(syntaxLines);
StringBuilder buff = new StringBuilder();
while (tokenizer.hasMoreTokens()) {
......@@ -43,7 +43,7 @@ public class BnfSyntax implements BnfVisitor {
}
String s = buff.toString();
// ensure it works within XHTML comments
s = StringUtils.replaceAll(s, "--", "&#45;-", false);
s = StringUtils.replaceAll(s, "--", "&#45;-");
return s;
}
......
......@@ -149,15 +149,15 @@ public class GenerateDoc {
String text = map.get("text");
if (text != null) {
// text is enclosed in <p> .. </p> so this works.
text = StringUtils.replaceAll(text, "<br /><br />", "</p><p>", false);
text = StringUtils.replaceAll(text, "<br />", " ", false);
text = StringUtils.replaceAll(text, "<br /><br />", "</p><p>");
text = StringUtils.replaceAll(text, "<br />", " ");
map.put("text", text);
}
String link = topic.toLowerCase();
link = StringUtils.replaceAll(link, " ", "_", false);
link = StringUtils.replaceAll(link, " ", "_");
// link = StringUtils.replaceAll(link, "_", "");
link = StringUtils.replaceAll(link, "@", "_", false);
link = StringUtils.replaceAll(link, "@", "_");
map.put("link", StringUtils.urlEncode(link));
list.add(map);
......
......@@ -41,7 +41,7 @@ public class MergeDocs {
for (String fileName : pages) {
String text = getContent(fileName);
for (String page : pages) {
text = StringUtils.replaceAll(text, page + "#", "#", false);
text = StringUtils.replaceAll(text, page + "#", "#");
}
text = disableRailroads(text);
text = removeHeaderFooter(fileName, text);
......@@ -61,10 +61,10 @@ public class MergeDocs {
}
private String disableRailroads(String text) {
text = StringUtils.replaceAll(text, "<!-- railroad-start -->", "<!-- railroad-start ", false);
text = StringUtils.replaceAll(text, "<!-- railroad-end -->", " railroad-end -->", false);
text = StringUtils.replaceAll(text, "<!-- syntax-start", "<!-- syntax-start -->", false);
text = StringUtils.replaceAll(text, "syntax-end -->", "<!-- syntax-end -->", false);
text = StringUtils.replaceAll(text, "<!-- railroad-start -->", "<!-- railroad-start ");
text = StringUtils.replaceAll(text, "<!-- railroad-end -->", " railroad-end -->");
text = StringUtils.replaceAll(text, "<!-- syntax-start", "<!-- syntax-start -->");
text = StringUtils.replaceAll(text, "syntax-end -->", "<!-- syntax-end -->");
return text;
}
......
......@@ -175,7 +175,7 @@ public class SpellChecker {
StringBuilder buff = new StringBuilder(text.length());
int pos = 0, last = 0;
if (fileName.endsWith(".properties")) {
text = StringUtils.replaceAll(text, "\\:", ":", false);
text = StringUtils.replaceAll(text, "\\:", ":");
}
while (true) {
pos = text.indexOf("http://", pos);
......
......@@ -55,8 +55,8 @@ public class UploadBuild {
idx = index.indexOf("</A>");
index = index.substring(0, idx) + index.substring(idx + "</A>".length());
}
index = StringUtils.replaceAll(index, "[all", "", false);
index = StringUtils.replaceAll(index, "classes]", "", false);
index = StringUtils.replaceAll(index, "[all", "");
index = StringUtils.replaceAll(index, "classes]", "");
FileOutputStream out = new FileOutputStream("coverage/overview.html");
out.write(index.getBytes("ISO-8859-1"));
out.close();
......
......@@ -138,18 +138,18 @@ public class WebSite {
if (name.endsWith(".html")) {
String page = new String(bytes, "UTF-8");
if (web) {
page = StringUtils.replaceAll(page, ANALYTICS_TAG, ANALYTICS_SCRIPT, false);
page = StringUtils.replaceAll(page, ANALYTICS_TAG, ANALYTICS_SCRIPT);
}
if (replaceFragments) {
page = replaceFragments(name, page);
page = StringUtils.replaceAll(page, "<a href=\"frame", "<a href=\"main", false);
page = StringUtils.replaceAll(page, "html/frame.html", "html/main.html", false);
page = StringUtils.replaceAll(page, "<a href=\"frame", "<a href=\"main");
page = StringUtils.replaceAll(page, "html/frame.html", "html/main.html");
}
if (web) {
page = StringUtils.replaceAll(page, TRANSLATE_START, "", false);
page = StringUtils.replaceAll(page, TRANSLATE_END, "", false);
page = StringUtils.replaceAll(page, "<pre>", "<pre class=\"notranslate\">", false);
page = StringUtils.replaceAll(page, "<code>", "<code class=\"notranslate\">", false);
page = StringUtils.replaceAll(page, TRANSLATE_START, "");
page = StringUtils.replaceAll(page, TRANSLATE_END, "");
page = StringUtils.replaceAll(page, "<pre>", "<pre class=\"notranslate\">");
page = StringUtils.replaceAll(page, "<code>", "<code class=\"notranslate\">");
}
bytes = page.getBytes("UTF-8");
}
......
......@@ -153,7 +153,7 @@ public class Doclet {
boolean isVarArgs = method.isVarArgs() && j == params.length - 1;
String typeName = getTypeName(false, isVarArgs, param.type());
buff.append(typeName);
buffSignature.append(StringUtils.replaceAll(typeName, "[]", "-", false));
buffSignature.append(StringUtils.replaceAll(typeName, "[]", "-"));
buff.append(' ');
buff.append(param.name());
}
......@@ -380,7 +380,7 @@ public class Doclet {
if (text == null) {
return text;
}
text = StringUtils.replaceAll(text, "\n </pre>", "</pre>", false);
text = StringUtils.replaceAll(text, "\n </pre>", "</pre>");
return text;
}
......
......@@ -129,16 +129,16 @@ public class PrepareTranslation {
map.put(k.toString(), prop.get(k));
}
String html = PageParser.parse(template, map);
html = StringUtils.replaceAll(html, "lang=\"" + MAIN_LANGUAGE + "\"", "lang=\"" + language + "\"", false);
html = StringUtils.replaceAll(html, "lang=\"" + MAIN_LANGUAGE + "\"", "lang=\"" + language + "\"");
for (String n : fileNames) {
if ("frame".equals(n)) {
// don't translate 'frame.html' to 'frame_ja.html',
// otherwise we can't switch back to English
continue;
}
html = StringUtils.replaceAll(html, n + ".html\"", n + "_" + language + ".html\"", false);
html = StringUtils.replaceAll(html, n + ".html\"", n + "_" + language + ".html\"");
}
html = StringUtils.replaceAll(html, "_" + MAIN_LANGUAGE + ".html\"", ".html\"", false);
html = StringUtils.replaceAll(html, "_" + MAIN_LANGUAGE + ".html\"", ".html\"");
String target;
if (language.equals(MAIN_LANGUAGE)) {
target = targetDir + "/" + name + ".html";
......@@ -376,7 +376,7 @@ public class PrepareTranslation {
text = text.replace('\r', ' ');
text = text.replace('\n', ' ');
while (true) {
String s = StringUtils.replaceAll(text, " ", " ", false);
String s = StringUtils.replaceAll(text, " ", " ");
if (s.equals(text)) {
break;
}
......
......@@ -146,8 +146,8 @@ public class PropertiesToUTF8 {
out.close();
}
String java = StringUtils.javaEncode(utf8);
java = StringUtils.replaceAll(java, "\\r", "\r", false);
java = StringUtils.replaceAll(java, "\\n", "\n", false);
java = StringUtils.replaceAll(java, "\\r", "\r");
java = StringUtils.replaceAll(java, "\\n", "\n");
RandomAccessFile out = new RandomAccessFile("_java." + name, "rw");
out.write(java.getBytes());
out.setLength(out.getFilePointer());
......
......@@ -447,7 +447,7 @@ public class FtpClient {
for (int i = 0; i < files.length; i++) {
String s = list[i];
while (true) {
String s2 = StringUtils.replaceAll(s, " ", " ", false);
String s2 = StringUtils.replaceAll(s, " ", " ");
if (s2.equals(s)) {
break;
}
......
......@@ -101,15 +101,15 @@ public class Railroads {
String text = map.get("text");
if (text != null) {
// text is enclosed in <p> .. </p> so this works.
text = StringUtils.replaceAll(text, "<br /><br />", "</p><p>", false);
text = StringUtils.replaceAll(text, "<br />", " ", false);
text = StringUtils.replaceAll(text, "<br /><br />", "</p><p>");
text = StringUtils.replaceAll(text, "<br />", " ");
map.put("text", text);
}
String link = topic.toLowerCase();
link = StringUtils.replaceAll(link, " ", "_", false);
link = StringUtils.replaceAll(link, " ", "_");
// link = StringUtils.replaceAll(link, "_", "");
link = StringUtils.replaceAll(link, "@", "_", false);
link = StringUtils.replaceAll(link, "@", "_");
map.put("link", StringUtils.urlEncode(link));
list.add(map);
}
......
......@@ -134,7 +134,7 @@ public class FunctionsMySQL {
private static String convertToSimpleDateFormat(String format) {
String[] replace = FORMAT_REPLACE;
for (int i = 0; i < replace.length; i += 2) {
format = StringUtils.replaceAll(format, replace[i], replace[i + 1], false);
format = StringUtils.replaceAll(format, replace[i], replace[i + 1]);
}
return format;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论