All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.publicobject.filebrowser.Entry Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
/* Glazed Lists                                                 (c) 2003-2006 */
/* http://publicobject.com/glazedlists/                      publicobject.com,*/
/*                                                     O'Dell Engineering Ltd.*/
package com.publicobject.filebrowser;


import java.io.File;
import java.util.Date;

/**
 * A wrapped file with cached meta-data.
 *
 * @author Jesse Wilson
 */
public class Entry implements Comparable {
    private final File file;
    private final boolean isDirectory;
    private final Entry parent;
    private final Date dateModified;
    private final Date dateCreated;
    private final long size;

    public Entry(File file, Entry parent) {
        this.file = file;
        this.isDirectory = file.isDirectory();
        this.parent = parent;

        this.dateModified = new Date(file.lastModified());
        this.dateCreated = new Date(file.lastModified());
        this.size = file.length();
    }

    @Override
    public String toString() {
        return file.getName();
    }

    public String getName() {
        return file.getName();
    }

    public Date getDateModified() {
        return dateModified;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public long getSize() {
        return size;
    }

    public String getKind() {
        return isDirectory ? "Directory" : "File";
    }

    public Entry getParent() {
        return parent;
    }

    public boolean isDirectory() {
        return isDirectory;
    }

    public File getFile() {
        return file;
    }

    public int compareTo(Entry other) {
        return file.compareTo(other.file);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy