{
if (s != null)
{
- id = new String(s);
+ id = new String(s).toLowerCase();
}
else
{
// match contains one ID flanked
if (id.length() > s.id.length())
{
- return id.startsWith(s.id) ? (WORD_SEP.indexOf(id.charAt(s.id
- .length())) > -1) : false;
+ return check_wordmatch(id, s.id);
}
else
{
- return s.id.startsWith(id) ? (s.id.equals(id) ? true : (WORD_SEP
- .indexOf(s.id.charAt(id.length())) > -1)) : false;
+ return check_wordmatch(s.id, id);
+ }
+ }
+
+ private boolean check_wordmatch(String longer, String shorter)
+ {
+ boolean elen = longer.length() == shorter.length();
+ int sp = longer.indexOf(shorter);
+ if (sp == -1)
+ {
+ return false;
+ }
+
+ if (sp == 0)
+ {
+ // end of match is word boundary
+ return elen ? true : (WORD_SEP.indexOf(longer.charAt(shorter
+ .length() + sp)) > -1);
+ }
+ if (WORD_SEP.indexOf(longer.charAt(sp - 1)) > -1)
+ {
+ if (sp + shorter.length() == longer.length())
+ {
+ return true;
+ }
+ else
+ {
+ // end of match is word boundary
+ return elen ? false
+ : sp + shorter.length() == longer.length() ? true
+ : (WORD_SEP.indexOf(longer.charAt(shorter
+ .length() + sp)) > -1);
+ }
+ }
+ else
+ {
+ // prefix of match is not a word boundary
+ return false;
}
}
public boolean equals(String s)
{
+ s = s.toLowerCase(); // TODO: employ faster to lower case operation
if (id.length() > s.length())
{
- return id.startsWith(s) ? (WORD_SEP.indexOf(id.charAt(s.length())) > -1)
- : false;
+ return check_wordmatch(id, s);
}
else
{
- return s.startsWith(id) ? (s.equals(id) ? true : (WORD_SEP
- .indexOf(s.charAt(id.length())) > -1)) : false;
+ return check_wordmatch(s, id);
}
}
}