001/* ----------------------------------------------------------------------------
002   The Kiwi Toolkit - A Java Class Library
003   Copyright (C) 1998-2004 Mark A. Lindner
004
005   This library is free software; you can redistribute it and/or
006   modify it under the terms of the GNU General Public License as
007   published by the Free Software Foundation; either version 2 of the
008   License, or (at your option) any later version.
009
010   This library is distributed in the hope that it will be useful,
011   but WITHOUT ANY WARRANTY; without even the implied warranty of
012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013   General Public License for more details.
014
015   You should have received a copy of the GNU General Public License
016   along with this library; if not, write to the Free Software
017   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
018   02111-1307, USA.
019 
020   The author may be contacted at: mark_a_lindner@yahoo.com
021   ----------------------------------------------------------------------------
022   $Log: DomainObjectFieldAdapter.java,v $
023   Revision 1.9  2004/05/05 21:37:04  markl
024   comment block updates
025
026   Revision 1.8  2003/02/06 07:43:23  markl
027   fixed javadoc typo
028
029   Revision 1.7  2003/01/19 09:35:41  markl
030   Javadoc & comment header updates.
031
032   Revision 1.6  2001/03/12 05:58:46  markl
033   Javadoc cleanup.
034
035   Revision 1.5  2001/03/12 01:17:30  markl
036   Source code cleanup.
037
038   Revision 1.4  1999/08/13 07:11:57  markl
039   Added support for column widths.
040
041   Revision 1.3  1999/07/25 13:39:10  markl
042   Minor fixes.
043
044   Revision 1.2  1999/07/16 07:13:25  markl
045   DomainObjectFieldAdapter
046
047   Revision 1.1  1999/06/28 09:37:47  markl
048   Initial revision
049
050   Revision 1.3  1999/04/19 05:30:29  markl
051   Added getName()/setName() methods.
052
053   Revision 1.2  1999/01/10 01:00:58  markl
054   added GPL header & RCS tag
055   ----------------------------------------------------------------------------
056*/
057
058package kiwi.db;
059
060import javax.swing.table.*;
061
062/** An interface that describes an adapter for accessing fields in a domain
063 * object. Consider a domain object as an array of fields which map to
064 * corresponding columns in a table (specifically, a <code>JTable</code>).
065 * In order to display a domain object as a row in such a table, data
066 * members of the domain object must be mapped to cardinal fields. This adapter
067 * provides the interface to accomplish this.
068 *
069 * @author Mark Lindner
070 *
071 * @see javax.swing.JTable
072 */
073
074public interface DomainObjectFieldAdapter
075  {
076  /** Get the field count.
077   *
078   * @return The number of fields in the domain object.
079   */
080  
081  public int getFieldCount();
082
083  /** Get the name of a field. The name may be used for display purposes, such
084   * as in a table column header.
085   *
086   * @param field The field number.
087   * @return The name of the field.
088   */
089  
090  public String getFieldName(int field);
091
092  /** Get a field value.
093   *
094   * @param object The domain object for which a field value is being
095   * requested.
096   * @param field The field number.
097   * @return The value of the field.
098   */
099
100  public Object getField(DomainObject object, int field);
101
102  /** Set a field value.
103   *
104   * @param object The domain object for which a field value is being set.
105   * @param field The field number.
106   * @param value The new value for the field.
107   * @exception kiwi.db.MutatorException If the value could not be set.
108   */
109  
110  public void setField(DomainObject object, int field, Object value)
111    throws MutatorException;
112
113  /** Get a cell renderer that is appropriate for rendering a given field.
114   *
115   * @param field The field number.
116   * @return A <code>TableCellRenderer</code> that can be used to render the
117   * value of this field.
118   */  
119
120  public TableCellRenderer getCellRenderer(int field);
121
122  /** Get a cell editor that is appropriate for editing a given field.
123   *
124   * @param field The field number.
125   * @return A <code>TableCellEditor</code> that can be used to edit the
126   * value of this field.
127   */  
128  
129  public TableCellEditor getCellEditor(int field);
130
131  /** Determine if the given field is editable.
132   *
133   * @param field The field number.
134   * @return <code>true</code> if the field can be edited by external means
135   * (such as through a table control), and <code>false</code> if it is
136   * immutable (display-only).
137   */
138  
139  public boolean isFieldEditable(int field);
140
141  /** Determine the type of a given field.
142   *
143   * @param field The field number.
144   * @return The type of the field.
145   */
146  
147  public Class getFieldClass(int field);
148
149  /** Get the preferered column width for this field. This value is used by
150   * the <code>JTable</code> or similar component to determine column sizing
151   * for the data model that uses this adapter.
152   *
153   * @param field The field number.
154   * @return The preferred width for the field, or 0 if there is no preferred
155   * width.
156   */
157  
158  public int getFieldPreferredWidth(int field);
159
160  /** Get the minimum column width for this field. This value is used by
161   * the <code>JTable</code> or similar component to determine column sizing
162   * for the data model that uses this adapter.
163   *
164   * @param field The field number.
165   * @return The minimum width for the field, or 0 if there is no minimum
166   * width.
167   */  
168  
169  public int getFieldMinWidth(int field);
170
171  /** Get the maximum column width for this field. This value is used by
172   * the <code>JTable</code> or similar component to determine column sizing
173   * for the data model that uses this adapter.
174   *
175   * @param field The field number.
176   * @return The maximum width for the field, or 0 if there is no minimum
177   * width.
178   */
179  
180  public int getFieldMaxWidth(int field);
181  }
182
183/* end of source file */