/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.io.PrintStream
 *  java.lang.Class
 *  java.lang.Exception
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.StringBuffer
 *  java.lang.System
 *  java.util.List
 *  javax.swing.table.AbstractTableModel
 */
package org.dom4j.swing;

import java.io.PrintStream;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.XPath;
import org.dom4j.swing.XMLTableDefinition;

public class XMLTableModel
extends AbstractTableModel {
    private XMLTableDefinition definition;
    private List rows;
    private Object source;

    public XMLTableModel(Document document, Object object) {
        super(XMLTableDefinition.load(document), object);
    }

    public XMLTableModel(Element element, Object object) {
        super(XMLTableDefinition.load(element), object);
    }

    public XMLTableModel(XMLTableDefinition xMLTableDefinition, Object object) {
        this.definition = xMLTableDefinition;
        this.source = object;
    }

    public Class getColumnClass(int n) {
        return this.definition.getColumnClass(n);
    }

    public int getColumnCount() {
        return this.definition.getColumnCount();
    }

    public String getColumnName(int n) {
        XPath xPath = this.definition.getColumnNameXPath(n);
        if (xPath != null) {
            System.out.println(new StringBuffer().append("Evaluating column xpath: ").append((Object)xPath).append(" value: ").append(xPath.valueOf(this.source)).toString());
            return xPath.valueOf(this.source);
        }
        return this.definition.getColumnName(n);
    }

    public XMLTableDefinition getDefinition() {
        return this.definition;
    }

    public int getRowCount() {
        return this.getRows().size();
    }

    public Object getRowValue(int n) {
        return this.getRows().get(n);
    }

    public List getRows() {
        if (this.rows == null) {
            this.rows = this.definition.getRowXPath().selectNodes(this.source);
        }
        return this.rows;
    }

    public Object getSource() {
        return this.source;
    }

    public Object getValueAt(int n, int n2) {
        try {
            Object object = this.getRowValue(n);
            Object object2 = this.definition.getValueAt(object, n2);
            return object2;
        }
        catch (Exception var3_5) {
            this.handleException(var3_5);
            return null;
        }
    }

    protected void handleException(Exception exception) {
        System.out.println(new StringBuffer().append("Caught: ").append((Object)exception).toString());
    }

    public void setDefinition(XMLTableDefinition xMLTableDefinition) {
        this.definition = xMLTableDefinition;
    }

    public void setSource(Object object) {
        this.source = object;
        this.rows = null;
    }
}

