au.com.prunge.jgenfile.impl.local
Class ItemUtils

java.lang.Object
  |
  +--au.com.prunge.jgenfile.impl.local.ItemUtils

public class ItemUtils
extends Object

Class containing utility methods for local file systems and items.

Version:
1.0
Author:
Peter Runge

Method Summary
static LocalDirectory createDirectoryFromFile(au.com.prunge.jgenfile.FileSystem fileSystem, File file)
          Attempts to create a directory from the specified file.
static LocalDirectory createDirectoryFromFile(au.com.prunge.jgenfile.FileSystem fileSystem, File file, boolean isRoot)
          Attempts to create a directory from the specified file.
static LocalFile createFileFromFile(au.com.prunge.jgenfile.FileSystem fileSystem, File file)
          Attempts to create a file from the specified java.io.File object.
static LocalItem createItemFromFile(au.com.prunge.jgenfile.FileSystem fileSystem, File file)
          Creates an item from a file object.
static LocalItem createItemFromFile(au.com.prunge.jgenfile.FileSystem fileSystem, File file, boolean isRoot)
          Creates an item from a file object.
static au.com.prunge.jgenfile.RelativeItemReference createRelativeReferenceFromFile(File file, File topParent)
          Creates a relative item reference for the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createItemFromFile

public static LocalItem createItemFromFile(au.com.prunge.jgenfile.FileSystem fileSystem,
                                           File file,
                                           boolean isRoot)
                                    throws ItemNotFoundException,
                                           JGenFileException
Creates an item from a file object.

Parameters:
fileSystem - the file system the item will exist in.
file - the file to create the item from.
isRoot - true if the item is a root, false if not.
Returns:
an item object of correct class for the file.
Throws:
NullPointerException - if file == null.
ItemNotFoundException - if the specified File does not exist in the local file system.
JGenFileException - if another error occurs.

createItemFromFile

public static LocalItem createItemFromFile(au.com.prunge.jgenfile.FileSystem fileSystem,
                                           File file)
                                    throws ItemNotFoundException,
                                           JGenFileException
Creates an item from a file object. Checking is performed to see if the specified file is a root in the file system.

Parameters:
fileSystem - the file system the item will exist in.
file - the file to create the item from.
Returns:
an item object of correct class for the file.
Throws:
NullPointerException - if file == null.
ItemNotFoundException - if the specified File does not exist in the local file system.
JGenFileException - if another error occurs.

createDirectoryFromFile

public static LocalDirectory createDirectoryFromFile(au.com.prunge.jgenfile.FileSystem fileSystem,
                                                     File file)
                                              throws ItemNotFoundException,
                                                     JGenFileException
Attempts to create a directory from the specified file. If the file is not a directory, an exception is thrown.

Parameters:
fileSystem - the file system the directory exists in.
file - the file object to create the directory object from.
Returns:
the created directory.
Throws:
ItemNotFoundException - if the specified file does not exist.
JGenFileException - if the specified file does not point to a directory, or another error occurs.

createDirectoryFromFile

public static LocalDirectory createDirectoryFromFile(au.com.prunge.jgenfile.FileSystem fileSystem,
                                                     File file,
                                                     boolean isRoot)
                                              throws ItemNotFoundException,
                                                     JGenFileException
Attempts to create a directory from the specified file. If the file is not a directory, an exception is thrown.

Parameters:
fileSystem - the file system the directory exists in.
file - the file object to create the directory object from.
isRoot - true if the item is a root, false if not.
Returns:
the created directory.
Throws:
ItemNotFoundException - if the specified file does not exist.
JGenFileException - if the specified file does not point to a directory, or another error occurs.

createFileFromFile

public static LocalFile createFileFromFile(au.com.prunge.jgenfile.FileSystem fileSystem,
                                           File file)
                                    throws ItemNotFoundException,
                                           JGenFileException
Attempts to create a file from the specified java.io.File object. If the file object is not a file, an exception is thrown.

Parameters:
fileSystem - the file system the file exists in.
file - the java.io.File object to create the file object from.
Returns:
the created file object.
Throws:
ItemNotFoundException - if the specified file does not exist.
JGenFileException - if the specified file object does not point to a file, or another error occurs.

createRelativeReferenceFromFile

public static au.com.prunge.jgenfile.RelativeItemReference createRelativeReferenceFromFile(File file,
                                                                                           File topParent)
                                                                                    throws NullPointerException,
                                                                                           JGenFileException
Creates a relative item reference for the specified file.

Parameters:
file - the file to create the reference for.
topParent - the highest parent in the relative reference.
Returns:
the created reference.
Throws:
NullPointerException - if a parameter is null.
JGenFileException - if topParent is not an ancestor of file.