final String iName, final String iValue) {
if (iValue == null)
return null;
final ODatabaseRecord database = iSourceRecord.getDatabase();
switch (iType) {
case EMBEDDEDLIST:
case EMBEDDEDSET:
return embeddedCollectionFromStream(database, (ODocument) iSourceRecord, iType, iLinkedClass, iLinkedType, iValue);
case LINKLIST:
case LINKSET: {
if (iValue.length() == 0)
return null;
// REMOVE BEGIN & END COLLECTIONS CHARACTERS IF IT'S A COLLECTION
final String value = iValue.startsWith("[") ? iValue.substring(1, iValue.length() - 1) : iValue;
return iType == OType.LINKLIST ? new ORecordLazyList(iSourceRecord).setStreamedContent(new StringBuilder(value))
: new ORecordLazySet(iSourceRecord).setStreamedContent(new StringBuilder(value));
}
case LINKMAP: {
if (iValue.length() == 0)
return null;
// REMOVE BEGIN & END MAP CHARACTERS
String value = iValue.substring(1, iValue.length() - 1);
@SuppressWarnings("rawtypes")
final Map map = new ORecordLazyMap(iSourceRecord, ODocument.RECORD_TYPE);
if (value.length() == 0)
return map;
final List<String> items = OStringSerializerHelper.smartSplit(value, OStringSerializerHelper.RECORD_SEPARATOR);
// EMBEDDED LITERALS
for (String item : items) {
if (item != null && item.length() > 0) {
final List<String> entry = OStringSerializerHelper.smartSplit(item, OStringSerializerHelper.ENTRY_SEPARATOR);
if (entry.size() > 0) {
String mapValue = entry.get(1);
if (mapValue != null && mapValue.length() > 0)
mapValue = mapValue.substring(1);
map.put(fieldTypeFromStream((ODocument) iSourceRecord, OType.STRING, entry.get(0)), new ORecordId(mapValue));
}
}
}
return map;
}
case EMBEDDEDMAP:
return embeddedMapFromStream((ODocument) iSourceRecord, iLinkedType, iValue);
case LINK:
if (iValue.length() > 1) {
int pos = iValue.indexOf(OStringSerializerHelper.CLASS_SEPARATOR);
if (pos > -1)
iLinkedClass = database.getMetadata().getSchema().getClass(iValue.substring(1, pos));
else
pos = 0;
return new ORecordId(iValue.substring(pos + 1));
} else