/*
 * Created on 13.04.2005
 *
 * $Id$
 */
package dir;

import java.io.File;

import pattern.composite.*;

@Leaf
public class FileComponent implements FileSystemComponent {
    
    private File file = null;
    
    public FileComponent(String name) {
        this(new File(name));
    }

    public FileComponent(File file) {
        this.file = file;
    }

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

    public long getSize() {
        return file.length();
    }
    
    public String toString() {
        return getName() + " (" + getSize() + " Bytes)";
    }
    
    public String toString(String prefix) {
        return prefix + toString();
    }
    
    public static void main(String[] args) {
        FileComponent file = new FileComponent(".project");
        System.out.println("file = " + file);
    }

}
