Index: /Users/jcarnell/groovy_projects/groovy/src/main/groovy/sql/DataSet.java =================================================================== --- /Users/jcarnell/groovy_projects/groovy/src/main/groovy/sql/DataSet.java (revision 5718) +++ /Users/jcarnell/groovy_projects/groovy/src/main/groovy/sql/DataSet.java (working copy) @@ -50,9 +50,13 @@ import java.sql.Connection; import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; import java.sql.SQLException; + import java.util.ArrayList; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; @@ -92,6 +96,7 @@ this.table = table; } + public DataSet(DataSet parent, Closure where) { super(parent); this.table = parent.table; @@ -99,6 +104,7 @@ this.where = where; } + public void add(Map values) throws SQLException { StringBuffer buffer = new StringBuffer("insert into "); buffer.append(table); @@ -210,4 +216,28 @@ public DataSet createView(Closure criteria) { return new DataSet(this, criteria); } + + /** + * Returns a List of all of the rows from the table a DataSet + * represents + * @return Returns a list of GroovyRowResult objects. + * @throws SQLException + */ + public List rows() throws SQLException { + String sql = "SELECT * FROM " + table; + return rows(sql); + + } + + /** + * Returns the first row from a DataSet's underying table + * + * @return + * @throws SQLException + */ + public Object firstRow() throws SQLException{ + List rows = rows(); + if (rows.isEmpty()) return null; + return(rows.get(0)); + } }