package de.se.buzzer.handler; import java.util.ArrayList; import java.util.List; import de.se.buzzer.LineContainer; /** * @author M. Friedeboldt */ public class AnswerHandler { private ContentLoaderInterface loaderInterface; private int count; private List contentList; /** * @param loaderInterface */ public AnswerHandler(ContentLoaderInterface loaderInterface) { this.loaderInterface = loaderInterface; } /** * @param count */ public void setCount(int count) { this.count = count; } /** * @param lines */ public void putLines(List lines) { if ( this.contentList == null ) contentList = new ArrayList(); contentList.addAll( lines ); } /** * @param index * @param max * @return */ public List getLines(int index, int max) throws Exception { if ( this.contentList == null || this.contentList.size() == 0 || this.contentList.size() <= index ) { // nachladen putLines( loaderInterface.loadLineContainers( index ) ); } List res = new ArrayList(); for ( int i = index; i < (index + max); i++ ) { if ( contentList.size() > i ) res.add( contentList.get( i ) ); } return res; } }