db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject svn commit: r372957 - in /db/ojb/trunk/src/java/org/apache/ojb/broker: metadata/JdbcTypesHelper.java platforms/PlatformDefaultImpl.java util/SqlHelper.java
Date Fri, 27 Jan 2006 19:55:32 GMT
Author: brj
Date: Fri Jan 27 11:55:11 2006
New Revision: 372957

URL: http://svn.apache.org/viewcvs?rev=372957&view=rev
Log:
moved quotes handling to SqlHelper

Modified:
    db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java
    db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java
    db/ojb/trunk/src/java/org/apache/ojb/broker/util/SqlHelper.java

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java?rev=372957&r1=372956&r2=372957&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/JdbcTypesHelper.java Fri Jan 27 11:55:11
2006
@@ -23,7 +23,7 @@
 import org.apache.commons.lang.BooleanUtils;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.ojb.broker.OJBRuntimeException;
-import org.apache.ojb.broker.platforms.PlatformDefaultImpl;
+import org.apache.ojb.broker.util.SqlHelper;
 import org.apache.ojb.broker.util.sequence.SequenceManagerException;
 
 /* Copyright 2003-2004 The Apache Software Foundation
@@ -321,8 +321,6 @@
         {
             if (stmt != null)
             {
-//                return columnIndex == MIN_INT
-//                        ? readValueFromStatement(stmt, columnName) : readValueFromStatement(stmt,
columnIndex);
                 if (columnIndex == MIN_INT)
                 {
                     throw new UnsupportedOperationException("Not implemented yet");
@@ -334,12 +332,8 @@
             }
             else
             {
-                /*
-                PlatformDefaultImpl is used to remove enclosing
-                quotes of the column name
-                */
                 return columnIndex == MIN_INT ?
-                        readValueFromResultSet(rs, PlatformDefaultImpl.stripQuotes(columnName))
+                        readValueFromResultSet(rs, SqlHelper.stripOjbQuotes(columnName))
                         : readValueFromResultSet(rs, columnIndex);
             }
         }

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java?rev=372957&r1=372956&r2=372957&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java Fri Jan
27 11:55:11 2006
@@ -30,6 +30,7 @@
 import org.apache.ojb.broker.accesslayer.JoinSyntaxTypes;
 import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
 import org.apache.ojb.broker.query.LikeCriteria;
+import org.apache.ojb.broker.util.SqlHelper;
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
 
@@ -45,8 +46,6 @@
 public class PlatformDefaultImpl implements Platform, JoinSyntaxTypes
 {
     protected Logger log = LoggerFactory.getLogger(PlatformDefaultImpl.class);
-    private static final char OJB_QUOTE_BEGIN_CHAR = '\'';
-    private static final char OJB_QUOTE_END_CHAR = '\'';
     private static final String INITIALIZATION_CHECK_AUTOCOMMIT = "initializationCheck";
     private static final String FALSE_STR = "false";
 
@@ -439,14 +438,7 @@
      */
     public String quoteName(String aString)
     {
-        String result = aString;
-        
-        if (isQuoted(aString))
-        {
-            result = getQuotedName(aString.substring(1, aString.length() - 1));         
 
-        }
-               
-        return result; 
+        return SqlHelper.stripOjbQuotes(aString);
     }
 
     /**
@@ -457,34 +449,6 @@
         return '"' + aString + '"'; 
     }
     
-    /**
-     * answer true if the string starts with OJB_QUOTE_BEGIN_CHAR 
-     * and ends with the OJB_QUOTE_END_CHAR
-     * @param aString
-     */
-    private static boolean isQuoted(String aString)
-    {
-        return aString != null &&
-                aString.charAt(0) == OJB_QUOTE_BEGIN_CHAR &&
-                aString.charAt(aString.length() - 1) == OJB_QUOTE_END_CHAR;
-    }
-
-    /**
-     * Remove the OJB-Quotes from the String.
-     * @param aString
-     * @return String withou OJB-Quotes
-     */
-    public static String stripQuotes(String aString)
-    {
-        String result = aString;
-        
-        if (isQuoted(aString))
-        {
-            result = aString.substring(1, aString.length() - 1);
-        }
-        return result;
-    }
-
     /**
      * @see org.apache.ojb.broker.platforms.Platform#registerOutResultSet(java.sql.CallableStatement,
int)
      */

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/util/SqlHelper.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/java/org/apache/ojb/broker/util/SqlHelper.java?rev=372957&r1=372956&r2=372957&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/util/SqlHelper.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/util/SqlHelper.java Fri Jan 27 11:55:11 2006
@@ -1,6 +1,5 @@
 package org.apache.ojb.broker.util;
 
-import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.StringTokenizer;
 
@@ -38,7 +37,11 @@
 
     /** define the name of the pseudo column holding the class to be instantiated. */
     public static final String OJB_CLASS_COLUMN = "OJB_CLAZZ"; 
-    
+ 
+    private static final char OJB_QUOTE_BEGIN_CHAR = '\'';
+    private static final char OJB_QUOTE_END_CHAR = '\'';
+
+
     /**
 	 * remove functions and () from path <br>
 	 * ie: avg(amount) -> amount <br>
@@ -153,6 +156,34 @@
             {
                 throw new PersistenceBrokerException("Cannot access " + OJB_CLASS_COLUMN,
e);
             }
+        }
+        return result;
+    }
+    
+    /**
+     * answer true if the string starts with OJB_QUOTE_BEGIN_CHAR 
+     * and ends with the OJB_QUOTE_END_CHAR
+     * @param aString
+     */
+    private static boolean isQuoted(String aString)
+    {
+        return aString != null &&
+                aString.charAt(0) == OJB_QUOTE_BEGIN_CHAR &&
+                aString.charAt(aString.length() - 1) == OJB_QUOTE_END_CHAR;
+    }
+
+    /**
+     * Remove the OJB-Quotes from the String.
+     * @param aString
+     * @return String without OJB-Quotes
+     */
+    public static String stripOjbQuotes(String aString)
+    {
+        String result = aString;
+        
+        if (isQuoted(aString))
+        {
+            result = aString.substring(1, aString.length() - 1);
         }
         return result;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message