提交 4945dcc0 authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

simplify "indexOf(x) >= 0" to "contains(x)"

上级 43919469
......@@ -684,7 +684,7 @@ public class Session extends SessionWithState {
*/
public void addLock(Table table) {
if (SysProperties.CHECK) {
if (locks.indexOf(table) >= 0) {
if (locks.contains(table)) {
DbException.throwInternalError();
}
}
......@@ -1127,7 +1127,7 @@ public class Session extends SessionWithState {
String identifier;
do {
identifier = SYSTEM_IDENTIFIER_PREFIX + systemIdentifier++;
} while (sql.indexOf(identifier) >= 0);
} while (sql.contains(identifier));
return identifier;
}
......
......@@ -1960,14 +1960,14 @@ public class Function extends Expression implements FunctionCall {
}
StringBuilder s = new StringBuilder();
s.append(d);
if (s.toString().indexOf("E") >= 0) {
if (s.toString().indexOf('E') >= 0) {
return d;
}
int len = s.length();
if (len < 16) {
return d;
}
if (s.toString().indexOf(".") > len - 3) {
if (s.toString().indexOf('.') > len - 3) {
return d;
}
s.delete(len - 2, len);
......
......@@ -146,7 +146,7 @@ public class JdbcSQLException extends SQLException {
* INTERNAL
*/
public void setSQL(String sql) {
if (sql != null && sql.indexOf(HIDE_SQL) >= 0) {
if (sql != null && sql.contains(HIDE_SQL)) {
sql = "-";
}
this.sql = sql;
......
......@@ -1267,10 +1267,10 @@ public class WebApp {
sql = sql.trim();
StringBuilder buff = new StringBuilder();
String sqlUpper = StringUtils.toUpperEnglish(sql);
if (sqlUpper.indexOf("CREATE") >= 0 ||
sqlUpper.indexOf("DROP") >= 0 ||
sqlUpper.indexOf("ALTER") >= 0 ||
sqlUpper.indexOf("RUNSCRIPT") >= 0) {
if (sqlUpper.contains("CREATE") ||
sqlUpper.contains("DROP") ||
sqlUpper.contains("ALTER") ||
sqlUpper.contains("RUNSCRIPT")) {
String sessionId = attributes.getProperty("jsessionid");
buff.append("<script type=\"text/javascript\">" +
"parent['h2menu'].location='tables.do?jsessionid="
......
......@@ -280,7 +280,7 @@ class WebThread extends WebApp implements Runnable {
len = Integer.parseInt(getHeaderLineValue(line));
trace("len=" + len);
} else if (lower.startsWith("user-agent")) {
boolean isWebKit = lower.indexOf("webkit/") >= 0;
boolean isWebKit = lower.contains("webkit/");
if (isWebKit && session != null) {
// workaround for what seems to be a WebKit bug:
// http://code.google.com/p/chromium/issues/detail?id=6402
......
......@@ -329,7 +329,7 @@ public class PageStore implements CacheWriter {
file = database.openFile(fileName, accessMode, true);
} catch (DbException e) {
if (e.getErrorCode() == ErrorCode.IO_EXCEPTION_2) {
if (e.getMessage().indexOf("locked") >= 0) {
if (e.getMessage().contains("locked")) {
// in Windows, you can't open a locked file
// (in other operating systems, you can)
// the exact error message is:
......
......@@ -691,7 +691,7 @@ public class MetaTable extends Table {
}
String sql = table.getCreateSQL();
if (!admin) {
if (sql != null && sql.indexOf(JdbcSQLException.HIDE_SQL) >= 0) {
if (sql != null && sql.contains(JdbcSQLException.HIDE_SQL)) {
// hide the password of linked tables
sql = "-";
}
......
......@@ -941,7 +941,7 @@ public class TableFilter implements ColumnResolver {
* @return true if this is a joined natural join column
*/
public boolean isNaturalJoinColumn(Column c) {
return naturalJoinColumns != null && naturalJoinColumns.indexOf(c) >= 0;
return naturalJoinColumns != null && naturalJoinColumns.contains(c);
}
@Override
......
......@@ -623,13 +623,13 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
if (browser.startsWith("call:")) {
browser = browser.substring("call:".length());
Utils.callStaticMethod(browser, url);
} else if (browser.indexOf("%url") >= 0) {
} else if (browser.contains("%url")) {
String[] args = StringUtils.arraySplit(browser, ',', false);
for (int i = 0; i < args.length; i++) {
args[i] = StringUtils.replaceAll(args[i], "%url", url);
}
rt.exec(args);
} else if (osName.indexOf("windows") >= 0) {
} else if (osName.contains("windows")) {
rt.exec(new String[] { "cmd.exe", "/C", browser, url });
} else {
rt.exec(new String[] { browser, url });
......@@ -655,9 +655,9 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
} catch (Exception e) {
// ignore
}
if (osName.indexOf("windows") >= 0) {
if (osName.contains("windows")) {
rt.exec(new String[] { "rundll32", "url.dll,FileProtocolHandler", url });
} else if (osName.indexOf("mac") >= 0 || osName.indexOf("darwin") >= 0) {
} else if (osName.contains("mac") || osName.contains("darwin")) {
// Mac OS: to open a page with Safari, use "open -a Safari"
Runtime.getRuntime().exec(new String[] { "open", url });
} else {
......
......@@ -619,7 +619,7 @@ public class StringUtils {
* @return <![CDATA[data]]>
*/
public static String xmlCData(String data) {
if (data.indexOf("]]>") >= 0) {
if (data.contains("]]>")) {
return xmlText(data);
}
boolean newline = data.endsWith("\n");
......
......@@ -589,7 +589,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
*/
private static boolean isCoverage() {
for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
if (e.toString().indexOf(".emma.") >= 0) {
if (e.toString().contains(".emma.")) {
return true;
}
}
......
......@@ -137,7 +137,7 @@ public class TestCompatibility extends TestBase {
String tableName = meta.getTableName(1);
if ("ID".equals(columnName) && "TEST".equals(tableName)) {
assertTrue(mode + " mode should not support columnAlias",
columnAlias.indexOf(mode) >= 0);
columnAlias.contains(mode));
} else if ("I".equals(columnName) && tableName.equals("")) {
assertTrue(mode + " mode should support columnAlias",
columnAlias.indexOf(mode) < 0);
......@@ -160,7 +160,7 @@ public class TestCompatibility extends TestBase {
try {
stat.execute("INSERT INTO TEST VALUES(1), (2), (NULL), (NULL)");
assertTrue(mode + " mode should not support multiple NULL",
multiNull.indexOf(mode) >= 0);
multiNull.contains(mode));
} catch (SQLException e) {
assertTrue(mode + " mode should support multiple NULL",
multiNull.indexOf(mode) < 0);
......
......@@ -333,7 +333,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
ResultSet rs;
rs = stat.executeQuery("select * from information_schema.views");
rs.next();
assertTrue(rs.getString("VIEW_DEFINITION").indexOf("SCHEMA2.FUNC") >= 0);
assertTrue(rs.getString("VIEW_DEFINITION").contains("SCHEMA2.FUNC"));
stat.execute("drop view test");
stat.execute("drop schema schema2");
......@@ -736,7 +736,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
boolean found = false;
while (rs.next()) {
String sql = rs.getString(1);
if (sql.indexOf("MEDIAN") >= 0) {
if (sql.contains("MEDIAN")) {
found = true;
}
}
......
......@@ -147,7 +147,7 @@ public class TestIndex extends TestBase {
int start = m.indexOf('\"'), end = m.indexOf('\"', start + 1);
String s = m.substring(start + 1, end);
for (String t : expected) {
assertTrue(t + " not in " + s, s.indexOf(t) >= 0);
assertTrue(t + " not in " + s, s.contains(t));
}
}
stat.execute("drop table test");
......
......@@ -138,7 +138,7 @@ public class TestLinkedTable extends TestBase {
"(null, 'jdbc:h2:mem:', 'sa', 'pwd', 'DUAL2')");
fail();
} catch (SQLException e) {
assertTrue(e.toString().indexOf("pwd") >= 0);
assertTrue(e.toString().contains("pwd"));
}
try {
conn.createStatement().execute("create linked table test" +
......
......@@ -110,7 +110,7 @@ public class TestListener extends TestBase implements DatabaseEventListener {
@Override
public void closingDatabase() {
if (databaseUrl.toUpperCase().indexOf("CIPHER") >= 0) {
if (databaseUrl.toUpperCase().contains("CIPHER")) {
return;
}
Connection conn = null;
......@@ -132,7 +132,7 @@ public class TestListener extends TestBase implements DatabaseEventListener {
@Override
public void opened() {
if (databaseUrl.toUpperCase().indexOf("CIPHER") >= 0) {
if (databaseUrl.toUpperCase().contains("CIPHER")) {
return;
}
Connection conn = null;
......
......@@ -311,12 +311,12 @@ public class TestOptimizations extends TestBase {
rs = stat.executeQuery("explain select * from test " +
"where id > 10 order by id");
rs.next();
assertTrue(rs.getString(1).indexOf("IDX_ID_ASC") >= 0);
assertTrue(rs.getString(1).contains("IDX_ID_ASC"));
rs = stat.executeQuery("explain select * from test " +
"where id < 10 order by id desc");
rs.next();
assertTrue(rs.getString(1).indexOf("IDX_ID_DESC") >= 0);
assertTrue(rs.getString(1).contains("IDX_ID_DESC"));
rs.next();
stat.execute("drop table test");
......
......@@ -67,7 +67,7 @@ public class TestRights extends TestBase {
ResultSetMetaData meta = rs.getMetaData();
for (int i = 1; i <= meta.getColumnCount(); i++) {
String s = rs.getString(i);
assertFalse(s != null && s.indexOf("'sa'") >= 0);
assertFalse(s != null && s.contains("'sa'"));
}
conn2.close();
// password is visible to admin
......@@ -79,7 +79,7 @@ public class TestRights extends TestBase {
boolean foundPassword = false;
for (int i = 1; i <= meta.getColumnCount(); i++) {
String s = rs.getString(i);
if (s != null && s.indexOf("'sa'") >= 0) {
if (s != null && s.contains("'sa'")) {
foundPassword = true;
}
}
......
......@@ -154,7 +154,7 @@ public class TestScript extends TestBase {
while (rs.next()) {
String sql = rs.getString("SQL");
if (sql != null) {
if (sql.indexOf("TEMPORARY") >= 0) {
if (sql.contains("TEMPORARY")) {
return true;
}
}
......@@ -281,7 +281,7 @@ public class TestScript extends TestBase {
}
private void writeResultSet(String sql, ResultSet rs) throws Exception {
boolean ordered = StringUtils.toLowerEnglish(sql).indexOf("order by") >= 0;
boolean ordered = StringUtils.toLowerEnglish(sql).contains("order by");
ResultSetMetaData meta = rs.getMetaData();
int len = meta.getColumnCount();
int[] max = new int[len];
......
......@@ -774,7 +774,7 @@ public class TestPreparedStatement extends TestBase {
ResultSet rs = prep.executeQuery();
rs.next();
String plan = rs.getString(1);
assertTrue(plan.indexOf(".tableScan") >= 0);
assertTrue(plan.contains(".tableScan"));
rs = prepExe.executeQuery();
rs.next();
assertEquals("World", rs.getString(2));
......@@ -785,7 +785,7 @@ public class TestPreparedStatement extends TestBase {
rs = prep.executeQuery();
rs.next();
String plan1 = rs.getString(1);
assertTrue(plan1.indexOf("IDXNAME") >= 0);
assertTrue(plan1.contains("IDXNAME"));
rs = prepExe.executeQuery();
rs.next();
assertEquals("Hello", rs.getString(2));
......
......@@ -104,7 +104,7 @@ public class TestConnectionPool extends TestBase {
man.getConnection();
fail();
} catch (SQLException e) {
assertTrue(e.toString().toLowerCase().indexOf("timeout") >= 0);
assertTrue(e.toString().toLowerCase().contains("timeout"));
time = System.currentTimeMillis() - time;
assertTrue("timeout after " + time + " ms", time > 1000);
} finally {
......
......@@ -141,7 +141,7 @@ public class TestWeb extends TestBase {
Server server = Server.createWebServer(
"-webPort", "8182", "-properties", "null");
server.start();
assertTrue(server.getStatus().indexOf("server running") >= 0);
assertTrue(server.getStatus().contains("server running"));
Server server2 = Server.createWebServer(
"-webPort", "8182", "-properties", "null");
assertEquals("Not started", server2.getStatus());
......@@ -149,9 +149,9 @@ public class TestWeb extends TestBase {
server2.start();
fail();
} catch (Exception e) {
assertTrue(e.toString().indexOf("port may be in use") >= 0);
assertTrue(server2.getStatus().indexOf(
"could not be started") >= 0);
assertTrue(e.toString().contains("port may be in use"));
assertTrue(server2.getStatus().contains(
"could not be started"));
}
server.stop();
}
......
......@@ -281,7 +281,7 @@ public class TestMVTableEngine extends TestBase {
rs.next();
plan = rs.getString(1);
// transaction log is larger than the table, so read the table
assertTrue(plan, plan.indexOf("reads:") >= 0);
assertTrue(plan, plan.contains("reads:"));
rs = stat2.executeQuery("select count(*) from test");
rs.next();
assertEquals(10000, rs.getInt(1));
......@@ -363,7 +363,7 @@ public class TestMVTableEngine extends TestBase {
rs.next();
String plan = rs.getString(1);
// expect about 249 reads
assertTrue(plan, plan.indexOf("reads: 2") >= 0);
assertTrue(plan, plan.contains("reads: 2"));
conn.close();
}
......
......@@ -406,7 +406,7 @@ if (connectTime > 2000) {
private void printIfBad(int seed, int id, int objectId, Throwable t) {
if (t instanceof BatchUpdateException) {
// do nothing
} else if (t.getClass().getName().indexOf("SQLClientInfoException") >= 0) {
} else if (t.getClass().getName().contains("SQLClientInfoException")) {
// do nothing
} else if (t instanceof SQLException) {
SQLException s = (SQLException) t;
......
......@@ -290,7 +290,7 @@ public class TestNestedJoins extends TestBase {
"inner join c on c.id = b.id on b.id = a.id");
assertTrue(rs.next());
sql = rs.getString(1);
assertTrue("nested", sql.indexOf("(") >= 0);
assertTrue("nested", sql.contains("("));
stat.execute("drop table a, b, c");
// see roadmap, tag: swapInnerJoinTables
......@@ -355,7 +355,7 @@ public class TestNestedJoins extends TestBase {
"left outer join (test c) on a.id = c.id");
assertTrue(rs.next());
sql = rs.getString(1);
assertTrue(sql.indexOf("PRIMARY_KEY") >= 0);
assertTrue(sql.contains("PRIMARY_KEY"));
stat.execute("drop table test");
/*
......@@ -634,7 +634,7 @@ public class TestNestedJoins extends TestBase {
r.setSkipRemarks(true);
sql = r.readStatement();
sql = sql.replaceAll("\\n", " ");
while (sql.indexOf(" ") >= 0) {
while (sql.contains(" ")) {
sql = sql.replaceAll(" ", " ");
}
return sql;
......
......@@ -309,7 +309,7 @@ public class TestOuterJoins extends TestBase {
"left outer join (test c) on a.id = c.id");
assertTrue(rs.next());
sql = rs.getString(1);
assertTrue(sql.indexOf("PRIMARY_KEY") >= 0);
assertTrue(sql.contains("PRIMARY_KEY"));
stat.execute("drop table test");
/*
......@@ -584,7 +584,7 @@ public class TestOuterJoins extends TestBase {
r.setSkipRemarks(true);
sql = r.readStatement();
sql = sql.replaceAll("\\n", " ");
while (sql.indexOf(" ") >= 0) {
while (sql.contains(" ")) {
sql = sql.replaceAll(" ", " ");
}
return sql;
......
......@@ -186,8 +186,8 @@ class Parser {
Float v = Float.parseFloat(number);
return new Arg(float.class, v);
} else if (number.endsWith("d") ||
number.indexOf("e") >= 0 ||
number.indexOf(".") >= 0) {
number.indexOf('e') >= 0 ||
number.indexOf('.') >= 0) {
Double v = Double.parseDouble(number);
return new Arg(double.class, v);
} else if (number.endsWith("L") || number.endsWith("l")) {
......
......@@ -120,7 +120,7 @@ public class TestClearReferences extends TestBase {
try {
clazz = Class.forName(className);
} catch (NoClassDefFoundError e) {
if (e.toString().indexOf("lucene") >= 0) {
if (e.toString().contains("lucene")) {
// Lucene is not in the classpath, OK
}
} catch (ClassNotFoundException e) {
......@@ -142,13 +142,13 @@ public class TestClearReferences extends TestBase {
try {
fields = clazz.getDeclaredFields();
} catch (NoClassDefFoundError e) {
if (e.toString().indexOf("lucene") >= 0) {
if (e.toString().contains("lucene")) {
// Lucene is not in the classpath, OK
return;
} else if (e.toString().indexOf("jts") >= 0) {
} else if (e.toString().contains("jts")) {
// JTS is not in the classpath, OK
return;
} else if (e.toString().indexOf("slf4j") >= 0) {
} else if (e.toString().contains("slf4j")) {
// slf4j is not in the classpath, OK
return;
}
......
......@@ -98,32 +98,32 @@ public class TestJmx extends TestBase {
getAttribute(name, "Version").toString().startsWith("1."));
assertEquals(14, info.getAttributes().length);
result = mbeanServer.invoke(name, "listSettings", null, null).toString();
assertTrue(result.indexOf("ANALYZE_AUTO") >= 0);
assertTrue(result.contains("ANALYZE_AUTO"));
conn.setAutoCommit(false);
stat.execute("create table test(id int)");
stat.execute("insert into test values(1)");
result = mbeanServer.invoke(name, "listSessions", null, null).toString();
assertTrue(result.indexOf("session id") >= 0);
assertTrue(result.contains("session id"));
if (config.mvcc) {
assertTrue(result.indexOf("read lock") >= 0);
assertTrue(result.contains("read lock"));
} else {
assertTrue(result.indexOf("write lock") >= 0);
assertTrue(result.contains("write lock"));
}
assertEquals(2, info.getOperations().length);
assertTrue(info.getDescription().indexOf("database") >= 0);
assertTrue(info.getDescription().contains("database"));
attrMap = New.hashMap();
for (MBeanAttributeInfo a : info.getAttributes()) {
attrMap.put(a.getName(), a);
}
assertTrue(attrMap.get("CacheSize").getDescription().indexOf("KB") >= 0);
assertTrue(attrMap.get("CacheSize").getDescription().contains("KB"));
opMap = New.hashMap();
for (MBeanOperationInfo o : info.getOperations()) {
opMap.put(o.getName(), o);
}
assertTrue(opMap.get("listSessions").getDescription().indexOf("lock") >= 0);
assertTrue(opMap.get("listSessions").getDescription().contains("lock"));
assertEquals(MBeanOperationInfo.INFO, opMap.get("listSessions").getImpact());
conn.close();
......
......@@ -231,8 +231,8 @@ public class TestPgServer extends TestBase {
"select version(), pg_postmaster_start_time(), current_schema()");
rs.next();
String s = rs.getString(1);
assertTrue(s.indexOf("H2") >= 0);
assertTrue(s.indexOf("PostgreSQL") >= 0);
assertTrue(s.contains("H2"));
assertTrue(s.contains("PostgreSQL"));
s = rs.getString(2);
s = rs.getString(3);
assertEquals(s, "PUBLIC");
......
......@@ -160,7 +160,7 @@ public class TestRecovery extends TestBase {
byte[] buff = new byte[Constants.DEFAULT_PAGE_SIZE];
while (f.position() < f.size()) {
FileUtils.readFully(f, ByteBuffer.wrap(buff));
if (new String(buff).indexOf("Hello World1") >= 0) {
if (new String(buff).contains("Hello World1")) {
buff[buff.length - 1]++;
f.position(f.position() - buff.length);
f.write(ByteBuffer.wrap(buff));
......@@ -291,7 +291,7 @@ public class TestRecovery extends TestBase {
rec.setOut(new PrintStream(buff));
rec.runTool("-dir", getBaseDir(), "-db", "recovery", "-trace");
String out = new String(buff.toByteArray());
assertTrue(out.indexOf("Created file") >= 0);
assertTrue(out.contains("Created file"));
Connection conn2 = getConnection("recovery2");
Statement stat2 = conn2.createStatement();
......
......@@ -508,36 +508,36 @@ public class TestTools extends TestBase {
Connection conn;
result = runServer(0, new String[]{"-?"});
assertTrue(result.indexOf("Starts the H2 Console") >= 0);
assertTrue(result.contains("Starts the H2 Console"));
assertTrue(result.indexOf("Unknown option") < 0);
result = runServer(1, new String[]{"-xy"});
assertTrue(result.indexOf("Starts the H2 Console") >= 0);
assertTrue(result.indexOf("Feature not supported") >= 0);
assertTrue(result.contains("Starts the H2 Console"));
assertTrue(result.contains("Feature not supported"));
result = runServer(0, new String[]{"-tcp",
"-tcpPort", "9001", "-tcpPassword", "abc"});
assertTrue(result.indexOf("tcp://") >= 0);
assertTrue(result.indexOf(":9001") >= 0);
assertTrue(result.indexOf("only local") >= 0);
assertTrue(result.contains("tcp://"));
assertTrue(result.contains(":9001"));
assertTrue(result.contains("only local"));
assertTrue(result.indexOf("Starts the H2 Console") < 0);
conn = getConnection("jdbc:h2:tcp://localhost:9001/mem:", "sa", "sa");
conn.close();
result = runServer(0, new String[]{"-tcpShutdown",
"tcp://localhost:9001", "-tcpPassword", "abc", "-tcpShutdownForce"});
assertTrue(result.indexOf("Shutting down") >= 0);
assertTrue(result.contains("Shutting down"));
result = runServer(0, new String[]{"-tcp",
"-tcpAllowOthers", "-tcpPort", "9001", "-tcpPassword", "abcdef", "-tcpSSL"});
assertTrue(result.indexOf("ssl://") >= 0);
assertTrue(result.indexOf(":9001") >= 0);
assertTrue(result.indexOf("others can") >= 0);
assertTrue(result.contains("ssl://"));
assertTrue(result.contains(":9001"));
assertTrue(result.contains("others can"));
assertTrue(result.indexOf("Starts the H2 Console") < 0);
conn = getConnection("jdbc:h2:ssl://localhost:9001/mem:", "sa", "sa");
conn.close();
result = runServer(0, new String[]{"-tcpShutdown",
"ssl://localhost:9001", "-tcpPassword", "abcdef"});
assertTrue(result.indexOf("Shutting down") >= 0);
assertTrue(result.contains("Shutting down"));
assertThrows(ErrorCode.CONNECTION_BROKEN_1, this).
getConnection("jdbc:h2:ssl://localhost:9001/mem:", "sa", "sa");
......@@ -546,21 +546,21 @@ public class TestTools extends TestBase {
"-pg", "-pgAllowOthers", "-pgPort", "9003",
"-tcp", "-tcpAllowOthers", "-tcpPort", "9006", "-tcpPassword", "abc"});
Server stop = server;
assertTrue(result.indexOf("https://") >= 0);
assertTrue(result.indexOf(":9002") >= 0);
assertTrue(result.indexOf("pg://") >= 0);
assertTrue(result.indexOf(":9003") >= 0);
assertTrue(result.indexOf("others can") >= 0);
assertTrue(result.contains("https://"));
assertTrue(result.contains(":9002"));
assertTrue(result.contains("pg://"));
assertTrue(result.contains(":9003"));
assertTrue(result.contains("others can"));
assertTrue(result.indexOf("only local") < 0);
assertTrue(result.indexOf("tcp://") >= 0);
assertTrue(result.indexOf(":9006") >= 0);
assertTrue(result.contains("tcp://"));
assertTrue(result.contains(":9006"));
conn = getConnection("jdbc:h2:tcp://localhost:9006/mem:", "sa", "sa");
conn.close();
result = runServer(0, new String[]{"-tcpShutdown",
"tcp://localhost:9006", "-tcpPassword", "abc", "-tcpShutdownForce"});
assertTrue(result.indexOf("Shutting down") >= 0);
assertTrue(result.contains("Shutting down"));
stop.shutdown();
assertThrows(ErrorCode.CONNECTION_BROKEN_1, this).
getConnection("jdbc:h2:tcp://localhost:9006/mem:", "sa", "sa");
......@@ -868,7 +868,7 @@ public class TestTools extends TestBase {
tool.setOut(new PrintStream(buff));
tool.runTool("-url", url, "-user", user, "-password", password,
"-script", fileName + ".txt", "-showResults");
assertTrue(buff.toString().indexOf("Hello") >= 0);
assertTrue(buff.toString().contains("Hello"));
}
private void testBackupRestore() throws SQLException {
......
......@@ -295,7 +295,7 @@ public class BuildBase {
}
private static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0;
return System.getProperty("os.name").toLowerCase().contains("windows");
}
/**
......
......@@ -90,7 +90,7 @@ public class LinkChecker {
if (targets.get(name).equals("id")) {
boolean ignore = false;
for (String to : IGNORE_MISSING_LINKS_TO) {
if (name.indexOf(to) >= 0) {
if (name.contains(to)) {
ignore = true;
break;
}
......
......@@ -56,7 +56,7 @@ public class UploadBuild {
byte[] data = IOUtils.readBytesAndClose(
new FileInputStream("coverage/index.html"), -1);
String index = new String(data, "ISO-8859-1");
coverageFailed = index.indexOf("CLASS=\"h\"") >= 0;
coverageFailed = index.contains("CLASS=\"h\"");
while (true) {
int idx = index.indexOf("<A HREF=\"");
if (idx < 0) {
......@@ -90,7 +90,7 @@ public class UploadBuild {
if (new File("docs/html/testOutput.html").exists()) {
testOutput = IOUtils.readStringAndClose(
new FileReader("docs/html/testOutput.html"), -1);
error = testOutput.indexOf(OutputCatcher.START_ERROR) >= 0;
error = testOutput.contains(OutputCatcher.START_ERROR);
} else if (new File("log.txt").exists()) {
testOutput = IOUtils.readStringAndClose(new FileReader("log.txt"), -1);
error = true;
......
......@@ -196,7 +196,7 @@ public class Indexer {
if (!lower.endsWith(".html") && !lower.endsWith(".htm")) {
return;
}
if (lower.indexOf("_ja.") >= 0) {
if (lower.contains("_ja.")) {
return;
}
if (!noIndex.contains(fileName)) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论