package data.swing; import data.*; import util.swing.*; /** * A {@link TableEntryDescriptor} that can be used with a {@link DataBasketTableModel} modelling * {@link DataBasketEntry DataBasketEntries} that describe operations on items in a {@link CountingStock}. * * <p>There will be two columns, headed "Name" and "Count". The first will give the item's * name, the second the number of items of that sort available.</p> * * @author Steffen Zschaler * @version 2.0 23/08/1999 * @since v2.0 */ public class DefaultCountingStockDBETableEntryDescriptor extends AbstractTableEntryDescriptor { /** * Create a new DefaultCountingStockDBETableEntryDescriptor. */ public DefaultCountingStockDBETableEntryDescriptor() { super(); } /** * @return 2. * @override Sometimes */ public int getColumnCount() { return 2; } /** * @return "Name" for the first and "Count" for the second column. * @override Sometimes */ public String getColumnName (int nIdx) { String[] asNames = {"Name", "Count"}; return asNames[nIdx]; } /** * @return <code>String.class</code> for the first and <code>Integer.class</code> for the second column. * @override Sometimes */ public Class getColumnClass (int nIdx) { Class[] acClasses = {String.class, Integer.class}; return acClasses[nIdx]; } /** * @return the item's name for the first and the number of available items for the second column. * @override Sometimes */ public Object getValueAt (Object oData, int nIdx) { DataBasketEntry dbe = (DataBasketEntry) oData; switch (nIdx) { case 0: return dbe.getSecondaryKey(); case 1: return dbe.getValue(); } return null; } }