* @throws WGBackendException
* @see de.innovationgate.wgpublisher.webtml.utils.ResultSetTagStatus#getContentList(int, int)
*/
public WGContentList getContentList(int start, int length) throws WGBackendException {
WGContentList list = new WGContentList();
Iterator sets = this.resultSets.iterator();
WGResultSet currentSet = null;
// First get to start position
int startCtr = start;
while (sets.hasNext()) {
currentSet = (WGResultSet) sets.next();
if (currentSet.results() < startCtr) {
startCtr -= currentSet.results();
currentSet = null;
}
else {
break;
}
}
if (currentSet == null) {
return list;
}
// The contents of this set is enough to fit the length
if (currentSet.results() >= startCtr + (length - 1)) {
try {
return currentSet.getContentList(startCtr, length);
}
catch (WGAPIException e) {
tmlContext.addwarning("Unable to retrieve content list from resultset. Exception: '" + e.getClass().getName() + "' message: '" + e.getMessage() + "'.");
return list;
}
}
// Multiple sets are needed to fit the length
else {
// Take the first contents from this set;
int lengthCtr = length;
int lengthThisSet = ((int) currentSet.results()) - startCtr + 1;
try {
list.addAll(currentSet.getContentList(startCtr, lengthThisSet));
lengthCtr -= lengthThisSet;
}
catch (WGAPIException e) {
tmlContext.addwarning("Unable to retrieve content list from resultset. Exception: '" + e.getClass().getName() + "' message: '" + e.getMessage() + "'.");
}
// Take more contents from coming sets
while (sets.hasNext()) {
currentSet = (WGResultSet) sets.next();
// This set has to be taken completely (< remaining length)
if (currentSet.results() <= lengthCtr) {
lengthThisSet = ((int) currentSet.results());
try {
list.addAll(currentSet.getContentList(1, lengthThisSet));
lengthCtr -= lengthThisSet;
}
catch (WGAPIException e) {
tmlContext.addwarning("Unable to retrieve content list from resultset. Exception: '" + e.getClass().getName() + "' message: '" + e.getMessage() + "'.");
}
}
// This sets contents fits the remaining length
else {
lengthThisSet = lengthCtr;
try {
list.addAll(currentSet.getContentList(1, lengthThisSet));
}
catch (WGAPIException e) {
tmlContext.addwarning("Unable to retrieve content list from resultset. Exception: '" + e.getClass().getName() + "' message: '" + e.getMessage() + "'.");
}
break;