001    package data.swing;
002    
003    import data.*;
004    
005    import util.swing.*;
006    
007    /**
008     * A {@link TableEntryDescriptor} that can be used with a {@link CatalogTableModel}.
009     *
010     * <p>There will be two columns headed &quot;Name&quot; and &quot;Value&quot;. The first will display the
011     * CatalogItems' names, the second their values.</p>
012     *
013     * @author Steffen Zschaler
014     * @version 2.0 23/08/1999
015     * @since v2.0
016     */
017    public class DefaultCatalogItemTED extends AbstractTableEntryDescriptor {
018    
019        /**
020             * ID for serialization.
021             */
022            private static final long serialVersionUID = -301307331065480096L;
023    
024            /**
025         * Create a new DefaultCatalogItemTED.
026         */
027        public DefaultCatalogItemTED() {
028            super();
029        }
030    
031        /**
032         * @return 2.
033         * @override Sometimes
034         */
035        public int getColumnCount() {
036            return 2;
037        }
038    
039        /**
040         * @return &quot;Name&quot; for the first, &quot;Value&quot; for the second column.
041         * @override Sometimes
042         */
043        public String getColumnName(int nIdx) {
044            String[] asNames = {
045                    "Name", "Value"};
046            return asNames[nIdx];
047        }
048    
049        /**
050         * @return <code>String.class</code> for the first, <code>{@link Value}.class</code> for the second column.
051         * @override Sometimes
052         */
053        public Class<?> getColumnClass(int nIdx) {
054            Class[] acClasses = {
055                    String.class, Value.class};
056            return acClasses[nIdx];
057        }
058    
059        /**
060         * @return the CatalogItem's name for the first, its value for the second column.
061         * @override Sometimes
062         */
063        public Object getValueAt(Object oData, int nIdx) {
064            if (nIdx == 0) {
065                return ((CatalogItem)oData).getName();
066            } else {
067                return ((CatalogItem)oData).getValue();
068            }
069        }
070    }