Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/ResultData.java @ 998:b81626b10cb7
Datacage: Moved templating in a better suited package.
flys-artifacts/trunk@2434 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 01 Aug 2011 08:31:09 +0000 |
parents | |
children | 5cb84ceee2a0 |
comparison
equal
deleted
inserted
replaced
997:4c82609824c8 | 998:b81626b10cb7 |
---|---|
1 package de.intevation.flys.artifacts.datacage.templating; | |
2 | |
3 import java.io.Serializable; | |
4 | |
5 import java.sql.ResultSetMetaData; | |
6 import java.sql.ResultSet; | |
7 import java.sql.SQLException; | |
8 | |
9 import java.util.List; | |
10 import java.util.ArrayList; | |
11 | |
12 public class ResultData | |
13 implements Serializable | |
14 { | |
15 protected String [] columns; | |
16 | |
17 protected List<Object []> rows; | |
18 | |
19 public ResultData() { | |
20 rows = new ArrayList<Object []>(); | |
21 } | |
22 | |
23 public ResultData(ResultSetMetaData meta) | |
24 throws SQLException | |
25 { | |
26 this(); | |
27 | |
28 int N = meta.getColumnCount(); | |
29 | |
30 columns = new String[N]; | |
31 | |
32 for (int i = 1; i <= N; ++i) { | |
33 columns[i-1] = meta.getColumnLabel(i); | |
34 } | |
35 } | |
36 | |
37 public String [] getColumnLabels() { | |
38 return columns; | |
39 } | |
40 | |
41 public ResultData addAll(ResultSet result) throws SQLException { | |
42 while (result.next()) { | |
43 add(result); | |
44 } | |
45 return this; | |
46 } | |
47 | |
48 public void add(ResultSet result) throws SQLException { | |
49 Object [] row = new Object[columns.length]; | |
50 for (int i = 0; i < columns.length; ++i) { | |
51 row[i] = result.getObject(i+1); | |
52 } | |
53 rows.add(row); | |
54 } | |
55 | |
56 public List<Object []> getRows() { | |
57 return rows; | |
58 } | |
59 } | |
60 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |