1 12 package org.displaytag.model; 13 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.apache.commons.logging.Log; 18 import org.apache.commons.logging.LogFactory; 19 import org.displaytag.decorator.TableDecorator; 20 21 22 27 public class RowIterator 28 { 29 30 33 private static Log log = LogFactory.getLog(RowIterator.class); 34 35 38 private Iterator iterator; 39 40 43 private int rowNumber; 44 45 48 private TableDecorator decorator; 49 50 53 private String id; 54 55 58 private int pageOffset; 59 60 67 protected RowIterator(List rowList, List columnList, TableDecorator tableDecorator, int offset) 68 { 69 this.iterator = rowList.iterator(); 70 this.rowNumber = 0; 71 this.decorator = tableDecorator; 72 this.pageOffset = offset; 73 } 74 75 79 public void setId(String tableId) 80 { 81 this.id = tableId; 82 } 83 84 88 public boolean hasNext() 89 { 90 return this.iterator.hasNext(); 91 } 92 93 public int getPageOffset() 94 { 95 return this.pageOffset; 96 } 97 98 102 public Row next() 103 { 104 105 int currentRowNumber = this.rowNumber++; 106 107 if (log.isDebugEnabled()) 108 { 109 log.debug("[" + this.id + "] rowIterator.next() row number=" + currentRowNumber); 110 } 111 112 Object object = this.iterator.next(); 113 114 Row row = (Row) object; 115 116 row.setRowNumber(currentRowNumber); 117 118 if (this.decorator != null) 119 { 120 this.decorator.initRow(row.getObject(), currentRowNumber, currentRowNumber + getPageOffset()); 121 } 122 123 return row; 124 125 } 126 127 } | Popular Tags |