Package jtrackbase.gui.table

Source Code of jtrackbase.gui.table.ArtistTableModel

/* License see bottom */
package jtrackbase.gui.table;

import java.util.Collection;

import jtrackbase.db.Artist;

public class ArtistTableModel extends EntityTableModel<Artist> {
  public ArtistTableModel() {
    super();
  }
 
  public ArtistTableModel(Collection<Artist> coll) {
    super(coll);
  }
 
  @Override
  public Class<?> getColumnClass(int columnIndex) {
    switch (columnIndex) {
    case 0:{
      return Integer.TYPE;
    }
    case 1: {
      return String.class;
    }
    default: {
      throw new IllegalArgumentException("column count exceeded: "+columnIndex);
    }
    }
  }

  @Override
  public int getColumnCount() {
    return 2;
  }

  @Override
  public String getColumnName(int columnIndex) {
    switch (columnIndex) {
    case 0:{
      return "Id";
    }
    case 1: {
      return "Name";
    }
    default: {
      throw new IllegalArgumentException("column count exceeded: "+columnIndex);
    }
    }
  }

  @Override
  public Object getValueAt(int rowIndex, int columnIndex) {
    Artist a=get(rowIndex);
    if (a==null) {
      return null;
    }
    switch (columnIndex) {
    case 0:{
      return a.getId();
    }
    case 1:{
      return a.getName();
    }
    }
    return null;
  }
}
/*
Copyright (C) 2008  Onkobu Tanaake

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program (gplv3.txt).
*/
TOP

Related Classes of jtrackbase.gui.table.ArtistTableModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.