RM: Support query for empty strings against untokenised text properties

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16622 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2009-09-30 14:36:46 +00:00
parent 26a3750be0
commit 7098bab5ea

View File

@@ -932,7 +932,7 @@ public class LuceneQueryParser extends QueryParser
String localeString = null; String localeString = null;
if (field.startsWith("@")) if (field.startsWith("@"))
{ {
if (queryText.charAt(0) == '\u0000') if ((queryText.length() > 0) && (queryText.charAt(0) == '\u0000'))
{ {
int position = queryText.indexOf("\u0000", 1); int position = queryText.indexOf("\u0000", 1);
testText = queryText.substring(position + 1); testText = queryText.substring(position + 1);
@@ -1299,16 +1299,19 @@ public class LuceneQueryParser extends QueryParser
if (replace != null) if (replace != null)
{ {
StringBuilder postfix = new StringBuilder(); StringBuilder postfix = new StringBuilder();
for (int i = replace.endOffset(); i < testText.length(); i++) if ((replace.endOffset() >= 0) && (replace.endOffset() < testText.length()))
{ {
char test = testText.charAt(i); for (int i = replace.endOffset(); i < testText.length(); i++)
if ((test == '*') || (test == '?'))
{ {
postfix.append(test); char test = testText.charAt(i);
} if ((test == '*') || (test == '?'))
else {
{ postfix.append(test);
break; }
else
{
break;
}
} }
} }
String post = postfix.toString(); String post = postfix.toString();