1 5 package org.exoplatform.text.template; 6 7 import java.util.ArrayList ; 8 import java.util.List ; 9 10 15 public class ListBeanDataHandler extends BeanDataHandler implements CollectionDataHandler { 16 protected List beans_; 17 protected int currentRow_; 18 19 public ListBeanDataHandler(Class type) { 20 super(type) ; 21 } 22 23 public ListBeanDataHandler setBeans(List beans) { 24 beans_ = beans; 25 return this; 26 } 27 28 public ListBeanDataHandler setBeans(Object [] beans) { 29 beans_ = new ArrayList (beans.length + 3); 30 for(int i = 0 ; i < beans.length; i++) { 31 beans_.add(beans[i]); 32 } 33 return this; 34 } 35 36 public void begin() { 37 currentRow_ = -1; 38 } 39 40 public void end() { 41 } 42 43 public boolean nextRow() { 44 currentRow_++; 45 if (beans_ != null) { 46 if (currentRow_ < beans_.size()) { 47 setBean(beans_.get(currentRow_)); 48 return true; 49 } 50 } 51 return false; 52 } 53 54 public int getCurrentRow() { return currentRow_; } 55 56 public Object getCurrentBean() { return beans_.get(currentRow_); } 57 58 public Object getBean(int index) { return beans_.get(index); } 59 60 public List getBeans() { return beans_ ; } 61 } 62 | Popular Tags |