db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
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 GMT
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)



Mime
View raw message