com.itemanalysis.jmetrik.data.DataTableName.java Source code

Java tutorial

Introduction

Here is the source code for com.itemanalysis.jmetrik.data.DataTableName.java

Source

/*
 * Copyright (c) 2014 Patrick Meyer
 *
 * 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.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.itemanalysis.jmetrik.data;

import org.apache.commons.io.FilenameUtils;

import java.io.File;

public class DataTableName {

    private File dataFile = null;

    private DataTableName(String tableName, String path) {
        dataFile = new File(path + "/" + tableName);
    }

    private DataTableName(File dataFile) {
        this.dataFile = dataFile;
    }

    public String getAbsolutePath() {
        return dataFile.getAbsolutePath();
    }

    public File getDataFile() {
        return dataFile;
    }

    @Override
    public String toString() {
        return FilenameUtils.removeExtension(dataFile.getName());
    }

    @Override
    public boolean equals(Object o) {
        return (o instanceof DataTableName) && (this.compareTo((DataTableName) o) == 0);
    }

    @Override
    public int hashCode() {
        return dataFile.getAbsolutePath().hashCode();
    }

    public int compareTo(DataTableName o) {
        return dataFile.getAbsolutePath().compareTo(o.getAbsolutePath());
    }

}