String fieldName = null;
String fieldValue;
OType type;
OClass linkedClass;
OType linkedType;
OProperty prop;
final Set<String> fieldSet;
if (iFields != null && iFields.length > 0) {
fieldSet = new HashSet<String>(iFields.length);
for (String f : iFields)
fieldSet.add(f);
} else
fieldSet = null;
// UNMARSHALL ALL THE FIELDS
for (String fieldEntry : fields) {
fieldEntry = fieldEntry.trim();
boolean uncertainType = false;
try {
pos = fieldEntry.indexOf(FIELD_VALUE_SEPARATOR);
if (pos > -1) {
// GET THE FIELD NAME
fieldName = fieldEntry.substring(0, pos);
// CHECK IF THE FIELD IS REQUESTED TO BEING UNMARSHALLED
if (fieldSet != null && !fieldSet.contains(fieldName))
continue;
if (record.containsField(fieldName))
// ALREADY UNMARSHALLED: DON'T OVERWRITE IT
continue;
// GET THE FIELD VALUE
fieldValue = fieldEntry.length() > pos + 1 ? fieldEntry.substring(pos + 1) : null;
boolean setFieldType = false;
// SEARCH FOR A CONFIGURED PROPERTY
prop = record.getSchemaClass() != null ? record.getSchemaClass().getProperty(fieldName) : null;
if (prop != null && prop.getType() != OType.ANY) {
// RECOGNIZED PROPERTY
type = prop.getType();
linkedClass = prop.getLinkedClass();
linkedType = prop.getLinkedType();
} else {
// SCHEMA PROPERTY NOT FOUND FOR THIS FIELD: TRY TO AUTODETERMINE THE BEST TYPE
type = record.fieldType(fieldName);
if (type == OType.ANY)