Alachisoft.NCache.Common.Util.SerializationUtility Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-common Show documentation
Show all versions of nc-common Show documentation
Internal package of Alachisoft.
package Alachisoft.NCache.Common.Util;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectInput;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectOutput;
import java.io.IOException;
import java.util.HashMap;
public class SerializationUtility {
public static void serializeDictionary(java.util.Map dictionary, NCacheObjectOutput writer) throws IOException
{
if (dictionary == null)
{
writer.writeBoolean(false);
return;
}
else
{
writer.writeBoolean(true);
writer.write(dictionary.size());
for (java.util.Iterator> i = dictionary.entrySet().iterator(); i.hasNext();)
{
writer.writeObject(i.next().getKey());
writer.writeObject(i.next().getValue());
}
}
}
/**
@param reader
@return
*/
//C# TO JAVA CONVERTER TODO TASK: C# optional parameters are not converted to Java:
//ORIGINAL LINE: public static IDictionary DeserializeDictionary(Runtime.Serialization.IO.CompactReader reader,IEqualityComparer comparer = null)
public static java.util.Map deserializeDictionary(NCacheObjectInput reader) throws IOException, ClassNotFoundException
{
T key;
V val;
boolean flag = reader.readBoolean();
if (flag)
{
java.util.Map dictionary = new HashMap();
int Length = reader.readInt();
for (int i = 0; i < Length; i++)
{
key = (T)reader.readObject();
val = (V)reader.readObject();
dictionary.put(key, val);
}
return dictionary;
}
else
{
return null;
}
}
}