empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1329708 - in /empire-db/trunk/empire-db/src/main/java/org/apache/empire/db: DBColumnExpr.java DBRecordData.java
Date Tue, 24 Apr 2012 13:29:39 GMT
Author: doebele
Date: Tue Apr 24 13:29:39 2012
New Revision: 1329708

URL: http://svn.apache.org/viewvc?rev=1329708&view=rev
Log:
EMPIREDB-141
make getBeanProperty safer and correct typos

Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java?rev=1329708&r1=1329707&r2=1329708&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java Tue Apr
24 13:29:39 2012
@@ -227,8 +227,12 @@ public abstract class DBColumnExpr exten
     {
         if (beanPropertyName==null)
         {   // Compute bean property name
+            String name = getName();
+            if (name==null)
+                return null; // no name provided!
+            // compute name
+            name = name.toLowerCase();        
             String res = "";
-            String name = getName().toLowerCase();
             int beg=0;
             while (beg<name.length())
             {
@@ -947,7 +951,7 @@ public abstract class DBColumnExpr exten
     }
 
     /**
-     * Creates and returns an expresion for the SQL "count()" function
+     * Creates and returns an expression for the SQL "count()" function
      * which returns the number of rows in the result set.
      *
      * @return the new DBFuncExpr object
@@ -958,7 +962,7 @@ public abstract class DBColumnExpr exten
     }
 
     /**
-     * Creates and returns an expresion for the SQL "count()" function
+     * Creates and returns an expression for the SQL "count()" function
      * which returns the number of unique values in the result set.
      *
      * @return the new DBFuncExpr object
@@ -1002,8 +1006,7 @@ public abstract class DBColumnExpr exten
      * @param otherwise the value to take if no key matches the given expression
      * @return a DBDecodeExpr object
      */
-    @SuppressWarnings("unchecked")
-    public DBColumnExpr decode(Map valueMap, Object otherwise)
+    public DBColumnExpr decode(Map<?,?> valueMap, Object otherwise)
     {
         // Detect data type
         DataType dataType = DataType.UNKNOWN;
@@ -1117,7 +1120,7 @@ public abstract class DBColumnExpr exten
 
     /**
      * Creates a new DBFuncExpr object that will convert
-     * the current column to the destination data type specivied.
+     * the current column to the destination data type specified.
      * 
      * @param dataType the destination data type
      * @param format optional destination format (usually a string)
@@ -1130,7 +1133,7 @@ public abstract class DBColumnExpr exten
 
     /**
      * Creates and returns a new DBFuncExpr object that will
-     * convert the current column to the destination data type specivied.
+     * convert the current column to the destination data type specified.
      * 
      * @param dataType Data type to which to convert the current expression to.
      * @return the new DBFuncExpr object

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java?rev=1329708&r1=1329707&r2=1329708&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java Tue Apr
24 13:29:39 2012
@@ -30,6 +30,7 @@ import org.apache.empire.commons.StringU
 import org.apache.empire.data.ColumnExpr;
 import org.apache.empire.data.RecordData;
 import org.apache.empire.exceptions.BeanPropertySetException;
+import org.apache.empire.exceptions.InvalidArgumentException;
 import org.apache.empire.exceptions.ItemNotFoundException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -291,7 +292,12 @@ public abstract class DBRecordData exten
     protected void getBeanProperty(Object bean, String property, Object value)
     {
         try
-        {   /*
+        {
+            if (bean==null)
+                throw new InvalidArgumentException("bean", bean);
+            if (StringUtils.isEmpty(property))
+                throw new InvalidArgumentException("property", property);
+            /*
             if (log.isTraceEnabled())
                 log.trace(bean.getClass().getName() + ": setting property '" + property +
"' to " + String.valueOf(value));
             */
@@ -344,7 +350,8 @@ public abstract class DBRecordData exten
                 continue; // ignore this property
             // Get Property Name
             String property = column.getBeanPropertyName();
-            getBeanProperty(bean, property, this.getValue(i));
+            if (property!=null)
+                getBeanProperty(bean, property, this.getValue(i));
             count++;
         }
         return count;



Mime
View raw message