org.apache.wiki.util
Class Serializer

java.lang.Object
  extended by org.apache.wiki.util.Serializer

public final class Serializer
extends Object

Provides static helper functions for serializing different objects.

Since:
2.8

Field Summary
protected static String BASE64_PREFIX
          Prefix used to indicated that a serialized item was encoded with Base64.
 
Method Summary
static Map<String,? extends Serializable> deserializeFromBase64(String rawString)
          Deserializes a Base64-encoded String into a HashMap.
static String serializeToBase64(Map<String,Serializable> map)
          Serializes a Map and formats it into a Base64-encoded String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE64_PREFIX

protected static final String BASE64_PREFIX
Prefix used to indicated that a serialized item was encoded with Base64.

See Also:
Constant Field Values
Method Detail

deserializeFromBase64

public static Map<String,? extends Serializable> deserializeFromBase64(String rawString)
                                                                throws IOException
Deserializes a Base64-encoded String into a HashMap. Both the keys and values must implement Serializable.

Parameters:
rawString - the String contents containing the map to be deserialized
Returns:
the attributes, parsed into a Map
Throws:
IOException - if the contents cannot be parsed for any reason

serializeToBase64

public static String serializeToBase64(Map<String,Serializable> map)
                                throws IOException
Serializes a Map and formats it into a Base64-encoded String. For ease of serialization, the Map contents are first copied into a HashMap, then serialized into a byte array that is encoded as a Base64 String.

Parameters:
map - the Map to serialize
Returns:
a String representing the serialized form of the Map
Throws:
IOException - If serialization cannot be done


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.