dev@jsftemplating.java.net

code review

From: Senthil Chidambaram <cchidamb_at_sun.com>
Date: Thu, 12 Apr 2007 12:39:34 -0700

I'm attaching the diffs for Date type conversion support in
jsftemplating. Could you pls review, and let me know.

thx
Senthil



Index: TypeConverter.java
===================================================================
RCS file: /cvs/jsftemplating/src/java/com/sun/jsftemplating/util/TypeConverter.java,v
retrieving revision 1.3
diff -c -r1.3 TypeConverter.java
*** TypeConverter.java 11 Apr 2007 19:38:33 -0000 1.3
--- TypeConverter.java 12 Apr 2007 19:33:48 -0000
***************
*** 141,146 ****
--- 141,147 ----
   * TypeConverter.TYPE_CHARACTER ("character")
   * TypeConverter.TYPE_BIG_DECIMAL ("bigdecimal")
   * TypeConverter.TYPE_SQL_DATE ("sqldate")
+ * TypeConverter.TYPE_DATE ("date")
   * TypeConverter.TYPE_SQL_TIME ("sqltime")
   * TypeConverter.TYPE_SQL_TIMESTAMP ("sqltimestamp")
   * </pre>
***************
*** 731,736 ****
--- 732,762 ----
      /**
       *
       */
+ public static class DateTypeConversion implements TypeConversion {
+ /**
+ *
+ */
+ public Object convertValue(Object value) {
+ if (value == null) {
+ return null;
+ }
+
+ if (!(value instanceof java.util.Date)) {
+ String v = value.toString();
+ if (v.trim().length() == 0) {
+ value = null;
+ } else {
+ value = new java.util.Date(v);
+ }
+ }
+
+ return value;
+ }
+ }
+
+ /**
+ *
+ */
      public static class SqlTimeTypeConversion implements TypeConversion {
  
          /**
***************
*** 942,947 ****
--- 968,976 ----
      /** Logical type name "sqldate" */
      public static final String TYPE_SQL_DATE = "sqldate";
  
+ /** Logical type name "sqldate" */
+ public static final String TYPE_DATE = "date";
+
      /** Logical type name "sqltime" */
      public static final String TYPE_SQL_TIME = "sqltime";
  
***************
*** 972,977 ****
--- 1001,1008 ----
              new ByteTypeConversion();
      public static final TypeConversion CHARACTER_TYPE_CONVERSION =
              new CharacterTypeConversion();
+ public static final TypeConversion DATE_TYPE_CONVERSION =
+ new DateTypeConversion();
      public static final TypeConversion SQL_DATE_TYPE_CONVERSION =
              new SqlDateTypeConversion();
      public static final TypeConversion SQL_TIME_TYPE_CONVERSION =
***************
*** 1007,1012 ****
--- 1038,1044 ----
          registerTypeConversion(Byte.TYPE, BYTE_TYPE_CONVERSION);
          registerTypeConversion(Character.class, CHARACTER_TYPE_CONVERSION);
          registerTypeConversion(Character.TYPE, CHARACTER_TYPE_CONVERSION);
+ registerTypeConversion(java.util.Date.class, DATE_TYPE_CONVERSION);
          registerTypeConversion(java.sql.Date.class, SQL_DATE_TYPE_CONVERSION);
          registerTypeConversion(java.sql.Time.class, SQL_TIME_TYPE_CONVERSION);
          registerTypeConversion(java.sql.Timestamp.class, SQL_TIMESTAMP_TYPE_CONVERSION);
***************
*** 1023,1028 ****
--- 1055,1061 ----
          registerTypeConversion(BigDecimal.class.getName(), BIG_DECIMAL_TYPE_CONVERSION);
          registerTypeConversion(Byte.class.getName(), BYTE_TYPE_CONVERSION);
          registerTypeConversion(Character.class.getName(), CHARACTER_TYPE_CONVERSION);
+ registerTypeConversion(java.util.Date.class.getName(), DATE_TYPE_CONVERSION);
          registerTypeConversion(java.sql.Date.class.getName(), SQL_DATE_TYPE_CONVERSION);
          registerTypeConversion(java.sql.Time.class.getName(), SQL_TIME_TYPE_CONVERSION);
          registerTypeConversion(java.sql.Timestamp.class.getName(), SQL_TIMESTAMP_TYPE_CONVERSION);
***************
*** 1042,1047 ****
--- 1075,1081 ----
          registerTypeConversion(TYPE_BYTE, BYTE_TYPE_CONVERSION);
          registerTypeConversion(TYPE_CHAR, CHARACTER_TYPE_CONVERSION);
          registerTypeConversion(TYPE_CHARACTER, CHARACTER_TYPE_CONVERSION);
+ registerTypeConversion(TYPE_DATE, DATE_TYPE_CONVERSION);
          registerTypeConversion(TYPE_SQL_DATE, SQL_DATE_TYPE_CONVERSION);
          registerTypeConversion(TYPE_SQL_TIME, SQL_TIME_TYPE_CONVERSION);
          registerTypeConversion(TYPE_SQL_TIMESTAMP, SQL_TIMESTAMP_TYPE_CONVERSION);