/**
 * TabelaPosicoes.java
 *
 * @author Wanderson C. Bragança <wanderson.wbc@gmail.com>
 * @link http://www.wanderson.wordpress.com
 * @copyright Copyright © 2009
 * @version  14/04/2009
 */

import javax.swing.table.*;
import java.util.Vector;

import jade.core.Location;

public class TabelaPosicoes extends AbstractTableModel {
    Vector names;
    Location container;
    // CONSTRUTOR
    public TabelaPosicoes() {
        super();
        names = new Vector();
    }
    
    // ADD
    public void add(Location loc) {
        names.add((Object) loc);
    }
    
    // PEGA O ELEMENTO EM
    public Location getElementAt(int index) {
        return((Location) names.get(index));
    }
    
    // CLEAR
    public void clear() {
        names.clear();
    }
    
    // M�todos a ser executados para ter uma classe concreta
    public int getRowCount() {
        return(names.size());
    }
    
    public int getColumnCount() {
        return(4);
    }
   
    public Object getValueAt(int row, int column) {
        String id, name, protocol, address;
        String value = new String();
        Location loc = (Location) names.get(row);
        
        switch(column) {
            case 0:
                value = loc.getID();
                
                break;
            case 1:
                value = loc.getName();
                break;
            case 2:
                value = loc.getProtocol();
                break;
            case 3:
                value = loc.getAddress();
                break;
                
        }
        return ((Object) value);
    }
}
