Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jbreport/core/TableRow.java


1   /*
2    * $Id: TableRow.java,v 1.1 2000/08/31 13:53:17 grantfin Exp $
3    *
4    * jbReport - A reporting library for Java
5    * Copyright (C) 2000 Grant Finnemore <grantfin@users.sourceforge.net>
6    *
7    * This library is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU Lesser General Public
9    * License as published by the Free Software Foundation; either
10   * version 2 of the License, or (at your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this library; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   */
21  package jbreport.core;
22  
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import jbreport.Constants;
28  import jbreport.ReportElement;
29  import jbreport.ReportException;
30  import jbreport.data.QueryResult;
31  
32  /**
33   * This contains all the data relating to a single row in the table. The number
34   * of columns obtained from the table.
35   *
36   * @author Grant Finnemore
37   * @version $Revision: 1.1 $
38   */
39  class TableRow extends AbstractReportElement {
40  
41     /** The string values of the table row elements */
42     private List cells;
43  
44     //
45     // Constructors
46     //
47  
48     public TableRow() {
49        elementType = "row";
50     }
51  
52     //
53     // Methods overloaded from AbstractReportElement
54     //
55  
56     public void accept(ReportVisitor visitor, ReportVisitorState state) 
57        throws ReportException {
58        visitor.visitTableRow(this, state);
59     }
60  
61     public List getList(String property) {
62        List result = null;
63        if(Constants.RE_TABLE_CELLS.equals(property)) {
64           result = (cells != null ? cells : Collections.EMPTY_LIST);
65        }
66        else {
67           result = super.getList(property);
68        }
69        return result;
70     }
71  
72     public void updateData(QueryResult queryResult) throws ReportException {
73        // Get the columns from the parent
74        ReportElement elem = 
75           getParent().getElement(Constants.RE_TABLE_HEADER_ROW);
76        List columns = elem.getList(Constants.RE_CHILDREN);
77        // Use these for the acquisition of cell data
78        for(int i = 0; i < columns.size(); i++) {
79           String id = ((ReportElement)columns.get(i)).getString("id", null);
80           addCellData(queryResult.getString(id));
81        }
82     }
83  
84     public void addCellData(String data) {
85        if(cells == null) {
86           cells = new ArrayList();
87        }
88        cells.add(data);
89     }
90  }
91  
92  
93  
94  
95  
96  
97  
98  
99  
100 
101