[seam-commits] Seam SVN: r8496 - in trunk/src/remoting/org/jboss/seam/remoting: wrapper and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Jul 24 04:30:20 EDT 2008
Author: shane.bryzak at jboss.com
Date: 2008-07-24 04:30:20 -0400 (Thu, 24 Jul 2008)
New Revision: 8496
Modified:
trunk/src/remoting/org/jboss/seam/remoting/InterfaceGenerator.java
trunk/src/remoting/org/jboss/seam/remoting/wrapper/DateWrapper.java
trunk/src/remoting/org/jboss/seam/remoting/wrapper/WrapperFactory.java
Log:
JBSEAM-3174
Modified: trunk/src/remoting/org/jboss/seam/remoting/InterfaceGenerator.java
===================================================================
--- trunk/src/remoting/org/jboss/seam/remoting/InterfaceGenerator.java 2008-07-23 06:55:53 UTC (rev 8495)
+++ trunk/src/remoting/org/jboss/seam/remoting/InterfaceGenerator.java 2008-07-24 08:30:20 UTC (rev 8496)
@@ -10,6 +10,7 @@
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Enumeration;
@@ -658,7 +659,7 @@
else if (type instanceof Class)
{
Class cls = (Class) type;
- if (Date.class.isAssignableFrom(cls))
+ if (Date.class.isAssignableFrom(cls) || Calendar.class.isAssignableFrom(cls))
return "date";
else if (cls.isArray())
return "bag";
Modified: trunk/src/remoting/org/jboss/seam/remoting/wrapper/DateWrapper.java
===================================================================
--- trunk/src/remoting/org/jboss/seam/remoting/wrapper/DateWrapper.java 2008-07-23 06:55:53 UTC (rev 8495)
+++ trunk/src/remoting/org/jboss/seam/remoting/wrapper/DateWrapper.java 2008-07-24 08:30:20 UTC (rev 8496)
@@ -6,6 +6,7 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
/**
@@ -22,7 +23,14 @@
public void marshal(OutputStream out) throws IOException
{
out.write(DATE_TAG_OPEN);
- out.write(df.format(value).getBytes());
+ if (Date.class.isAssignableFrom(value.getClass()))
+ {
+ out.write(df.format(value).getBytes());
+ }
+ else if (Calendar.class.isAssignableFrom(value.getClass()))
+ {
+ out.write(df.format(((Calendar) value).getTime()).getBytes());
+ }
out.write(DATE_TAG_CLOSE);
}
@@ -35,11 +43,26 @@
try {
value = df.parse(element.getStringValue());
}
- catch (ParseException ex) {
+ catch (ParseException ex)
+ {
throw new ConversionException(String.format(
"Date value [%s] is not in a valid format.", element.getStringValue()));
}
}
+ else if ((type instanceof Class && Calendar.class.isAssignableFrom((Class) type)))
+ {
+ try
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(df.parse(element.getStringValue()));
+ value = cal;
+ }
+ catch (ParseException ex)
+ {
+ throw new ConversionException(String.format(
+ "Date value [%s] is not in a valid format.", element.getStringValue()));
+ }
+ }
else
throw new ConversionException(String.format(
"Value [%s] cannot be converted to type [%s].", element.getStringValue(),
@@ -50,7 +73,7 @@
public ConversionScore conversionScore(Class cls)
{
- if (Date.class.isAssignableFrom(cls))
+ if (Date.class.isAssignableFrom(cls) || Calendar.class.isAssignableFrom(cls))
return ConversionScore.exact;
else if (cls.equals(Object.class))
return ConversionScore.compatible;
Modified: trunk/src/remoting/org/jboss/seam/remoting/wrapper/WrapperFactory.java
===================================================================
--- trunk/src/remoting/org/jboss/seam/remoting/wrapper/WrapperFactory.java 2008-07-23 06:55:53 UTC (rev 8495)
+++ trunk/src/remoting/org/jboss/seam/remoting/wrapper/WrapperFactory.java 2008-07-24 08:30:20 UTC (rev 8496)
@@ -2,6 +2,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -106,7 +107,7 @@
w = new BooleanWrapper();
else if (obj.getClass().isEnum())
w = new StringWrapper();
- else if (Date.class.isAssignableFrom(obj.getClass()))
+ else if (Date.class.isAssignableFrom(obj.getClass()) || Calendar.class.isAssignableFrom(obj.getClass()))
w = new DateWrapper();
else if (classRegistry.containsKey(obj.getClass()))
{
More information about the seam-commits
mailing list