if (returnFields!=null && !returnFields.contains(fname)) {
continue;
}
// if the field is multivalued, it may have other values further on... so
// build up a list for each multi-valued field.
SchemaField sf = schema.getField(fname);
if (sf.multiValued()) {
MultiValueField mf = multi.get(fname);
if (mf==null) {
mf = new MultiValueField(sf, ff);
multi.put(fname, mf);
} else {
mf.fields.add(ff);
}
} else {
single.add(ff);
}
}
// obtain number of fields in doc
writeArrayOpener(single.size() + multi.size() + ((pseudoFields!=null) ? pseudoFields.size() : 0));
// output single value fields
for(Fieldable ff : single) {
SchemaField sf = schema.getField(ff.name());
writeKey(ff.name(),true);
sf.write(this, ff.name(), ff);
}
// output multi value fields
for(MultiValueField mvf : multi.values()) {
writeKey(mvf.sfield.getName(), true);