Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2012-02-20 18:16:54 -0500
committerRyan D. Brooks2012-02-20 18:16:54 -0500
commit8cedf4b061280c35ea479f117ae486b5a9e628d9 (patch)
tree7db32e87db98d30793339c94bb08266857a2ebeb
parentcca5f74ba5483f57d0117858e6ab5d3506254da4 (diff)
downloadorg.eclipse.osee-8cedf4b061280c35ea479f117ae486b5a9e628d9.tar.gz
org.eclipse.osee-8cedf4b061280c35ea479f117ae486b5a9e628d9.tar.xz
org.eclipse.osee-8cedf4b061280c35ea479f117ae486b5a9e628d9.zip
bug[ats_L9Q6R]: Quick Search case insensitive not working correctly
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/WordOrderMatcherTest.java10
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java42
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcherTest.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcher.java42
4 files changed, 74 insertions, 30 deletions
diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/WordOrderMatcherTest.java b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/WordOrderMatcherTest.java
index 05535bbd8c..7050d46a61 100644
--- a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/WordOrderMatcherTest.java
+++ b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/WordOrderMatcherTest.java
@@ -63,6 +63,16 @@ public class WordOrderMatcherTest {
addTest(data, "Why is this here this again.", "THIS", false, true, getLocs(8, 11, 18, 21));
addTest(data, "hello #@!@$$%'- again.", "hello again", false, false, getLocs(1, 21));
addTest(data, "hello word again.", "hello again", false, false, getLocs());
+ addTest(data, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID", false, false,
+ getLocs(18, 35));
+ addTest(data, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID", true, false,
+ getLocs(18, 35));
+ addTest(data, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", true, false, getLocs(41, 58));
+ addTest(data, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", false, false, getLocs(41, 58));
+ addTest(data, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_\nID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", false, false, getLocs(41, 59));
return data;
}
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java
index dcf2b02829..378f52f47b 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.framework.search.engine.utility;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -36,7 +37,9 @@ public final class WordOrderMatcher {
List<MatchLocation> matchLocations = new ArrayList<MatchLocation>();
Reader reader = null;
try {
- reader = new InputStreamReader(inputStream, "UTF-8");
+ boolean matchedAWhitespace = false;
+ int savedCharCount = 0;
+ reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
boolean isCaseInsensitive = !options.isCaseSensitive();
char[] charsToSearch = WordsUtil.removeExtraSpacesAndSpecialCharacters(toSearch, isCaseInsensitive);
int charCount = 0;
@@ -45,6 +48,7 @@ public final class WordOrderMatcher {
boolean lastCharacterAddedWasWhiteSpace = false;
boolean currCharValid = false;
MatchLocation matchLocation = new MatchLocation();
+ reader.mark(charsToSearch.length);
while (value != -1) {
value = reader.read();
charCount++;
@@ -53,31 +57,39 @@ public final class WordOrderMatcher {
currChar = Character.toLowerCase(currChar);
}
- if (currChar != '\r' && currChar != '\n') {
- if (WordsUtil.isPunctuationOrApostrophe(currChar)) {
- currChar = ' ';
- }
+ if (WordsUtil.isPunctuationOrApostrophe(currChar)) {
+ currChar = ' ';
+ }
- if (Character.isWhitespace(currChar)) {
- if (!lastCharacterAddedWasWhiteSpace) {
- currCharValid = true;
- lastCharacterAddedWasWhiteSpace = true;
- } else {
- currCharValid = false;
- }
- } else {
+ if (Character.isWhitespace(currChar)) {
+ reader.mark(toSearch.length());
+ savedCharCount = charCount;
+ if (!lastCharacterAddedWasWhiteSpace) {
currCharValid = true;
- lastCharacterAddedWasWhiteSpace = false;
+ lastCharacterAddedWasWhiteSpace = true;
+ } else {
+ currCharValid = false;
}
+ } else {
+ currCharValid = true;
+ lastCharacterAddedWasWhiteSpace = false;
}
if (currCharValid) {
if (charsToSearch[index] != currChar) {
- index = 0;
matchLocation.reset();
+ if (matchedAWhitespace) {
+ reader.reset();
+ charCount = savedCharCount;
+ }
+ index = 0;
+ matchedAWhitespace = false;
}
if (charsToSearch[index] == currChar) {
+ if (currChar == ' ' && index > 0) {
+ matchedAWhitespace = true;
+ }
if (index == 0) {
matchLocation.setStartPosition(charCount);
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcherTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcherTest.java
index fcc303aa90..8e6c80667d 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcherTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcherTest.java
@@ -66,6 +66,16 @@ public class WordOrderMatcherTest {
addTest(data, "Why is this here this again.", "THIS", CaseType.IGNORE_CASE, true, getLocs(8, 11, 18, 21));
addTest(data, "hello #@!@$$%'- again.", "hello again", CaseType.IGNORE_CASE, false, getLocs(1, 21));
addTest(data, "hello word again.", "hello again", CaseType.IGNORE_CASE, false, getLocs());
+ addTest(data, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID",
+ CaseType.IGNORE_CASE, false, getLocs(18, 35));
+ addTest(data, " (Selected) -> [.SELECTED_STRING_ID] Selected -> ", "SELECTED_STRING_ID",
+ CaseType.MATCH_CASE, false, getLocs(18, 35));
+ addTest(data, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", CaseType.MATCH_CASE, false, getLocs(41, 58));
+ addTest(data, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_ID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", CaseType.IGNORE_CASE, false, getLocs(41, 58));
+ addTest(data, " (Selected) -> [.SELECTED_STRING_IWRONG SELECTED_STRING_\nID_TWO] Selected -> ",
+ "SELECTED_STRING_ID", CaseType.IGNORE_CASE, false, getLocs(41, 59));
return data;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcher.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcher.java
index b459766c67..d8c372298d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcher.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/WordOrderMatcher.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.util;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -36,7 +37,9 @@ public final class WordOrderMatcher {
List<MatchLocation> matchLocations = new ArrayList<MatchLocation>();
Reader reader = null;
try {
- reader = new InputStreamReader(inputStream, "UTF-8");
+ boolean matchedAWhitespace = false;
+ int savedCharCount = 0;
+ reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
boolean isCaseInsensitive = !caseType.isCaseSensitive();
char[] charsToSearch = WordsUtil.removeExtraSpacesAndSpecialCharacters(toSearch, isCaseInsensitive);
int charCount = 0;
@@ -45,6 +48,7 @@ public final class WordOrderMatcher {
boolean lastCharacterAddedWasWhiteSpace = false;
boolean currCharValid = false;
MatchLocation matchLocation = new MatchLocation();
+ reader.mark(charsToSearch.length);
while (value != -1) {
value = reader.read();
charCount++;
@@ -53,31 +57,39 @@ public final class WordOrderMatcher {
currChar = Character.toLowerCase(currChar);
}
- if (currChar != '\r' && currChar != '\n') {
- if (WordsUtil.isPunctuationOrApostrophe(currChar)) {
- currChar = ' ';
- }
+ if (WordsUtil.isPunctuationOrApostrophe(currChar)) {
+ currChar = ' ';
+ }
- if (Character.isWhitespace(currChar)) {
- if (!lastCharacterAddedWasWhiteSpace) {
- currCharValid = true;
- lastCharacterAddedWasWhiteSpace = true;
- } else {
- currCharValid = false;
- }
- } else {
+ if (Character.isWhitespace(currChar)) {
+ reader.mark(toSearch.length());
+ savedCharCount = charCount;
+ if (!lastCharacterAddedWasWhiteSpace) {
currCharValid = true;
- lastCharacterAddedWasWhiteSpace = false;
+ lastCharacterAddedWasWhiteSpace = true;
+ } else {
+ currCharValid = false;
}
+ } else {
+ currCharValid = true;
+ lastCharacterAddedWasWhiteSpace = false;
}
if (currCharValid) {
if (charsToSearch[index] != currChar) {
- index = 0;
matchLocation.reset();
+ if (matchedAWhitespace) {
+ reader.reset();
+ charCount = savedCharCount;
+ }
+ index = 0;
+ matchedAWhitespace = false;
}
if (charsToSearch[index] == currChar) {
+ if (currChar == ' ' && index > 0) {
+ matchedAWhitespace = true;
+ }
if (index == 0) {
matchLocation.setStartPosition(charCount);
}

Back to the top