KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > data > column > Column


1 package prefuse.data.column;
2
3 import java.util.Date JavaDoc;
4
5 import prefuse.data.DataTypeException;
6 import prefuse.data.event.ColumnListener;
7 import prefuse.data.parser.DataParser;
8
9
10 /**
11  * Interface for a data column in a table.
12  *
13  * @author <a HREF="http://jheer.org">jeffrey heer</a>
14  */

15 public interface Column {
16     
17     // ------------------------------------------------------------------------
18
// Column Metadata
19

20     /**
21      * Returns the number of rows in this data column
22      * @return the number of rows
23      */

24     public int getRowCount();
25     
26     /**
27      * Sets the number of rows in this data column
28      * @param nrows the number of rows
29      */

30     public void setMaximumRow(int nrows);
31     
32     /**
33      * Indicates if the values in this column are read-only.
34      * @return true if the values can not be edited, false otherwise
35      */

36     public boolean isReadOnly();
37     
38     /**
39      * Sets if the values in this column are read-only
40      * @param readOnly true to ensure the values can not be edited,
41      * false otherwise
42      */

43     public void setReadOnly(boolean readOnly);
44     
45     /**
46      * Indicates if the value at the given row can be edited.
47      * @param row the row to check
48      * @return true is the value can be modified, false otherwise
49      */

50     public boolean isCellEditable(int row);
51     
52     /**
53      * Returns the most specific superclass for the values in the column
54      * @return the Class of the column's data values
55      */

56     public Class JavaDoc getColumnType();
57     
58     /**
59      * Get the data parser used to map String values to and from the values
60      * stored by this Column.
61      * @return the DataParser used by this Column
62      */

63     public DataParser getParser();
64
65     /**
66      * Set the data parser used to map String values to and from the values
67      * stored by this Column.
68      * @param parser the DataParser to use
69      */

70     public void setParser(DataParser parser);
71     
72     // ------------------------------------------------------------------------
73
// Listener Methods
74

75     /**
76      * Adds a listener to be notified when this column changes
77      * @param listener the ColumnListener to add
78      */

79     public void addColumnListener(ColumnListener listener);
80
81     /**
82      * Removes a listener, causing it to no longer be notified of changes
83      * @param listener the ColumnListener to remove
84      */

85     public void removeColumnListener(ColumnListener listener);
86     
87     
88     // ------------------------------------------------------------------------
89
// Data Access Methods
90

91     /**
92      * Returns the default value for rows that have not been set explicitly.
93      */

94     public Object JavaDoc getDefaultValue();
95     
96     /**
97      * Reverts the specified row back to the column's default value.
98      * @param row
99      */

100     public void revertToDefault(int row);
101     
102     /**
103      * Indicates if the get method can be called without
104      * an exception being thrown for the given type.
105      * @param type the Class of the data type to check
106      * @return true if the type is supported by this column, false otherwise
107      */

108     public boolean canGet(Class JavaDoc type);
109     
110     /**
111      * Indicates if the set method can be called without
112      * an exception being thrown for the given type.
113      * @param type the Class of the data type to check
114      * @return true if the type is supported by this column, false otherwise
115      */

116     public boolean canSet(Class JavaDoc type);
117     
118     /**
119      * Get the data value at the specified row
120      * @param row the row from which to retrieve the value
121      * @return the data value
122      */

123     public Object JavaDoc get(int row);
124         
125     /**
126      * Set the data value at the specified row
127      * @param val the value to set
128      * @param row the row at which to set the value
129      */

130     public void set(Object JavaDoc val, int row) throws DataTypeException;
131     
132     
133     // ------------------------------------------------------------------------
134
// Data Type Convenience Methods
135

136     // because java's type system can be tedious at times...
137

138     // -- int -----------------------------------------------------------------
139

140     /**
141      * Indicates if convenience get method can be called without
142      * an exception being thrown for the int type.
143      * @return true if getInt is supported, false otherwise
144      */

145     public boolean canGetInt();
146     
147     /**
148      * Indicates if convenience set method can be called without
149      * an exception being thrown for the int type.
150      * @return true if setInt is supported, false otherwise
151      */

152     public boolean canSetInt();
153     
154     /**
155      * Get the data value at the specified row as an integer
156      * @param row the row from which to retrieve the value
157      * @return the data value as an integer
158      * @throws DataTypeException if this column does not
159      * support the integer type
160      */

161     public int getInt(int row) throws DataTypeException;
162     
163     /**
164      * Set the data value at the specified row as an integer
165      * @param val the value to set
166      * @param row the row at which to set the value
167      * @throws DataTypeException if this column does not
168      * support the integer type
169      */

170     public void setInt(int val, int row) throws DataTypeException;
171
172     // -- long ----------------------------------------------------------------
173

174     /**
175      * Indicates if convenience get method can be called without
176      * an exception being thrown for the long type.
177      * @return true if getLong is supported, false otherwise
178      */

179     public boolean canGetLong();
180     
181     /**
182      * Indicates if convenience set method can be called without
183      * an exception being thrown for the long type.
184      * @return true if setLong is supported, false otherwise
185      */

186     public boolean canSetLong();
187     
188     /**
189      * Get the data value at the specified row as a long
190      * @param row the row from which to retrieve the value
191      * @return the data value as a long
192      * @throws DataTypeException if this column does not
193      * support the long type
194      */

195     public long getLong(int row) throws DataTypeException;
196     
197     /**
198      * Set the data value at the specified row as a long
199      * @param val the value to set
200      * @param row the row at which to set the value
201      * @throws DataTypeException if this column does not
202      * support the long type
203      */

204     public void setLong(long val, int row) throws DataTypeException;
205     
206     // -- float ---------------------------------------------------------------
207

208     /**
209      * Indicates if convenience get method can be called without
210      * an exception being thrown for the float type.
211      * @return true if getFloat is supported, false otherwise
212      */

213     public boolean canGetFloat();
214     
215     /**
216      * Indicates if convenience set method can be called without
217      * an exception being thrown for the float type.
218      * @return true if setFloat is supported, false otherwise
219      */

220     public boolean canSetFloat();
221     
222     /**
223      * Get the data value at the specified row as a float
224      * @param row the row from which to retrieve the value
225      * @return the data value as a float
226      * @throws DataTypeException if this column does not
227      * support the float type
228      */

229     public float getFloat(int row) throws DataTypeException;
230     
231     /**
232      * Set the data value at the specified row as a float
233      * @param val the value to set
234      * @param row the row at which to set the value
235      * @throws DataTypeException if this column does not
236      * support the float type
237      */

238     public void setFloat(float val, int row) throws DataTypeException;
239     
240     // -- double --------------------------------------------------------------
241

242     /**
243      * Indicates if convenience get method can be called without
244      * an exception being thrown for the double type.
245      * @return true if getDouble is supported, false otherwise
246      */

247     public boolean canGetDouble();
248     
249     /**
250      * Indicates if convenience set method can be called without
251      * an exception being thrown for the double type.
252      * @return true if setDouble is supported, false otherwise
253      */

254     public boolean canSetDouble();
255     
256     /**
257      * Get the data value at the specified row as a double
258      * @param row the row from which to retrieve the value
259      * @return the data value as a double
260      * @throws DataTypeException if this column does not
261      * support the double type
262      */

263     public double getDouble(int row) throws DataTypeException;
264     
265     /**
266      * Set the data value at the specified row as a double
267      * @param val the value to set
268      * @param row the row at which to set the value
269      * @throws DataTypeException if this column does not
270      * support the double type
271      */

272     public void setDouble(double val, int row) throws DataTypeException;
273     
274     // -- boolean -------------------------------------------------------------
275

276     /**
277      * Indicates if convenience get method can be called without
278      * an exception being thrown for the boolean type.
279      * @return true if getBoolean is supported, false otherwise
280      */

281     public boolean canGetBoolean();
282     
283     /**
284      * Indicates if convenience set method can be called without
285      * an exception being thrown for the boolean type.
286      * @return true if setBoolean is supported, false otherwise
287      */

288     public boolean canSetBoolean();
289     
290     /**
291      * Get the data value at the specified row as a boolean
292      * @param row the row from which to retrieve the value
293      * @return the data value as a boolean
294      * @throws DataTypeException if this column does not
295      * support the boolean type
296      */

297     public boolean getBoolean(int row) throws DataTypeException;
298     
299     /**
300      * Set the data value at the specified row as a boolean
301      * @param val the value to set
302      * @param row the row at which to set the value
303      * @throws DataTypeException if this column does not
304      * support the boolean type
305      */

306     public void setBoolean(boolean val, int row) throws DataTypeException;
307     
308     // -- String --------------------------------------------------------------
309

310     /**
311      * Indicates if convenience get method can be called without
312      * an exception being thrown for the String type.
313      * @return true if getString is supported, false otherwise
314      */

315     public boolean canGetString();
316     
317     /**
318      * Indicates if convenience set method can be called without
319      * an exception being thrown for the String type.
320      * @return true if setString is supported, false otherwise
321      */

322     public boolean canSetString();
323     
324     /**
325      * Get the data value at the specified row as a String
326      * @param row the row from which to retrieve the value
327      * @return the data value as a String
328      * @throws DataTypeException if this column does not
329      * support the String type
330      */

331     public String JavaDoc getString(int row) throws DataTypeException;
332     
333     /**
334      * Set the data value at the specified row as a String
335      * @param val the value to set
336      * @param row the row at which to set the value
337      * @throws DataTypeException if this column does not
338      * support the String type
339      */

340     public void setString(String JavaDoc val, int row) throws DataTypeException;
341     
342     // -- Date ----------------------------------------------------------------
343

344     /**
345      * Indicates if convenience get method can be called without
346      * an exception being thrown for the Date type.
347      * @return true if getDate is supported, false otherwise
348      */

349     public boolean canGetDate();
350     
351     /**
352      * Indicates if convenience set method can be called without
353      * an exception being thrown for the Date type.
354      * @return true if setDate is supported, false otherwise
355      */

356     public boolean canSetDate();
357     
358     /**
359      * Get the data value at the specified row as a Date
360      * @param row the row from which to retrieve the value
361      * @return the data value as a Date
362      * @throws DataTypeException if this column does not
363      * support the Date type
364      */

365     public Date JavaDoc getDate(int row) throws DataTypeException;
366     
367     /**
368      * Set the data value at the specified row as a Date
369      * @param val the value to set
370      * @param row the row at which to set the value
371      * @throws DataTypeException if this column does not
372      * support the Date type
373      */

374     public void setDate(Date JavaDoc val, int row) throws DataTypeException;
375     
376 } // end of interface Column
377
Popular Tags