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

Quick Search    Search Deep

Source code: jbreport/core/TableColumn.java


1   /*
2    * $Id: TableColumn.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 org.xml.sax.Attributes;
24  
25  import jbreport.ReportElement;
26  import jbreport.ReportException;
27  
28  /**
29   * This is used to contain the information about the column headers in a table.
30   *
31   * @author Grant Finnemore
32   * @version $Revision: 1.1 $
33   */
34  class TableColumn extends ReportCompositeImpl {
35  
36     /** The name of the column that this instance represents */
37     private String id;
38  
39     //
40     // Constructors
41     //
42  
43     public TableColumn() {
44        elementType = "column";
45     }
46  
47     //
48     // Methods overloaded from AbstractReportElement
49     //
50  
51     public void accept(ReportVisitor visitor, ReportVisitorState state) 
52        throws ReportException {
53        visitor.visitTableHeaderItem(this, state);
54     }
55  
56     public String getString(String property, String defaultValue) 
57        throws ReportException {
58        
59        String result = defaultValue;
60        if("id".equals(property)) {
61           result = id;
62        }
63        else {
64           result = super.getString(property, defaultValue);
65        }
66        return result;
67     }
68  
69     public void setString(String property, String value) 
70        throws ReportException {
71  
72        assertNotNull(value, "value");
73        if("id".equals(property)) {
74           id = value;
75        }
76        else {
77           super.setString(property, value);
78        }
79     }
80  
81     public void xmlInitialize(String localName, Attributes attributes)
82        throws ReportException {
83        
84        super.xmlInitialize(localName, attributes);
85        id = attributes.getValue("id");
86        assertNotNull(id, id);
87     }
88  
89     public void xmlEndChild(ReportElement elem) throws ReportException {
90        if("aggregate".equals(elem.getType())) {
91           // I'm not sure that we should extend the ReportCompositeImpl class
92           // to just provide for the aggregates, but it is the easiest for the 
93           // moment.
94           addElement(elem);
95        }
96        else {
97           super.xmlEndChild(elem);
98        }
99     }
100 }