private ResultIterator retrieveResultIterator() throws TMLException, WGAPIException {
ResultIterator objectIterator = null;
Status status = (Status) getStatus();
if (status.forEachType.equals("content")) {
ResultSetTagStatus tag;
if (this.getSourcetag() != null) {
tag = (ResultSetTagStatus) this.getTagStatusById(this.getSourcetag(), ResultSetTagStatus.class);
if (tag == null) {
throw new TMLException("Could not find content list tag with id " + this.getSourcetag(), true);
}
}
else if (this.getRelationgroup() != null) {
String group = getRelationgroup();
status.contentLanguage = getTMLContext().content().getLanguage().getName();
return new ResultIterator(getTMLContext().content().getRelationsOfGroup(group));
}
else if (getStatus() instanceof ResultSetTagStatus) {
tag = (ResultSetTagStatus) getStatus();
}
else {
tag = (ResultSetTagStatus) getStatus().getAncestorTag(ResultSetTagStatus.class);
if (tag == null) {
throw new TMLException("No content list tag specified", true);
}
}
objectIterator = tag.getResultIterator();
status.contentLanguage = tag.getResultLanguage();
}
else if (status.forEachType.equals("loop") || status.forEachType.equals("level")) {
int count = 0;