db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r540986 - in /db/derby/code/trunk/java/engine/org/apache/derby/iapi/types: DataValueFactory.java DataValueFactoryImpl.java
Date Wed, 23 May 2007 16:10:23 GMT
Author: djd
Date: Wed May 23 09:10:22 2007
New Revision: 540986

URL: http://svn.apache.org/viewvc?view=rev&rev=540986
Log:
Add methods to DataValueFactory to get character values based upon a collation.
These methods are unused at the moment but a subsequent commit will utilise
them in the generateDataValue() call of BaseTypeCompiler.

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=540986&r1=540985&r2=540986
==============================================================================
--- 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 Wed
May 23 09:10:22 2007
@@ -34,9 +34,12 @@
 import java.util.Locale;
 
 /**
- * This interface is how we get constant data values of different types.
+ * This interface is how we get data values of different types.
+ * 
+ * For any method that takes a 'previous' argument it is required
+ * that the caller pass in an object of the same class that would
+ * be returned by the call if null was passed for previous.
  */
-
 public interface DataValueFactory
 {
         /**
@@ -160,10 +163,29 @@
          *
          */
         StringDataValue         getVarcharDataValue(String value);
-        StringDataValue         getVarcharDataValue(String value,
-                                                                                        StringDataValue
previous)
-                                                                                        
               throws StandardException;
-
+        
+        /**
+         * Get a SQLVarhar object to represent a SQL VARCHAR  (UCS_BASIC)
+         * with the given value. A null argument means get a SQL NULL value.
+         * If previous is not null (Java reference) then it will be set
+         * to the value passed in and returned, otherwise a new SQLVarchar
+         * will be created and set to the value.
+         *
+         */
+        StringDataValue getVarcharDataValue(String value, StringDataValue previous)
+            throws StandardException;
+        
+        /**
+         * Get a StringDataValue to represent a SQL VARCHAR with the
+         * passed in collationType. A null argument means get a SQL NULL value.
+         * If previous is not null (Java reference) then it will be set
+         * to the value passed in and returned, otherwise a new StringDataValue
+         * will be created and set to the value.
+         * If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC
+         * then the call is the equivalent of the overload without collationType.
+         */
+        StringDataValue getVarcharDataValue(String value, StringDataValue previous,
+                int collationType) throws StandardException;
         /**
          * Get a SQL long varchar with the given value.  A null argument means
          * get a SQL null value.  The second form uses the previous value
@@ -171,17 +193,54 @@
          *
          */
         StringDataValue         getLongvarcharDataValue(String value);
-        StringDataValue         getLongvarcharDataValue(String value, StringDataValue previous)
throws StandardException;
+        
+        /**
+         * Get a SQLLongvarchar object to represent a SQL LONG VARCHAR  (UCS_BASIC)
+         * with the given value. A null argument means get a SQL NULL value.
+         * If previous is not null (Java reference) then it will be set
+         * to the value passed in and returned, otherwise a new SQLLongvarchar
+         * will be created and set to the value.
+         *
+         */
+        StringDataValue getLongvarcharDataValue(String value, StringDataValue previous) throws
StandardException;
 
         /**
-         * Get a SQL Clob with the given value.  A null argument means
-         * get a SQL null value.  The second form uses the previous value
-         * (if non-null) to hold the return value.
+         * Get a StringDataValue to represent a SQL LONG VARCHAR with the
+         * passed in collationType. A null argument means get a SQL NULL value.
+         * If previous is not null (Java reference) then it will be set
+         * to the value passed in and returned, otherwise a new StringDataValue
+         * will be created and set to the value.
+         * If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC
+         * then the call is the equivalent of the overload without collationType.
+
+         */
+        StringDataValue getLongvarcharDataValue(String value, StringDataValue previous,
+                int collationType) throws StandardException;
+        
+ 
+        /**
+         * Get a SQLClob object to represent a SQL CLOB  (UCS_BASIC)
+         * with the given value. A null argument means get a SQL NULL value.
+         * If previous is not null (Java reference) then it will be set
+         * to the value passed in and returned, otherwise a new SQLLongvarchar
+         * will be created and set to the value.
          *
          */
-        StringDataValue         getClobDataValue(String value, StringDataValue previous)
throws StandardException;
+        StringDataValue getClobDataValue(String value, StringDataValue previous) throws StandardException;
 
         /**
+         * Get a StringDataValue to represent a SQL LONG VARCHAR with the
+         * passed in collationType. A null argument means get a SQL NULL value.
+         * If previous is not null (Java reference) then it will be set
+         * to the value passed in and returned, otherwise a new StringDataValue
+         * will be created and set to the value.
+         * If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC
+         * then the call is the equivalent of the overload without collationType.
+         */
+        StringDataValue getClobDataValue(String value, StringDataValue previous,
+                int collationType) throws StandardException;
+        
+        /**
          * Get a SQL national varchar with the given value.  A null argument means get
          * a SQL null value.  The second form uses the previous value (if non-null)
          * to hold the return value.
@@ -352,8 +411,20 @@
          * will be created and set to the value.
          *
          */
-        StringDataValue         getCharDataValue(String value, StringDataValue previous)
+        StringDataValue  getCharDataValue(String value, StringDataValue previous)
                                                         throws StandardException;
+        
+        /**
+         * Get a StringDataValue to represent a SQL CHAR with the
+         * passed in collationType. A null argument means get a SQL NULL value.
+         * If previous is not null (Java reference) then it will be set
+         * to the value passed in and returned, otherwise a new StringDataValue
+         * will be created and set to the value.
+         * If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC
+         * then the call is the equivalent of the overload without collationType.
+         */
+        StringDataValue getCharDataValue(String value, StringDataValue previous,
+                int collationType) throws StandardException;
 
         /**
          * Get a SQL national char with the given value.  A null argument means get

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=540986&r1=540985&r2=540986
==============================================================================
--- 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
Wed May 23 09:10:22 2007
@@ -435,6 +435,26 @@
                 previous.setValue(value);
                 return previous;
         }
+        
+        /**
+         * Return a StringDataValue to represent a SQL CHAR
+         * with the given collation re-using previous if not null.
+         */
+        public StringDataValue getCharDataValue(String value,
+                StringDataValue previous, int collationType)
+            throws StandardException
+        {
+            if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
+                return getCharDataValue(value, previous);
+            
+            if (previous == null)
+                return new CollatorSQLChar(value, getCharacterCollator(collationType));
+            
+            previous.setValue(value);
+            return previous;
+        }
+
+        
 
         public StringDataValue getVarcharDataValue(String value)
         {
@@ -450,6 +470,25 @@
                 previous.setValue(value);
                 return previous;
         }
+        
+        /**
+         * Return a StringDataValue to represent a SQL VARCHAR
+         * with the given collation re-using previous if not null.
+         */
+        public StringDataValue getVarcharDataValue(String value,
+                StringDataValue previous, int collationType)
+            throws StandardException
+        {
+            if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
+                return getVarcharDataValue(value, previous);
+            
+            if (previous == null)
+                return new CollatorSQLVarchar(value,
+                        getCharacterCollator(collationType));
+            
+            previous.setValue(value);
+            return previous;
+        }
 
         public StringDataValue getLongvarcharDataValue(String value)
         {
@@ -465,6 +504,25 @@
                 previous.setValue(value);
                 return previous;
         }
+        
+        /**
+         * Return a StringDataValue to represent a SQL LONG VARCHAR
+         * with the given collation re-using previous if not null.
+         */
+        public StringDataValue getLongvarcharDataValue(String value,
+                StringDataValue previous, int collationType)
+            throws StandardException
+        {
+            if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
+                return getLongvarcharDataValue(value, previous);
+            
+            if (previous == null)
+                return new CollatorSQLLongvarchar(value,
+                        getCharacterCollator(collationType));
+            
+            previous.setValue(value);
+            return previous;
+        }
 
         public StringDataValue getClobDataValue(String value, StringDataValue previous) throws
StandardException
         {
@@ -472,6 +530,25 @@
                         return new SQLClob(value);
                 previous.setValue(value);
                 return previous;
+        }
+        
+        /**
+         * Return a StringDataValue to represent a SQL CLOB
+         * with the given collation re-using previous if not null.
+         */
+        public StringDataValue getClobDataValue(String value,
+                StringDataValue previous, int collationType)
+            throws StandardException
+        {
+            if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
+                return getClobDataValue(value, previous);
+            
+            if (previous == null)
+                return new CollatorSQLClob(value,
+                        getCharacterCollator(collationType));
+            
+            previous.setValue(value);
+            return previous;
         }
 
         //



Mime
View raw message