j_waste
Class FileDatabase

java.lang.Object
  extended byj_waste.FileDatabase

public class FileDatabase
extends java.lang.Object

This is the File database in J-WASTE, it holds a list of all files with number and name.

Version:
0.1
Author:
Jan Lindblom (cl0wn@users.sourceforge.net)

Constructor Summary
FileDatabase()
          Constructs an empty FileDatabase.
 
Method Summary
static void addFile(java.io.File toAdd)
          Adds a File to the database.
static java.io.File getFile(int index)
          Returns the File Object at the given position.
static java.io.File[] getFiles(java.io.File directory)
          Returns a list of all Files in the given directory.
static int getID(java.io.File file)
          Returns the ID of a specific File.
static void populate()
          Populates the file database, reads the path from config and adds the files to the database.
static int size()
          Returns the size (number of elements) of this FileDatabase.
 java.lang.String toString()
          This method returns a String with all files in the database in a format suitable for display in a console.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileDatabase

public FileDatabase()
Constructs an empty FileDatabase.

Method Detail

getFile

public static java.io.File getFile(int index)
Returns the File Object at the given position.

Parameters:
index - position in the database.
Returns:
The file if it exists, otherwise null.

addFile

public static void addFile(java.io.File toAdd)
Adds a File to the database.

Parameters:
toAdd - the File to add.

getID

public static int getID(java.io.File file)
Returns the ID of a specific File.

Parameters:
file - the File for which to return the ID.
Returns:
the ID of the File or -1 if file is a directory.

size

public static int size()
Returns the size (number of elements) of this FileDatabase.

Returns:
the number of elements in this FileDatabase.

populate

public static void populate()
Populates the file database, reads the path from config and adds the files to the database.


getFiles

public static java.io.File[] getFiles(java.io.File directory)
Returns a list of all Files in the given directory.

Parameters:
directory - the directory from which to list Files.
Returns:
an array of File Objects if successful, null otherwise.

toString

public java.lang.String toString()
This method returns a String with all files in the database in a format suitable for display in a console. The method is meant for debugging only.

Returns:
A String with all files in the share.