You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/03/09 08:46:52 UTC

svn commit: r516321 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java

Author: jonesde
Date: Thu Mar  8 23:46:51 2007
New Revision: 516321

URL: http://svn.apache.org/viewvc?view=rev&rev=516321
Log:
Added a bunch of stuff to do a pseudo converstion from objects to List and Set by creating a List or Set and putting the object in it

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java?view=diff&rev=516321&r1=516320&r2=516321
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java Thu Mar  8 23:46:51 2007
@@ -30,8 +30,11 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 
+import javolution.util.FastList;
 import javolution.util.FastMap;
+import javolution.util.FastSet;
 
 /**
  * Utilities for analyzing and converting Object types in Java 
@@ -641,6 +644,14 @@
                         throw new GeneralException("Could not convert " + str + " to " + type + ": ", e);
                     }
                 }
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(str);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(str);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -667,6 +678,14 @@
                 return new Long(Math.round(dbl.doubleValue()));
             } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {
                 return new Integer((int) Math.round(dbl.doubleValue()));
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(dbl);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(dbl);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -692,6 +711,14 @@
                 return new Long(Math.round(flt.doubleValue()));
             } else if ("Integer".equals(type)) {
                 return new Integer((int) Math.round(flt.doubleValue()));
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(flt);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(flt);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -717,6 +744,14 @@
                 return obj;
             } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {
                 return new Integer(lng.intValue());
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(lng);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(lng);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -741,6 +776,14 @@
                 return new Long(intgr.longValue());
             } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {
                 return obj;
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(intgr);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(intgr);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -765,6 +808,14 @@
                 return new Long(bigDec.longValue());
             } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {
                 return new Integer(bigDec.intValue());
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(bigDec);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(bigDec);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -784,6 +835,14 @@
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) {
                 return new java.sql.Timestamp(dte.getTime());
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(dte);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(dte);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -805,6 +864,14 @@
                 return obj;
             } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) {
                 return new java.sql.Timestamp(tme.getTime());
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(tme);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(tme);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -826,6 +893,14 @@
                 return new java.sql.Time(tme.getTime());
             } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) {
                 return obj;
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(tme);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(tme);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -837,10 +912,19 @@
             } else if ("String".equals(type) || "java.lang.String".equals(type)) {
                 return bol.toString();
             } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {
-                if (bol.booleanValue())
+                if (bol.booleanValue()) {
                     return new Integer(1);
-                else
-                    return new Integer(0);                
+                } else {
+                    return new Integer(0);
+                }
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(bol);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(bol);
+                return tempSet;
             } else { 
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");
             }
@@ -862,6 +946,14 @@
                 return obj;           
             } else if ("String".equals(type) || "java.lang.String".equals(type)) {
                 return obj.toString();   
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(obj);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(obj);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            
             }            
@@ -872,6 +964,14 @@
                 return map;
             } else if ("String".equals(type) || "java.lang.String".equals(type)) {
                 return map.toString();
+            } else if ("List".equals(type) || "java.util.List".equals(type)) {
+                List tempList = FastList.newInstance();
+                tempList.add(obj);
+                return tempList;
+            } else if ("Set".equals(type) || "java.util.Set".equals(type)) {
+                Set tempSet = FastSet.newInstance();
+                tempSet.add(obj);
+                return tempSet;
             } else {
                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            
             }