1 28 package net.sf.jasperreports.engine.data; 29 30 import java.util.Map ; 31 32 import net.sf.jasperreports.engine.JRField; 33 import net.sf.jasperreports.engine.JRRewindableDataSource; 34 35 36 40 public class JRMapArrayDataSource implements JRRewindableDataSource 41 { 42 43 44 47 private Object [] records = null; 48 private int index = -1; 49 50 51 54 public JRMapArrayDataSource(Object [] array) 55 { 56 records = array; 57 } 58 59 60 63 public boolean next() 64 { 65 index++; 66 67 if (records != null) 68 { 69 return (index < records.length); 70 } 71 72 return false; 73 } 74 75 76 79 public Object getFieldValue(JRField field) 80 { 81 Object value = null; 82 83 Map currentRecord = (Map )records[index]; 84 85 if (currentRecord != null) 86 { 87 value = currentRecord.get(field.getName()); 88 } 89 90 return value; 91 } 92 93 94 97 public void moveFirst() 98 { 99 this.index = -1; 100 } 101 102 103 } 104 | Popular Tags |