empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1324951 - in /empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions: FieldIllegalValueException.java FieldIsReadOnlyException.java FieldNotNullException.java FieldValueException.java FieldValueTooLongException.java
Date Wed, 11 Apr 2012 19:44:06 GMT
Author: doebele
Date: Wed Apr 11 19:44:05 2012
New Revision: 1324951

URL: http://svn.apache.org/viewvc?rev=1324951&view=rev
Log:
EMPIREDB-139
Improve Field value exceptions

Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIllegalValueException.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIsReadOnlyException.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldNotNullException.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueException.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueTooLongException.java

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIllegalValueException.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIllegalValueException.java?rev=1324951&r1=1324950&r2=1324951&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIllegalValueException.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIllegalValueException.java
Wed Apr 11 19:44:05 2012
@@ -19,7 +19,7 @@
 package org.apache.empire.db.exceptions;
 
 import org.apache.empire.commons.ErrorType;
-import org.apache.empire.db.DBColumn;
+import org.apache.empire.data.Column;
 
 public class FieldIllegalValueException extends FieldValueException
 {
@@ -30,13 +30,13 @@ public class FieldIllegalValueException 
     
     public static final ErrorType errorType = new ErrorType("error.db.fieldIllegalValue",
 "The value {1} for field {0} is invalid.");
     
-    public FieldIllegalValueException(DBColumn column, String value, Throwable cause)
+    public FieldIllegalValueException(Column column, String value, Throwable cause)
     {
-        super(column, errorType, new String[] { column.getFullName(), value }, cause);
+        super(column, errorType, new String[] { getColumnTitle(column), value }, cause);
     }
     
-    public FieldIllegalValueException(DBColumn column, String value)
+    public FieldIllegalValueException(Column column, String value)
     {
-        super(column, errorType, new String[] { column.getFullName(), value }, null);
+        super(column, errorType, new String[] { getColumnTitle(column), value }, null);
     }
 }

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIsReadOnlyException.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIsReadOnlyException.java?rev=1324951&r1=1324950&r2=1324951&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIsReadOnlyException.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldIsReadOnlyException.java
Wed Apr 11 19:44:05 2012
@@ -19,10 +19,9 @@
 package org.apache.empire.db.exceptions;
 
 import org.apache.empire.commons.ErrorType;
-import org.apache.empire.db.DBColumn;
-import org.apache.empire.exceptions.EmpireException;
+import org.apache.empire.data.Column;
 
-public class FieldIsReadOnlyException extends EmpireException
+public class FieldIsReadOnlyException extends FieldValueException
 {
     /**
      * Comment for <code>serialVersionUID</code>
@@ -31,8 +30,8 @@ public class FieldIsReadOnlyException ex
     
     public static final ErrorType errorType = new ErrorType("error.db.fieldIsReadOnly", 
  "The field {0} is read only.");
     
-    public FieldIsReadOnlyException(DBColumn col)
+    public FieldIsReadOnlyException(Column col)
     {
-        super(errorType, new String[] { col.getFullName() });
+        super(col, errorType, new String[] { getColumnTitle(col) });
     }
 }

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldNotNullException.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldNotNullException.java?rev=1324951&r1=1324950&r2=1324951&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldNotNullException.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldNotNullException.java
Wed Apr 11 19:44:05 2012
@@ -20,10 +20,8 @@ package org.apache.empire.db.exceptions;
 
 import org.apache.empire.commons.ErrorType;
 import org.apache.empire.data.Column;
-import org.apache.empire.db.DBColumn;
-import org.apache.empire.exceptions.EmpireException;
 
-public class FieldNotNullException extends EmpireException
+public class FieldNotNullException extends FieldValueException
 {
     /**
      * Comment for <code>serialVersionUID</code>
@@ -32,13 +30,8 @@ public class FieldNotNullException exten
     
     public static final ErrorType errorType = new ErrorType("error.db.fieldNotNull",    
  "The field {0} must not be null.");
     
-    public FieldNotNullException(DBColumn col)
-    {
-        super(errorType, new String[] { col.getFullName() });
-    }
-    
     public FieldNotNullException(Column col)
     {
-        super(errorType, new String[] { col.getName() });
+        super(col, errorType, new String[] { getColumnTitle(col) });
     }
 }

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueException.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueException.java?rev=1324951&r1=1324950&r2=1324951&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueException.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueException.java
Wed Apr 11 19:44:05 2012
@@ -19,6 +19,8 @@
 package org.apache.empire.db.exceptions;
 
 import org.apache.empire.commons.ErrorType;
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.data.Column;
 import org.apache.empire.db.DBColumn;
 import org.apache.empire.exceptions.EmpireException;
 
@@ -29,16 +31,29 @@ public abstract class FieldValueExceptio
      */
     private static final long serialVersionUID = 1L;
     
-    private transient final DBColumn column;
+    protected static String getColumnTitle(Column column)
+    {
+        String title = column.getTitle();
+        if (StringUtils.isEmpty(title))
+            title = "!["+((column instanceof DBColumn) ? ((DBColumn)column).getId() : column.getName())
+ "]";
+        return title;
+    }
+    
+    private transient final Column column;
 
-    protected FieldValueException(final DBColumn column, final ErrorType errType, final String[]
params, final Throwable cause)
+    protected FieldValueException(final Column column, final ErrorType errType, final String[]
params, final Throwable cause)
     {
         super(errType, params, cause);
         // save type and params for custom message formatting
         this.column = column;
     }
+
+    protected FieldValueException(final Column column, final ErrorType errType, final String[]
params)
+    {
+        this(column, errType, params, null);
+    }
     
-    public DBColumn getColumn()
+    public Column getColumn()
     {
         return column;
     }

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueTooLongException.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueTooLongException.java?rev=1324951&r1=1324950&r2=1324951&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueTooLongException.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/FieldValueTooLongException.java
Wed Apr 11 19:44:05 2012
@@ -19,10 +19,9 @@
 package org.apache.empire.db.exceptions;
 
 import org.apache.empire.commons.ErrorType;
-import org.apache.empire.db.DBColumn;
-import org.apache.empire.exceptions.EmpireException;
+import org.apache.empire.data.Column;
 
-public class FieldValueTooLongException extends EmpireException
+public class FieldValueTooLongException extends FieldValueException
 {
     /**
      * Comment for <code>serialVersionUID</code>
@@ -31,8 +30,8 @@ public class FieldValueTooLongException 
     
     public static final ErrorType errorType = new ErrorType("error.db.fieldValueTooLong",
 "The value supplied for field {0} is too long. The maximum number of characters is {1}.");
     
-    public FieldValueTooLongException(DBColumn col)
+    public FieldValueTooLongException(Column col)
     {
-        super(errorType, new String[] { col.getFullName(), String.valueOf((int)col.getSize())
});
+        super(col, errorType, new String[] { getColumnTitle(col), String.valueOf((int)col.getSize())
});
     }
 }



Mime
View raw message