ByteArrayInputStream bais = new ByteArrayInputStream(marshalledState);
DataInputStream dis = new DataInputStream(bais);
int magicValue = dis.readInt();
if (magicValue != MAGIC_VALUE)
{
throw new StateConversionException("Bad magic value " + Integer.toHexString(magicValue));
}
byte versionId = dis.readByte();
if (versionId > 0)
{
throw new StateConversionException("Bad version id " + versionId);
}
String portletId = dis.readUTF();
int size = dis.readInt();
PropertyMap properties = new SimplePropertyMap(size);
while (size-- > 0)
{
String key = dis.readUTF();
int length = dis.readInt();
String[] strings = new String[length];
for (int i = 0; i < strings.length; i++)
{
boolean isNull = dis.readBoolean();
if (isNull == false)
{
String string = dis.readUTF();
strings[i] = string;
}
}
List<String> value = Arrays.asList(strings.clone());
properties.setProperty(key, value);
}
return new PortletState(portletId, properties);
}
catch (IOException e)
{
throw new StateConversionException(e);
}
}