Map<String, String> oldUuidToNewUuid ) throws IOException, ClassNotFoundException {
assert input != null;
assert output != null;
if (oldUuidToNewUuid == null) oldUuidToNewUuid = Collections.emptyMap();
UuidFactory uuidFactory = valueFactories.getUuidFactory();
ValueFactory<Reference> referenceFactory = valueFactories.getReferenceFactory();
// Read the number of properties ...
int count = input.readInt();
output.writeInt(count);
// Deserialize all of the proeprties ...
for (int i = 0; i != count; ++i) {
// Read and write the property name ...
Object name = input.readObject();
output.writeObject(name);
// Read and write the number of values ...
int numValues = input.readInt();
output.writeInt(numValues);
// Now read and write each property value ...
for (int j = 0; j != numValues; ++j) {
// Read and write the type of value ...
char type = input.readChar();
output.writeChar(type);
switch (type) {
case 'S':
output.writeObject(input.readObject());
break;
case 'b':
output.writeBoolean(input.readBoolean());
break;
case 'i':
output.writeInt(input.readInt());
break;
case 'l':
output.writeLong(input.readLong());
break;
case 's':
output.writeShort(input.readShort());
break;
case 'f':
output.writeFloat(input.readFloat());
break;
case 'd':
output.writeDouble(input.readDouble());
break;
case 'c':
// char
output.writeChar(input.readChar());
break;
case 'U':
// UUID
output.writeLong(input.readLong());
output.writeLong(input.readLong());
break;
case 'I':
// URI
output.writeObject(input.readObject());
break;
case 'N':
// Name
output.writeObject(input.readObject());
break;
case 'P':
// Path
output.writeObject(input.readObject());
break;
case 'T':
// DateTime
output.writeObject(input.readObject());
break;
case 'D':
// BigDecimal
output.writeObject(input.readObject());
break;
case 'R':
// Reference
String refValue = (String)input.readObject();
Reference ref = referenceFactory.create(refValue);
try {
UUID toUuid = uuidFactory.create(ref);
String newUuid = oldUuidToNewUuid.get(toUuid.toString());
if (newUuid != null) {
// Create a new reference ...
ref = referenceFactory.create(newUuid);
refValue = ref.getString();