001 package com.sptci.rwt;
002 import java.io.Serializable;
003
004 import java.util.ArrayList;
005 import java.util.Collections;
006 import java.util.List;
007
008 /**
009 * A simple value object that represents a {@link java.sql.ResultSet}.
010 *
011 * <p>© Copyright 2007 <a href='http://sptci.com/' target='_new'>Sans Pareil Technologies, Inc.</a></p>
012 * @author Rakesh Vidyadharan 2007-10-02
013 * @version $Id: Rows.java 4123 2008-05-25 21:49:01Z rakesh $
014 */
015 public class Rows implements Serializable
016 {
017 /**
018 * The total number of rows available in the {@link java.sql.ResultSet}
019 * out of which this object was generated. Note that the {@link
020 * #rows} collection will usually not contain the same number (usually
021 * less) of rows as the total number available.
022 *
023 * @since Version 1.2
024 */
025 private int totalRows;
026
027 /** The collection of {@link Row} instances contained in result set. */
028 private List<Row> rows = new ArrayList<Row>();
029
030 /**
031 * Returns {@link #totalRows}.
032 *
033 * @since Version 1.2
034 * @return The value/reference of/to totalRows.
035 */
036 public int getTotalRows()
037 {
038 return totalRows;
039 }
040
041 /**
042 * Set {@link #totalRows}.
043 *
044 * @since Version 1.2
045 * @param totalRows The value to set.
046 */
047 protected void setTotalRows( final int totalRows )
048 {
049 this.totalRows = totalRows;
050 }
051
052 /**
053 * Returns {@link #rows}.
054 *
055 * @return The value/reference of/to rows.
056 */
057 public List<Row> getRows()
058 {
059 return Collections.unmodifiableList( rows );
060 }
061
062 /**
063 * Set {@link #rows}.
064 *
065 * @param rows The value to set.
066 */
067 protected void setRows( final List<Row> rows )
068 {
069 this.rows.clear();
070 this.rows.addAll( rows );
071 }
072
073 /**
074 * Add the specified row to {@link #rows} collection.
075 *
076 * @param row The row to be added.
077 */
078 protected void addRow( final Row row )
079 {
080 rows.add( row );
081 }
082 }