Author: ajaquith
Date: Wed Jun 11 23:29:28 2008
New Revision: 666976

URL: http://svn.apache.org/viewvc?rev=666976&view=rev
Log:
Minor tightening of Map API for Serializer methods; the keys are now Strings 
rather than Serializable. This is a dev branch, remember!

Modified:
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/Serializer.java

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/Serializer.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/Serializer.java?rev=666976&r1=666975&r2=666976&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/Serializer.java 
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/Serializer.java Wed Jun 
11 23:29:28 2008
@@ -34,6 +34,11 @@
 public final class Serializer
 {
     /**
+     * Prefix used to indicated that a serialized item was encoded with Base64.
+     */
+    protected static final String BASE64_PREFIX = "base64 ";
+
+    /**
      *  Prevent instantiation.
      */
     private Serializer()
@@ -47,7 +52,7 @@
      * @throws IOException if the contents cannot be parsed for any reason
      */
     @SuppressWarnings("unchecked")
-    public static Map<? extends Serializable,? extends Serializable> 
deserializeFromBase64( String rawString ) throws IOException
+    public static Map<String,? extends Serializable> deserializeFromBase64( 
String rawString ) throws IOException
     {
         // Decode from Base64-encoded String to byte array
         byte[] decodedBytes = Base64.decodeBase64( rawString.getBytes("UTF-8") 
);
@@ -55,10 +60,10 @@
         // Deserialize from the input stream to the Map
         InputStream bytesIn = new ByteArrayInputStream( decodedBytes );
         ObjectInputStream in = new ObjectInputStream( bytesIn );
-        HashMap<Serializable,Serializable> attributes;
+        HashMap<String,Serializable> attributes;
         try
         {
-            attributes = (HashMap<Serializable,Serializable>)in.readObject();
+            attributes = (HashMap<String,Serializable>)in.readObject();
         }
         catch ( ClassNotFoundException e )
         {
@@ -78,10 +83,10 @@
      * @return a String representing the serialized form of the Map
      * @throws IOException If serialization cannot be done
      */
-    public static String serializeToBase64( Map<Serializable,Serializable> map 
) throws IOException
+    public static String serializeToBase64( Map<String,Serializable> map ) 
throws IOException
     {
         // Load the Map contents into a defensive HashMap
-        HashMap<Serializable,Serializable> serialMap = new 
HashMap<Serializable,Serializable>();
+        HashMap<String,Serializable> serialMap = new 
HashMap<String,Serializable>();
         serialMap.putAll( map );
         
         // Serialize the Map to an output stream


Reply via email to