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