Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-06-18 03:21:48 -0400
committerKarsten Thoms2019-06-18 04:01:34 -0400
commit8587a3bbc00131b5cba94f05365e573f4b041b15 (patch)
tree37ec3acd4d2cf6e5cbaf7ffc6f33c24c455bba11
parentb3c2ede7a8454c5ec51e6aaab69e322fe4e92bdc (diff)
downloadeclipse.platform.swt-8587a3bbc00131b5cba94f05365e573f4b041b15.tar.gz
eclipse.platform.swt-8587a3bbc00131b5cba94f05365e573f4b041b15.tar.xz
eclipse.platform.swt-8587a3bbc00131b5cba94f05365e573f4b041b15.zip
Use String.contains instead of indexOf
Change-Id: Ib5e9ae7e066f809a0223299b5708462fcf6b66f9 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java2
-rw-r--r--examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java10
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/addressbook/AddressBook.java4
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java2
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet283.java4
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java8
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTError.java6
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTException.java6
8 files changed, 21 insertions, 21 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java
index 50e91651eb..0df7b1668b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java
@@ -226,7 +226,7 @@ static boolean isLoadable () {
static boolean load (String libName, StringBuilder message) {
try {
- if (libName.indexOf (SEPARATOR) != -1) {
+ if (libName.contains (SEPARATOR)) {
System.load (libName);
} else {
System.loadLibrary (libName);
diff --git a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java b/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java
index e1a709acce..388885b874 100644
--- a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java
+++ b/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java
@@ -143,8 +143,8 @@ public class PawnTab {
public void changing(LocationEvent e) {
try {
final Browser browser = (Browser)e.widget;
- if (e.location.indexOf(ACTION_START_1_PLAYER) != -1 || e.location.indexOf(ACTION_START_2_PLAYERS) != -1) {
- computer = e.location.indexOf(ACTION_START_1_PLAYER) != -1;
+ if (e.location.contains(ACTION_START_1_PLAYER) || e.location.contains(ACTION_START_2_PLAYERS)) {
+ computer = e.location.contains(ACTION_START_1_PLAYER);
game = new byte[8][8];
if (computer) ttr = new Pawns();
for (int i = 0; i < 5; i++) game[(int)(Math.random()*game.length)][(int)(Math.random()*game[0].length)] = WALL;
@@ -152,7 +152,7 @@ public class PawnTab {
e.doit = false;
return;
}
- if (e.location.indexOf(ACTION_THEME) != -1) {
+ if (e.location.contains(ACTION_THEME)) {
int index = e.location.indexOf(ACTION_THEME) + ACTION_THEME.length() + 1;
CSS_FOLDER = e.location.substring(index, index + 4);
URL_CSS = PLUGIN_PATH+CSS_FOLDER+"/style.css";
@@ -162,8 +162,8 @@ public class PawnTab {
return;
}
byte player = EMPTY;
- if (e.location.indexOf(ACTION_WHITE) != -1) player = WHITE;
- else if (e.location.indexOf(ACTION_BLACK) != -1) player = BLACK;
+ if (e.location.contains(ACTION_WHITE)) player = WHITE;
+ else if (e.location.contains(ACTION_BLACK)) player = BLACK;
if (player != EMPTY) {
int index = e.location.indexOf("xx") + 2;
int x = Integer.parseInt(e.location.substring(index, index + 1));
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/addressbook/AddressBook.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/addressbook/AddressBook.java
index e703cda541..8c3c6576ba 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/addressbook/AddressBook.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/addressbook/AddressBook.java
@@ -172,7 +172,7 @@ private String[] decodeLine(String line) {
}
}
- if (line.indexOf(DELIMITER) != -1) return null;
+ if (line.contains(DELIMITER)) return null;
parsedLine[parsedLine.length - 1] = line;
@@ -247,7 +247,7 @@ private boolean findMatch(String searchString, TableItem item, int column, boole
}
} else {
- if(tableText!= null && tableText.indexOf(searchString) != -1) {
+ if(tableText!= null && tableText.contains(searchString)) {
return true;
}
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java
index ef212e122f..a5fbf9d039 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java
@@ -1269,7 +1269,7 @@ public class FileViewer {
* On JDK 1.1.7 and beyond...
* -- PORTABILITY ISSUES HERE --
*/
- if (System.getProperty ("os.name").indexOf ("Windows") != -1) {
+ if (System.getProperty ("os.name").contains ("Windows")) {
List<File> list = new ArrayList<>();
list.add(new File(DRIVE_A));
list.add(new File(DRIVE_B));
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet283.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet283.java
index 1687af1f3c..9ad9a9e36c 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet283.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet283.java
@@ -68,8 +68,8 @@ public class Snippet283 {
table.addListener(SWT.EraseItem, event -> {
event.detail &= ~SWT.FOREGROUND;
String osName = System.getProperty("os.name");
- if (osName != null && osName.indexOf ("Windows") != -1) {
- if (osName.indexOf ("Vista") != -1 || osName.indexOf ("unknown") != -1) {
+ if (osName != null && osName.contains ("Windows")) {
+ if (osName.contains ("Vista") || osName.contains ("unknown")) {
return;
}
}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java
index 5c49658464..365e26dbd1 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java
@@ -58,19 +58,19 @@ public class SnippetLauncher {
System.out.println(source.substring(start, end-3));
boolean skip = false;
String platform = SWT.getPlatform();
- if (source.indexOf("PocketPC") != -1) {
+ if (source.contains("PocketPC")) {
platform = "PocketPC";
skip = true;
- } else if (source.indexOf("OpenGL") != -1) {
+ } else if (source.contains("OpenGL")) {
platform = "OpenGL";
skip = true;
- } else if (source.indexOf("JavaXPCOM") != -1) {
+ } else if (source.contains("JavaXPCOM")) {
platform = "JavaXPCOM";
skip = true;
} else {
String [] platforms = {"win32", "gtk"};
for (int p = 0; p < platforms.length; p++) {
- if (!platforms[p].equals(platform) && source.indexOf("." + platforms[p]) != -1) {
+ if (!platforms[p].equals(platform) && source.contains("." + platforms[p])) {
platform = platforms[p];
skip = true;
break;
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTError.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTError.java
index 0abd3ff8b2..00139b124d 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTError.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTError.java
@@ -64,7 +64,7 @@ public void test_getMessage() {
assertTrue (
"did not include creation string in result",
new SWTError(SWT.ERROR_CANNOT_BE_ZERO, "An interesting message").getMessage()
- .indexOf("An interesting message") >= 0);
+ .contains("An interesting message"));
}
@Test
@@ -86,7 +86,7 @@ public void test_printStackTrace() {
SWTError error = new SWTError();
error.printStackTrace();
assertTrue(out.size() > 0);
- assertTrue(new String(out.toByteArray()).indexOf("test_printStackTrace") != -1);
+ assertTrue(new String(out.toByteArray()).contains("test_printStackTrace"));
// test SWTError with code
@@ -95,6 +95,6 @@ public void test_printStackTrace() {
error = new SWTError(SWT.ERROR_INVALID_ARGUMENT);
error.printStackTrace();
assertTrue(out.size() > 0);
- assertTrue(new String(out.toByteArray()).indexOf("test_printStackTrace") != -1);
+ assertTrue(new String(out.toByteArray()).contains("test_printStackTrace"));
}
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTException.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTException.java
index c570971646..45411973f2 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTException.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_SWTException.java
@@ -65,7 +65,7 @@ public void test_getMessage() {
assertTrue (
"did not include creation string in result",
new SWTException(SWT.ERROR_CANNOT_BE_ZERO, "An interesting message").getMessage()
- .indexOf("An interesting message") >= 0);
+ .contains("An interesting message"));
}
@Test
@@ -87,7 +87,7 @@ public void test_printStackTrace() {
SWTException error = new SWTException();
error.printStackTrace();
assertTrue(out.size() > 0);
- assertTrue(new String(out.toByteArray()).indexOf("test_printStackTrace") != -1);
+ assertTrue(new String(out.toByteArray()).contains("test_printStackTrace"));
// test SWTException with code
@@ -96,6 +96,6 @@ public void test_printStackTrace() {
error = new SWTException(SWT.ERROR_INVALID_ARGUMENT);
error.printStackTrace();
assertTrue(out.size() > 0);
- assertTrue(new String(out.toByteArray()).indexOf("test_printStackTrace") != -1);
+ assertTrue(new String(out.toByteArray()).contains("test_printStackTrace"));
}
}

Back to the top