use of org.bimserver.models.store.IfcHeader in project BIMserver by opensourceBIM.
the class SharedJsonSerializer method write.
public boolean write(OutputStream outputStream, ProgressReporter progressReporter) throws SerializerException {
this.outputStream = outputStream;
try {
if (mode == Mode.HEADER) {
print("{");
IfcHeader ifcHeader = model.getModelMetaData().getIfcHeader();
if (ifcHeader != null) {
print("\"header\":");
writeObject(ifcHeader);
print("\n,");
}
print("\"objects\":[");
mode = Mode.BODY;
iterator = model.iterator();
return true;
} else if (mode == Mode.BODY) {
if (iterator.hasNext()) {
IdEObject object = iterator.next();
if (object.getOid() == -1) {
throw new SerializerException("Object cannot have oid -1 " + object.eClass().getName());
}
if (object.eClass().getEAnnotation("hidden") == null || includeHidden) {
if (!firstObject) {
print(",");
} else {
firstObject = false;
}
writeObject(object);
}
return true;
} else {
print("]");
print("}");
mode = Mode.FOOTER;
return true;
}
} else if (mode == Mode.FOOTER) {
mode = Mode.DONE;
return false;
}
} catch (Throwable e) {
throw new SerializerException(e);
}
return false;
}
Aggregations