empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r749118 - in /incubator/empire-db/trunk/empire-db/src: main/java/org/apache/empire/commons/ main/java/org/apache/empire/db/postgresql/ test/java/org/apache/empire/commons/ test/java/org/apache/empire/db/hsql/
Date Sun, 01 Mar 2009 21:45:27 GMT
Author: francisdb
Date: Sun Mar  1 21:45:27 2009
New Revision: 749118

URL: http://svn.apache.org/viewvc?rev=749118&view=rev
Log:
fixing todo's fixme's and removing unused code

Modified:
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/ObjectUtilsTest.java
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java?rev=749118&r1=749117&r2=749118&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
Sun Mar  1 21:45:27 2009
@@ -87,8 +87,10 @@
     
     /**
      * Compares two objects for equality 
+     * 
      * @param o1 the first object
      * @param o2 the second object
+     * 
      * @return true if both objects are equal or false otherwise
      */
     public static boolean compareEqual(Object o1, Object o2)

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java?rev=749118&r1=749117&r2=749118&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
Sun Mar  1 21:45:27 2009
@@ -18,9 +18,6 @@
  */
 package org.apache.empire.commons;
 
-import java.util.Collection;
-import java.util.Iterator;
-
 /**
  * This class contains common functions for comparing and converting values of type String.

  * 
@@ -155,77 +152,7 @@
             return buf.toString();
         }
         // Only one member
-        return array[0].toString();
-    }
-
-    /**
-     * Converts a string to an array of objects.
-     * 
-     * @param string the source string to parse
-     * @param separator the separator string by which the parts are separated
-     * @return returns a String
-     */
-    public static String[] stringToArray(String string, String separator)
-    {
-        if (string == null || isEmpty(separator))
-            return null; // Empty
-        // Count the items first
-        int sepLength = separator.length();
-        int count = 0;
-        int pos = -1;
-        while ((pos=string.indexOf(separator, pos+sepLength))>=0)
-                count++;
-        // Alloc an array
-        String[] array = new String[count+1];
-        if (count>0)
-        {
-            int beg = 0;
-            for (int i=0; true; i++)
-            {
-                int end = string.indexOf(separator, beg);
-                if (end>beg)
-                {   // Add Item
-                    array[i] = string.substring(beg, end);
-                    beg = end + sepLength;
-                }
-                else
-                {   // Last Item
-                    array[i] = string.substring(beg);
-                    break;
-                }
-            }
-        }
-        else
-        {
-            array[0] = string;
-        }
-        // Only one member
-        return array;
-    }
-
-    /**
-     * Converts an collection of objects to a string.
-     * 
-     * @param c the collection to add
-     * @param separator the separator to put between the object strings
-     * @return returns a String
-     */
-    public static String collectionToString(Collection<? extends Object> c, String
separator)
-    {
-        if (c == null || c.size()==0)
-            return null; // Empty
-        // Iterator
-        StringBuilder buf = new StringBuilder();
-        boolean addSep = false;
-        Iterator<?> i = c.iterator();
-        while (i.hasNext())
-        {
-            if (addSep)
-                buf.append(separator);
-            buf.append(valueOf(i.next()));
-            addSep = true;
-        }
-        return buf.toString();
+        return String.valueOf(array[0]);
     }
     
     /**

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java?rev=749118&r1=749117&r2=749118&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
Sun Mar  1 21:45:27 2009
@@ -19,10 +19,6 @@
 package org.apache.empire.db.postgresql;
 
 import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.GregorianCalendar;
 import java.util.Iterator;
 
@@ -227,7 +223,8 @@
      */
     @Override
     public Object getNextSequenceValue(DBDatabase db, String seqName, int minValue, Connection
conn)
-    { // Use Oracle Sequences
+    { 
+        // Use PostgreSQL Sequences
         StringBuilder sql = new StringBuilder(80);
         sql.append("SELECT nextval('");
         db.appendQualifiedName(sql, seqName, detectQuoteName(seqName));
@@ -237,54 +234,9 @@
         { // Error!
             log.error("getNextSequenceValue: Invalid sequence value for sequence " + seqName);
         }
-        // Done
         return val;
     }
     
-    @Override
-	public int executeSQL(String sqlCmd, Object[] sqlParams, Connection conn, DBSetGenKeys genKeys)
throws SQLException
-	{
-    	// TODO remove as is defined in parent?
-		Statement stmt = null;
-		try
-		{
-			int count = 0;
-			if (sqlParams != null)
-			{ // Use a prepared statement
-				PreparedStatement pstmt = conn.prepareStatement(sqlCmd);
-				prepareStatement(pstmt, sqlParams);
-				count = pstmt.executeUpdate();
-				stmt = pstmt;
-			} else
-			{ // Execute a simple statement
-				stmt = conn.createStatement();
-				count = stmt.executeUpdate(sqlCmd);
-			}
-
-			// Retrieve any auto-generated keys
-			if (genKeys != null)
-			{
-				// Return Keys
-				ResultSet rs = stmt.getGeneratedKeys();
-				try
-				{
-					while (rs.next())
-						genKeys.set(rs.getObject(1));
-				} finally
-				{
-					rs.close();
-				}
-			}
-			return count;
-		} finally
-		{
-			close(stmt);
-		}
-	}
-    
-    
-    
-
     /**
      * @see DBDatabaseDriver#getDDLScript(DBCmdType, DBObject, DBSQLScript)  
      */

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/ObjectUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/ObjectUtilsTest.java?rev=749118&r1=749117&r2=749118&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/ObjectUtilsTest.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/ObjectUtilsTest.java
Sun Mar  1 21:45:27 2009
@@ -61,7 +61,6 @@
 	@Test
 	public void testCompareEqual()
 	{
-		// TODO check if this is the wanted result
 		assertTrue(ObjectUtils.compareEqual(null, null));
 		
 		Object object = new Object();

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java?rev=749118&r1=749117&r2=749118&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java
Sun Mar  1 21:45:27 2009
@@ -20,10 +20,6 @@
 
 import static org.junit.Assert.*;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
 import org.junit.Test;
 
 public class StringUtilsTest
@@ -103,46 +99,12 @@
 		assertEquals(null, StringUtils.arrayToString(null , null));
 		assertEquals(null, StringUtils.arrayToString(null , "/"));
 		assertEquals(null, StringUtils.arrayToString(new String[]{} , ""));
+		assertEquals("test", StringUtils.arrayToString(new String[]{"test"} , "|"));
 		assertEquals("12312.3", StringUtils.arrayToString(new Number[]{Integer.valueOf("123"),
Double.valueOf("12.3")} , ""));
 		assertEquals("firstnullsecondnullthird", StringUtils.arrayToString(new String[]{"first",
"second", "third"} , null));
 		assertEquals(" first \t second \t third ", StringUtils.arrayToString(new String[]{" first
", " second ", " third "} , "\t"));
 		assertEquals("null/null", StringUtils.arrayToString(new String[]{null, null} , "/"));
-		// FIXME see what this should return + implement (throws nullpointer now)
-		// assertEquals("null", StringUtils.arrayToString(new String[]{null} , "/"));
-	}
-
-	@Test
-	public void testStringToArray()
-	{
-		// TODO see if we want to always return empty arrays instead of nulls
-		assertArrayEquals(null, StringUtils.stringToArray(null , null));
-		assertArrayEquals(null, StringUtils.stringToArray("first null second" , null));
-		assertArrayEquals(null, StringUtils.stringToArray(null , "/"));
-		assertArrayEquals(new String[]{"test"}, StringUtils.stringToArray("test" , "/"));
-		assertArrayEquals(new String[]{"test "," test2"}, StringUtils.stringToArray("test and test2"
, "and"));
-		// FIXME this is returning strange results !!!
-		//assertArrayEquals(new String[]{"","","",""}, StringUtils.stringToArray("///" , "/"));
-	}
-
-	@Test
-	public void testCollectionToString()
-	{
-		assertEquals(null, StringUtils.collectionToString(null , null));
-		assertEquals(null, StringUtils.collectionToString(null , "/"));
-		assertEquals(null, StringUtils.collectionToString(Collections.emptySet() , null));
-		List<String> test = new ArrayList<String>();
-		Collections.addAll(test, "first","second","third");
-		assertEquals("firstsecondthird", StringUtils.collectionToString(test , ""));
-		assertEquals("firstnullsecondnullthird", StringUtils.collectionToString(test , null));
-		assertEquals("first \t second \t third", StringUtils.collectionToString(test , " \t "));
-		test.clear();
-		Collections.addAll(test, "first", null, "third");
-		// TODO should null be converted to string null as with the arry method?
-		assertEquals("first//third", StringUtils.collectionToString(test , "/"));
-		test.clear();
-		Collections.addAll(null);
-		// FIXME see what this should return + implement (throws nullpointer now)
-		// assertEquals("null", StringUtils.arrayToString(new String[]{null} , "/"));
+		assertEquals("null", StringUtils.arrayToString(new String[]{null} , "/"));
 	}
 
 	@Test

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java?rev=749118&r1=749117&r2=749118&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
Sun Mar  1 21:45:27 2009
@@ -14,7 +14,6 @@
 import org.apache.empire.db.DBTools;
 import org.apache.empire.db.CompanyDB;
 import org.junit.AfterClass;
-import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 



Mime
View raw message