db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r398720 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters: ByteArrayBase64Converter.java TimestampConverter.java
Date Mon, 01 May 2006 22:43:52 GMT
Author: tomdz
Date: Mon May  1 15:43:49 2006
New Revision: 398720

URL: http://svn.apache.org/viewcvs?rev=398720&view=rev
Log:
Fixed null handling in converters

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/ByteArrayBase64Converter.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimestampConverter.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/ByteArrayBase64Converter.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/ByteArrayBase64Converter.java?rev=398720&r1=398719&r2=398720&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/ByteArrayBase64Converter.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/ByteArrayBase64Converter.java
Mon May  1 15:43:49 2006
@@ -31,7 +31,14 @@
      */
     public Object convertFromString(String textRep, int sqlTypeCode) throws ConversionException
     {
-        return Base64.encodeBase64(textRep.getBytes());
+        try
+        {
+            return textRep == null ? null : Base64.encodeBase64(textRep.getBytes());
+        }
+        catch (Exception ex)
+        {
+            throw new ConversionException(ex);
+        }
     }
 
     /**
@@ -39,7 +46,14 @@
      */
     public String convertToString(Object obj, int sqlTypeCode) throws ConversionException
     {
-        return new String(Base64.decodeBase64((byte[])obj));
+        try
+        {
+            return obj == null ? null : new String(Base64.decodeBase64((byte[])obj));
+        }
+        catch (Exception ex)
+        {
+            throw new ConversionException(ex);
+        }
     }
 
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimestampConverter.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimestampConverter.java?rev=398720&r1=398719&r2=398720&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimestampConverter.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimestampConverter.java Mon
May  1 15:43:49 2006
@@ -33,7 +33,18 @@
      */
     public Object convertFromString(String textRep, int sqlTypeCode) throws ConversionException
     {
-        return sqlTypeCode == Types.TIMESTAMP ? Timestamp.valueOf(textRep) : (Object)textRep;
+        if (textRep == null)
+        {
+            return null;
+        }
+        else if (sqlTypeCode == Types.TIMESTAMP)
+        {
+            return Timestamp.valueOf(textRep);
+        }
+        else
+        {
+            return textRep;
+        }
     }
 
     /**
@@ -41,6 +52,6 @@
      */
     public String convertToString(Object obj, int sqlTypeCode) throws ConversionException
     {
-        return (obj == null ? null : ((Timestamp)obj).toString());
+        return obj == null ? null : ((Timestamp)obj).toString();
     }
 }



Mime
View raw message