KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > crosstabs > fill > calculation > CrosstabCell


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.crosstabs.fill.calculation;
29
30 import net.sf.jasperreports.crosstabs.fill.calculation.MeasureDefinition.MeasureValue;
31
32 /**
33  * Crosstab cell produced by the crosstab bucketing engine.
34  *
35  * @author Lucian Chirita (lucianc@users.sourceforge.net)
36  * @version $Id: CrosstabCell.java 1229 2006-04-19 13:27:35 +0300 (Wed, 19 Apr 2006) teodord $
37  */

38 public class CrosstabCell
39 {
40     private final BucketDefinition.Bucket[] rowBucketValues;
41     private final int rowTotalGroupIndex;
42     private final BucketDefinition.Bucket[] columnBucketValues;
43     private final int columnTotalGroupIndex;
44     private final MeasureValue[] mesureValues;
45     private final MeasureValue[][][] totals;
46     
47     
48     /**
49      * Create a crosstab cell.
50      *
51      * @param rowBucketValues the row bucket values corresponding to the cell
52      * @param columnBucketValues the column bucket values corresponding to the cell
53      * @param mesureValues the measure values
54      * @param totals totals corresponding to the cell
55      */

56     public CrosstabCell(
57             BucketDefinition.Bucket[] rowBucketValues,
58             BucketDefinition.Bucket[] columnBucketValues,
59             MeasureValue[] mesureValues,
60             MeasureValue[][][] totals)
61     {
62         this.rowBucketValues = rowBucketValues;
63         rowTotalGroupIndex = getTotalIndex(rowBucketValues);
64         this.columnBucketValues = columnBucketValues;
65         columnTotalGroupIndex = getTotalIndex(columnBucketValues);
66         this.mesureValues = mesureValues;
67         this.totals = totals;
68     }
69
70     
71     private static int getTotalIndex(BucketDefinition.Bucket[] values)
72     {
73         int i = 0;
74         while (i < values.length && !values[i].isTotal())
75         {
76             ++i;
77         }
78         
79         return i;
80     }
81
82     
83     /**
84      * Returns the measure values for this cell.
85      *
86      * @return the measure values for this cell
87      */

88     public MeasureValue[] getMesureValues()
89     {
90         return mesureValues;
91     }
92
93
94     /**
95      * Returns the column bucket values corresponding to this cell.
96      *
97      * @return the column bucket values corresponding to this cell
98      */

99     public BucketDefinition.Bucket[] getColumnBucketValues()
100     {
101         return columnBucketValues;
102     }
103
104
105     /**
106      * Returns the row bucket values corresponding to this cell.
107      *
108      * @return the row bucket values corresponding to this cell
109      */

110     public BucketDefinition.Bucket[] getRowBucketValues()
111     {
112         return rowBucketValues;
113     }
114
115
116     /**
117      * Returns the index of the column total bucket this cell corresponds to.
118      * <p>
119      * If this cell corresponds to a column total bucket, this method returns the index of the
120      * bucket. Otherwise it returns the number of column buckets.
121      *
122      * @return the index of the column total bucket this cell corresponds to
123      */

124     public int getColumnTotalGroupIndex()
125     {
126         return columnTotalGroupIndex;
127     }
128
129
130     /**
131      * Returns the index of the row total bucket this cell corresponds to.
132      * <p>
133      * If this cell corresponds to a row total bucket, this method returns the index of the
134      * bucket. Otherwise it returns the number of row buckets.
135      *
136      * @return the index of the row total bucket this cell corresponds to
137      */

138     public int getRowTotalGroupIndex()
139     {
140         return rowTotalGroupIndex;
141     }
142     
143     
144     /**
145      * Returns measure totals corresponding to the cell.
146      *
147      * @return measure totals corresponding to the cell
148      */

149     public MeasureValue[][][] getTotals()
150     {
151         return totals;
152     }
153 }
154
Popular Tags