if (iValue instanceof ORecordLazyList && ((ORecordLazyList) iValue).getStreamedContent() != null) {
iOutput.append(((ORecordLazyList) iValue).getStreamedContent());
OProfiler.getInstance().updateCounter("serializer.rec.str.linkList2string.cached", +1);
} else {
final ORecordLazyList coll;
final Iterator<OIdentifiable> it;
if (!(iValue instanceof ORecordLazyList)) {
// FIRST TIME: CONVERT THE ENTIRE COLLECTION
coll = new ORecordLazyList(iRecord);
coll.addAll((Collection<? extends OIdentifiable>) iValue);
((Collection<? extends OIdentifiable>) iValue).clear();
iRecord.field(iName, coll);
it = coll.rawIterator();
} else {
// LAZY LIST
coll = (ORecordLazyList) iValue;
if (coll.getStreamedContent() != null) {
// APPEND STREAMED CONTENT
iOutput.append(coll.getStreamedContent());
OProfiler.getInstance().updateCounter("serializer.rec.str.linkList2string.cached", +1);
it = coll.newItemsIterator();
} else
it = coll.rawIterator();
}
if (it != null && it.hasNext()) {
final StringBuilder buffer = new StringBuilder();
for (int items = 0; it.hasNext(); items++) {
if (items > 0)
buffer.append(OStringSerializerHelper.RECORD_SEPARATOR);
final OIdentifiable item = it.next();
linkToStream(buffer, iRecord, item);
}
coll.convertRecords2Links();
iOutput.append(buffer);
// UPDATE THE STREAM
coll.setStreamedContent(buffer);
}
}
iOutput.append(OStringSerializerHelper.COLLECTION_END);
OProfiler.getInstance().stopChrono("serializer.rec.str.linkList2string", timer);
break;
}
case LINKSET: {
final ORecordLazySet coll;
if (!(iValue instanceof ORecordLazySet)) {
// FIRST TIME: CONVERT THE ENTIRE COLLECTION
coll = new ORecordLazySet(iRecord);
coll.addAll((Collection<? extends OIdentifiable>) iValue);
((Collection<? extends OIdentifiable>) iValue).clear();
iRecord.field(iName, coll);
} else
// LAZY SET