1 28 package datasource; 29 30 import net.sf.jasperreports.engine.JRDataSource; 31 import net.sf.jasperreports.engine.JRException; 32 import net.sf.jasperreports.engine.JRField; 33 34 35 39 public class WebappDataSource implements JRDataSource 40 { 41 42 43 46 private Object [][] data = 47 { 48 {"Berne", new Integer (22), "Bill Ott", "250 - 20th Ave."}, 49 {"Berne", new Integer (9), "James Schneider", "277 Seventh Av."}, 50 {"Boston", new Integer (32), "Michael Ott", "339 College Av."}, 51 {"Boston", new Integer (23), "Julia Heiniger", "358 College Av."}, 52 {"Chicago", new Integer (39), "Mary Karsen", "202 College Av."}, 53 {"Chicago", new Integer (35), "George Karsen", "412 College Av."}, 54 {"Chicago", new Integer (11), "Julia White", "412 Upland Pl."}, 55 {"Dallas", new Integer (47), "Janet Fuller", "445 Upland Pl."}, 56 {"Dallas", new Integer (43), "Susanne Smith", "2 Upland Pl."}, 57 {"Dallas", new Integer (40), "Susanne Miller", "440 - 20th Ave."}, 58 {"Dallas", new Integer (36), "John Steel", "276 Upland Pl."}, 59 {"Dallas", new Integer (37), "Michael Clancy", "19 Seventh Av."}, 60 {"Dallas", new Integer (19), "Susanne Heiniger", "86 - 20th Ave."}, 61 {"Dallas", new Integer (10), "Anne Fuller", "135 Upland Pl."}, 62 {"Dallas", new Integer (4), "Sylvia Ringer", "365 College Av."}, 63 {"Dallas", new Integer (0), "Laura Steel", "429 Seventh Av."}, 64 {"Lyon", new Integer (38), "Andrew Heiniger", "347 College Av."}, 65 {"Lyon", new Integer (28), "Susanne White", "74 - 20th Ave."}, 66 {"Lyon", new Integer (17), "Laura Ott", "443 Seventh Av."}, 67 {"Lyon", new Integer (2), "Anne Miller", "20 Upland Pl."}, 68 {"New York", new Integer (46), "Andrew May", "172 Seventh Av."}, 69 {"New York", new Integer (44), "Sylvia Ott", "361 College Av."}, 70 {"New York", new Integer (41), "Bill King", "546 College Av."}, 71 {"Oslo", new Integer (45), "Janet May", "396 Seventh Av."}, 72 {"Oslo", new Integer (42), "Robert Ott", "503 Seventh Av."}, 73 {"Paris", new Integer (25), "Sylvia Steel", "269 College Av."}, 74 {"Paris", new Integer (18), "Sylvia Fuller", "158 - 20th Ave."}, 75 {"Paris", new Integer (5), "Laura Miller", "294 Seventh Av."}, 76 {"San Francisco", new Integer (48), "Robert White", "549 Seventh Av."}, 77 {"San Francisco", new Integer (7), "James Peterson", "231 Upland Pl."} 78 }; 79 80 private int index = -1; 81 82 83 86 public WebappDataSource() 87 { 88 } 89 90 91 94 public boolean next() throws JRException 95 { 96 index++; 97 98 return (index < data.length); 99 } 100 101 102 105 public Object getFieldValue(JRField field) throws JRException 106 { 107 Object value = null; 108 109 String fieldName = field.getName(); 110 111 if ("City".equals(fieldName)) 112 { 113 value = data[index][0]; 114 } 115 else if ("Id".equals(fieldName)) 116 { 117 value = data[index][1]; 118 } 119 else if ("Name".equals(fieldName)) 120 { 121 value = data[index][2]; 122 } 123 else if ("Street".equals(fieldName)) 124 { 125 value = data[index][3]; 126 } 127 128 return value; 129 } 130 131 132 } 133 | Popular Tags |