KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > contrib > table > model > ITableColumn


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.contrib.table.model;
16
17 import java.util.Comparator JavaDoc;
18
19 import org.apache.tapestry.IRender;
20 import org.apache.tapestry.IRequestCycle;
21
22 /**
23  * The interface defining a table column.
24  *
25  * A column is responsible for presenting a particular part of the data
26  * from the objects in the table. This is done via the getValueRender() method.
27  *
28  * A column may be sortable, in which case it defines the way in which the
29  * objects in the table must be sorted by providing a Comparator.
30  *
31  * @author mindbridge
32  */

33 public interface ITableColumn
34 {
35     /**
36      * Method getColumnName provides the name of the column.
37      *
38      * The column name must be unique and is generally used for the identification
39      * of the column. It does not have to be the same as the display name
40      * via which the column is identified to the user (see the getColumnRender() method).
41      * @return String the name of the column
42      */

43     String JavaDoc getColumnName();
44
45     /**
46      * Method getSortable declares whether the column allows sorting.
47      * If the column allows sorting, it must also return a valid Comparator
48      * via the getComparator() method.
49      * @return boolean whether the column is sortable or not
50      */

51     boolean getSortable();
52
53     /**
54      * Method getComparator returns the Comparator to be used to sort
55      * the data in the table according to this column. The Comparator must
56      * accept two different rows, compare them according to this column,
57      * and return the appropriate value.
58      * @return Comparator the Comparator used to sort the table data
59      */

60     Comparator JavaDoc getComparator();
61
62     /**
63      * Method getColumnRenderer provides a renderer that takes care of rendering
64      * the column in the table header. If the column is sortable, the renderer
65      * may provide a mechanism to sort the table in an ascending or descending
66      * manner.
67      * @param objCycle the current request cycle
68      * @param objSource a component that can provide the table model (typically TableView)
69      * @return IRender the renderer to present the column header
70      */

71     IRender getColumnRenderer(
72         IRequestCycle objCycle,
73         ITableModelSource objSource);
74
75     /**
76      * Method getValueRenderer provides a renderer for presenting the value of a
77      * particular row in the current column.
78      *
79      * @param objCycle the current request cycle
80      * @param objSource a component that can provide the table model (typically TableView)
81      * @param objRow the row data
82      * @return IRender the renderer to present the value of the row in this column
83      */

84     IRender getValueRenderer(
85         IRequestCycle objCycle,
86         ITableModelSource objSource,
87         Object JavaDoc objRow);
88 }
89
Popular Tags