// Decompiled by Jad v1.5.7. Copyright 1997-99 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   StringTableModel.java

package com.symantec.itools.javax.swing.models;

import java.io.Serializable;
import java.util.*;
import javax.swing.table.AbstractTableModel;

public class StringTableModel extends AbstractTableModel
    implements Serializable
{

    public int getRowCount()
    {
        return dataVector.size();
    }

    public int getColumnCount()
    {
        return colCount;
    }

    public String getColumnName(int i)
    {
        return (String)headerVector.elementAt(i);
    }

    public Class getColumnClass(int i)
    {
        if(class$java$lang$String != null)
            return class$java$lang$String;
        else
            return class$java$lang$String = class$("java.lang.String");
    }

    public Object getValueAt(int i, int j)
    {
        return (String)((Vector)dataVector.elementAt(i)).elementAt(j);
    }

    public void setValueAt(Object obj, int i, int j)
    {
        ((Vector)dataVector.elementAt(i)).setElementAt(obj, j);
        ((Vector)editableVector.elementAt(i)).setElementAt(Boolean.TRUE, j);
        fireTableCellUpdated(i, j);
    }

    public void setCellEditable(int i, int j, boolean flag)
    {
        Vector vector = (Vector)editableVector.elementAt(i);
        vector.setElementAt(new Boolean(flag), j);
    }

    public boolean isCellEditable(int i, int j)
    {
        if(!editable)
        {
            return false;
        }
        else
        {
            Vector vector = (Vector)editableVector.elementAt(i);
            return ((Boolean)vector.elementAt(j)).booleanValue();
        }
    }

    public String[] getItems()
    {
        return getItems(',');
    }

    public String[] getItems(char c)
    {
        int i = dataVector.size();
        String as[] = new String[i];
        for(int j = 0; j < i; j++)
        {
            StringBuffer stringbuffer = new StringBuffer();
            for(int k = 0; k < colCount; k++)
            {
                stringbuffer.append(((Vector)dataVector.elementAt(j)).elementAt(k));
                stringbuffer.append(c);
            }

            stringbuffer.setLength(stringbuffer.length() - 1);
            as[j] = stringbuffer.toString();
        }

        return as;
    }

    public void setItems(String as[])
    {
        setItems(as, ",");
    }

    public void setItems(String as[], String s)
    {
        colCount = 0;
        dataVector.setSize(0);
        for(int j = 0; j < as.length; j++)
            setItemAt(as[j], j, false, s);

        int i = dataVector.size();
        for(int k = 0; k < i; k++)
        {
            int l = ((Vector)dataVector.elementAt(k)).size();
            if(l < colCount)
            {
                int i1 = colCount - l;
                for(int j1 = 0; j1 < i1; j1++)
                    ((Vector)dataVector.elementAt(k)).addElement("");

            }
        }

        fireTableStructureChanged();
    }

    public void setItemAt(String s, int i, boolean flag)
    {
        setItemAt(s, i, flag, ",");
    }

    public void setItemAt(String s, int i, boolean flag, String s1)
    {
        dataVector.insertElementAt(new Vector(), i);
        editableVector.insertElementAt(new Vector(), i);
        StringTokenizer stringtokenizer = new StringTokenizer(s, s1);
        colCount = Math.max(colCount, stringtokenizer.countTokens());
        while(stringtokenizer.hasMoreTokens()) 
        {
            String s2 = stringtokenizer.nextToken();
            ((Vector)dataVector.elementAt(i)).addElement(s2);
            ((Vector)editableVector.elementAt(i)).addElement(Boolean.TRUE);
            int j = ((Vector)dataVector.elementAt(i)).size();
            if(j > headerVector.size())
                headerVector.addElement(" ");
        }

        if(flag)
            fireTableDataChanged();
    }

    public String getColumnHeaders()
    {
        return getColumnHeaders(',');
    }

    public String getColumnHeaders(char c)
    {
        StringBuffer stringbuffer = new StringBuffer();
        for(int i = 0; i < colCount; i++)
        {
            stringbuffer.append((String)headerVector.elementAt(i));
            stringbuffer.append(c);
        }

        if(stringbuffer.length() > 0)
            stringbuffer.setLength(stringbuffer.length() - 1);
        return stringbuffer.toString();
    }

    public void setColumnHeaders(String s)
    {
        setColumnHeaders(s, ",");
    }

    public void setColumnHeaders(String s, String s1)
    {
        headerVector = new Vector();
        StringTokenizer stringtokenizer = new StringTokenizer(s, s1);
        int i = stringtokenizer.countTokens();
        for(int j = 0; j < Math.max(i, colCount); j++)
            if(stringtokenizer.hasMoreTokens())
                headerVector.addElement(stringtokenizer.nextToken());
            else
                headerVector.addElement(" ");

        fireTableStructureChanged();
        fireTableDataChanged();
    }

    public boolean isEditable()
    {
        return editable;
    }

    public void setEditable(boolean flag)
    {
        editable = flag;
    }

    public String getRow(int i)
    {
        return getRow(i, ',');
    }

    public String getRow(int i, char c)
    {
        StringBuffer stringbuffer = new StringBuffer();
        for(Enumeration enumeration = elements(i); enumeration.hasMoreElements(); stringbuffer.append(c))
            stringbuffer.append((String)enumeration.nextElement());

        stringbuffer.setLength(stringbuffer.length() - 1);
        return stringbuffer.toString();
    }

    public void addRow(String s)
    {
        insertRowAt(s, dataVector.size());
    }

    public void insertRowAt(String s, int i)
    {
        setItemAt(s, i, false);
        fireTableRowsInserted(i, i);
    }

    public void removeRow(int i)
    {
        dataVector.removeElementAt(i);
        fireTableRowsDeleted(i, i);
    }

    public int getNumRows()
    {
        return dataVector.size();
    }

    public Object getElementAt(int i, int j)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.elementAt(j);
    }

    public void copyInto(Object aobj[][])
    {
        for(int i = 0; i < aobj.length; i++)
        {
            for(int j = 0; j < aobj[i].length; j++)
                aobj[i][j] = elementAt(i, j);

        }

    }

    public void trimToSize(int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        vector.trimToSize();
    }

    public void ensureCapacity(int i, int j)
    {
        Vector vector = (Vector)dataVector.elementAt(j);
        vector.ensureCapacity(i);
    }

    public void setSize(int i, int j)
    {
        Vector vector = (Vector)dataVector.elementAt(j);
        int k = vector.size();
        vector.setSize(i);
        if(k != i)
            fireTableRowsUpdated(j, j);
    }

    public int capacity(int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.capacity();
    }

    public int size()
    {
        return dataVector.size();
    }

    public int size(int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.size();
    }

    public boolean isEmpty(int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.isEmpty();
    }

    public Enumeration elements(int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.elements();
    }

    public boolean rowContains(Object obj, int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.contains(obj);
    }

    public boolean columnContains(Object obj, int i)
    {
        int j = size();
        for(int k = 0; k < j; k++)
            if(((Vector)dataVector.elementAt(k)).elementAt(i).equals(obj))
                return true;

        return false;
    }

    public int indexOf(Object obj, int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.indexOf(obj);
    }

    public int indexOf(Object obj, int i, int j)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.indexOf(obj, j);
    }

    public int lastIndexOf(Object obj, int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.lastIndexOf(obj);
    }

    public int lastIndexOf(Object obj, int i, int j)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.lastIndexOf(obj, j);
    }

    public Object elementAt(int i, int j)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.elementAt(j);
    }

    public Object firstElement(int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.firstElement();
    }

    public Object lastElement(int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        return vector.lastElement();
    }

    public void setElementAt(Object obj, int i, int j)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        vector.setElementAt(obj, j);
        fireTableRowsUpdated(i, i);
    }

    public void removeElementAt(int i, int j)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        vector.removeElementAt(j);
        fireTableRowsUpdated(i, i);
    }

    public void insertElementAt(Object obj, int i, int j)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        vector.insertElementAt(obj, j);
        fireTableRowsUpdated(i, i);
    }

    public void addElement(Object obj, int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        vector.addElement(obj);
        fireTableRowsUpdated(i, i);
    }

    public boolean removeElement(Object obj, int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        boolean flag = vector.removeElement(obj);
        if(flag)
            fireTableRowsUpdated(i, i);
        return flag;
    }

    public void removeAllElements(int i)
    {
        Vector vector = (Vector)dataVector.elementAt(i);
        vector.removeAllElements();
        fireTableRowsUpdated(i, i);
    }

    public StringTableModel()
    {
        dataVector = new Vector();
        editableVector = new Vector();
        headerVector = new Vector();
        editable = false;
    }

    static Class class$(String s)
    {
        try
        {
            return Class.forName(s);
        }
        catch(ClassNotFoundException classnotfoundexception)
        {
            throw new NoClassDefFoundError(classnotfoundexception.getMessage());
        }
    }

    protected int colCount;
    protected Vector dataVector;
    protected Vector editableVector;
    protected Vector headerVector;
    protected boolean editable;
    static Class class$java$lang$String; /* synthetic field */
}
