Class type = blueprint.get(key).getClass();
if (Util.isDatatype(type)) {
document.put(key,valueList.getNextObject());
} else if (type.isArray()) {
// DocumentType.TYPE_EMBEDDED_ARRAY
ValueList tempList = valueList.getNextList();
if ((tempList == null) || (tempList.length() == 0)) {
document.put(key,null);
continue;
}
NoSchemaDocument[] references = new NoSchemaDocument[tempList.length()];
for (int j=0;j<tempList.length();j++) {
references[j] = new NoSchemaDocument();
ValueList tList = tempList.getNextList();
read(references[j],tList,((NoSchemaDocument[])blueprint.get(key))[0]);
}
document.put(key,references);
//} TODO else if (type == DocumentType.TYPE_REFERENCE_ARRAY) {
// embedded or reference
} else {
Object nestedDoc = blueprint.get(key);
// embedded
if (nestedDoc instanceof NoSchemaDocument) {
ValueList vList = valueList.getNextList();
NoSchemaDocument nDocument = new NoSchemaDocument();
for (int j=0;j<vList.length()/2;j++) {
String nKey = vList.getNextString();
// TODO more nesting?
String nValue = vList.getNextString();
NodeReference tempGlobal = connection.createNodeReference(nKey);
if (tempGlobal.exists(nValue)) {
// this is a reference
read(nDocument,tempGlobal.getList(nValue),(NoSchemaDocument)blueprint.get(key));