db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kathey Marsden <kmarsdende...@sbcglobal.net>
Subject Language based matching
Date Fri, 07 Jul 2006 19:01:26 GMT
Does anyone know of an easy  built in Java  mechanism for Locale 
sensitive matching?

I continue to work with a user trying to develop a strategy for language 
based string type  handling in Derby 10.1.
The ordering seems doable with the approach in 
http://wiki.apache.org/db-derby/LanguageBasedOrdering
For <, =. > comparisons I was able to implement a LOCALE_COMPARE 
function pretty easily using Collators as well,
but matching (LIKE replacement) seems harder.    For example  in 
Norwegian we need to have "aa" be treated as one character and in the US 
have it treated as two.  So given  the values acorn, aacorn, and aass ( 
a Norwegian brewery) , and matching "a.*",  we should see three rows in 
english and just one in   Norwegian.

e.g.

With function LOCALE_MATCHES that returns 1 for a match and  method
 public static int  localeMatches(String language, String country, 
String pattern, String value)
    {
     ....
   }

we should see:

SELECT ID, NAME FROM CUSTOMER  WHERE LOCALE_MATCHES('no','NO', 'a.*', 
NAME) = 1
  7 , acorn

SELECT ID, NAME FROM CUSTOMER  WHERE LOCALE_MATCHES('en','US', 'a.*', 
NAME) = 1
  6 , aacorn
  7 , acorn
  8 , aass


I looked at java.util.regex to see if there were Locale related API's 
but I don't see them and tried to see if the results of 
java.lang.String.matches() vary at all if I change my default Locale.  
They don't.   I also looked at some of the server Like code in the hopes 
of finding something easy I could pull out into a function.  What I 
found was a world of  RuleBasedCollators, CollationElementIterators etc 
and thought I better ask if there is an easier way  before heading off  
to try to understand that.

Any help appreciated.    I'll summarize any knowledge gained on the Wiki.

Kathey


Mime
View raw message