Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 41302 invoked from network); 12 Apr 2007 18:18:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Apr 2007 18:18:45 -0000 Received: (qmail 25843 invoked by uid 500); 12 Apr 2007 18:18:51 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 25820 invoked by uid 500); 12 Apr 2007 18:18:51 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 25809 invoked by uid 99); 12 Apr 2007 18:18:51 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2007 11:18:51 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2007 11:18:44 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id BC9AB1A9838; Thu, 12 Apr 2007 11:18:23 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r528070 - in /db/derby/code/trunk/java/engine/org/apache/derby/iapi/types: DataValueFactory.java DataValueFactoryImpl.java Date: Thu, 12 Apr 2007 18:18:23 -0000 To: derby-commits@db.apache.org From: mamta@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070412181823.BC9AB1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mamta Date: Thu Apr 12 11:18:22 2007 New Revision: 528070 URL: http://svn.apache.org/viewvc?view=rev&rev=528070 Log: Committing patch DERBY2535_Return_Collator_api_On_DVD_v1_diff.txt attached to DERBY2535. This patch adds the api on DVF to return the Collator object depending on the collation type. The new api looks as follows RuleBasedCollator getCharacterCollator(int collationType); If the collation type is UCS_BASIC, then Collator object returned by the new api above will be null. If the collation type is TERRITORY_BASED, then Collator object returned will be the one based on the territory of the database. This new api will be used in a method on DataValueFactory(DVF) which will take format id and collation type and return a DVD based on those 2 values. That method on DVF will first consturct a DVD using just the format id. For character trype format ids, this means that the DVF will always be SQLChar/SQLVarchar/SQLLongvarchar/SQLClob. This is ok if we are dealing with collation type of UCS_BASIC. But if the collation type is TERRITORY_BASED, then we shoould construct a DVD of type CollatorSQLChar/CollatorSQLVarchar/CollatorSQLLongvarchar/CollatorSQLClob. In order to construct these collation sensitive DVDs, the method on DVF will call the new api on DVF (getCharacterCollator) and it will use the return Collator from getCharacterCollator to construct the right kind of character DVD. Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java?view=diff&rev=528070&r1=528069&r2=528070 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java Thu Apr 12 11:18:22 2007 @@ -29,6 +29,8 @@ import java.sql.Time; import java.sql.Timestamp; +import java.text.RuleBasedCollator; + import java.util.Locale; /** @@ -687,4 +689,30 @@ * Collator object */ void setLocale(Locale localeOfTheDatabase); + + /** + * Return the RuleBasedCollator depending on the collation type. + * If the collation type is UCS_BASIC, then this method will return + * null. If the collation type is TERRITORY_BASED then the return + * value will be the Collator derived from the database's locale. + * + * This method will be used when Store code is trying to create a DVD + * template row using the format ids and the collation types. First a + * DVD will be constructed just using format id. Then if the DVD is of + * type StringDataValue, then it will call this method to get the + * Collator object. If the Collator object returned from this method is + * null then we will continue to use the default DVDs for the character + * types, ie the DVDs which just use the JVM's default collation. (This + * is why, we want this method to return null if we are dealing with + * UCS_BASIC.) If the Collator object returned is not null, then we + * will construct collation sensitive DVD for the character types. So, + * the return value of this method determines if we are going to create + * a character DVD with default collation or with custom collation. + * + * @param collationType This will be UCS_BASIC or TERRITORY_BASED + * + * @return Collator null if the collation type is UCS_BASIC. + * Collator based on territory if the collation type is TERRITORY_BASED + */ + RuleBasedCollator getCharacterCollator(int collationType); } Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java?view=diff&rev=528070&r1=528069&r2=528070 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java Thu Apr 12 11:18:22 2007 @@ -47,6 +47,9 @@ import java.sql.Time; import java.sql.Timestamp; +import java.text.Collator; +import java.text.RuleBasedCollator; + import java.util.Properties; import java.util.Locale; @@ -66,6 +69,8 @@ //BasicDatabase first boots DVF in it's boot method and then sets //this databaseLocale in DVF. private Locale databaseLocale; + //Following Collator object will be initialized using databaseLocale. + private RuleBasedCollator collatorForCharacterTypes; DataValueFactoryImpl() { @@ -1086,6 +1091,17 @@ /** @see DataValueFactory#setLocale(Locale) */ public void setLocale(Locale localeOfTheDatabase){ databaseLocale = localeOfTheDatabase; + collatorForCharacterTypes = + (RuleBasedCollator) Collator.getInstance(databaseLocale); + } + + /** @see DataValueFactory#getCharacterCollator(int) */ + public RuleBasedCollator getCharacterCollator(int collationType){ + if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC) + return (RuleBasedCollator)null; + else + return collatorForCharacterTypes; + } // RESOLVE: This is here to find the LocaleFinder (i.e. the Database)