svn commit: r585811 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize: XmlSerializable.java XmlSerializer.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r585811 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize: XmlSerializable.java XmlSerializer.java

doogie-3
Author: doogie
Date: Wed Oct 17 20:10:26 2007
New Revision: 585811

URL: http://svn.apache.org/viewvc?rev=585811&view=rev
Log:
Java 1.5 markup for entity serialize.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializable.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializable.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializable.java?rev=585811&r1=585810&r2=585811&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializable.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializable.java Wed Oct 17 20:10:26 2007
@@ -24,14 +24,14 @@
  * XmlSerializable
  *
  */
-public interface XmlSerializable {
+public interface XmlSerializable<T> {
 
     /**
      * Deserialize the XML element back to an object
      * @param element XML element
      * @throws SerializeException
      */
-    public Object deserialize(Element element) throws SerializeException;
+    public T deserialize(Element element) throws SerializeException;
 
     /**
      * Serialize the object to an XML element

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java?rev=585811&r1=585810&r2=585811&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/serialize/XmlSerializer.java Wed Oct 17 20:10:26 2007
@@ -64,7 +64,7 @@
 public class XmlSerializer {
     public static final String module = XmlSerializer.class.getName();
 
-    private static WeakReference simpleDateFormatter;
+    private static WeakReference<DateFormat> simpleDateFormatter;
 
     public static String serialize(Object object) throws SerializeException, FileNotFoundException, IOException {
         Document document = UtilXml.makeEmptyXmlDocument("ofbiz-ser");
@@ -299,22 +299,22 @@
             }
         } else if (tagName.startsWith("col-")) {
             // - Collections -
-            Collection value = null;
+            Collection<Object> value = null;
 
             if ("col-ArrayList".equals(tagName)) {
-                value = new ArrayList();
+                value = new ArrayList<Object>();
             } else if ("col-LinkedList".equals(tagName)) {
-                value = new LinkedList();
+                value = new LinkedList<Object>();
             } else if ("col-Stack".equals(tagName)) {
-                value = new Stack();
+                value = new Stack<Object>();
             } else if ("col-Vector".equals(tagName)) {
-                value = new Vector();
+                value = new Vector<Object>();
             } else if ("col-TreeSet".equals(tagName)) {
-                value = new TreeSet();
+                value = new TreeSet<Object>();
             } else if ("col-HashSet".equals(tagName)) {
-                value = new HashSet();
+                value = new HashSet<Object>();
             } else if ("col-Collection".equals(tagName)) {
-                value = new LinkedList();
+                value = new LinkedList<Object>();
             }
 
             if (value == null) {
@@ -332,20 +332,20 @@
             }
         } else if (tagName.startsWith("map-")) {
             // - Maps -
-            Map value = null;
+            Map<Object, Object> value = null;
 
             if ("map-HashMap".equals(tagName)) {
-                value = new HashMap();
+                value = new HashMap<Object, Object>();
             } else if ("map-Properties".equals(tagName)) {
                 value = new Properties();
             } else if ("map-Hashtable".equals(tagName)) {
-                value = new Hashtable();
+                value = new Hashtable<Object, Object>();
             } else if ("map-WeakHashMap".equals(tagName)) {
-                value = new WeakHashMap();
+                value = new WeakHashMap<Object, Object>();
             } else if ("map-TreeMap".equals(tagName)) {
-                value = new TreeMap();
+                value = new TreeMap<Object, Object>();
             } else if ("map-Map".equals(tagName)) {
-                value = new HashMap();
+                value = new HashMap<Object, Object>();
             }
 
             if (value == null) {
@@ -431,11 +431,11 @@
         DateFormat formatter = null;
 
         if (simpleDateFormatter != null) {
-            formatter = (DateFormat) simpleDateFormatter.get();
+            formatter = simpleDateFormatter.get();
         }
         if (formatter == null) {
             formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
-            simpleDateFormatter = new WeakReference(formatter);
+            simpleDateFormatter = new WeakReference<DateFormat>(formatter);
         }
         return formatter;
     }