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

java.lang.Object
  |
  +--au.com.prunge.jgenfile.impl.local.LocalItem
All Implemented Interfaces:
Item
Direct Known Subclasses:
LocalDirectory, LocalFile

public class LocalItem
extends Object
implements Item

An item in the local file system.

Version:
1.0
Author:
Peter Runge

Constructor Summary
LocalItem(au.com.prunge.jgenfile.FileSystem fileSystem, File file)
          Constructs a LocalItem that is not a root.
LocalItem(au.com.prunge.jgenfile.FileSystem fileSystem, File file, boolean isRoot)
          Constructs a LocalItem.
 
Method Summary
 au.com.prunge.jgenfile.CanCopyItemOperation createCanCopyItemOperation()
          Creates an operation that tests whether this item can be copied.
 au.com.prunge.jgenfile.CanCopyItemToDestinationOperation createCanCopyItemToDestinationOperation(au.com.prunge.jgenfile.Directory destination)
          Creates an operation that tests whether this item can be copied into the specified directory keeping its current name.
 au.com.prunge.jgenfile.CanCopyItemToDestinationOperation createCanCopyItemToDestinationOperation(au.com.prunge.jgenfile.Directory destination, String newName)
          Creates an operation that tests whether this item can be copied into the specified directory using the specified name.
 au.com.prunge.jgenfile.CanDeleteItemOperation createCanDeleteOperation()
          Creates an operation that tests whether this item can be deleted.
 au.com.prunge.jgenfile.CanGetAbsolutePathOperation createCanGetAbsolutePathOperation()
          Creates an operation that tests whether the absolute path of this item can be acquired.
 au.com.prunge.jgenfile.CanGetMetadataOperation createCanGetMetadataOperation(Set metadataKeySet)
          Creates an operation that tests whether the specified metadata is accessible for this item.
 au.com.prunge.jgenfile.CanGetParentOperation createCanGetParentOperation()
          Creates an operation that will test whether the parent of this item can be acquired.
 au.com.prunge.jgenfile.CanGetRelativePathOperation createCanGetRelativePathOperation(au.com.prunge.jgenfile.Directory toAncestor)
          Creates an operation that tests whether the relative path of this item up to and including toAncestor can be acquired.
 au.com.prunge.jgenfile.CanSetMetadataOperation createCanSetMetadataOperation(Set metadataKeySet)
          Creates an operation that tests whether the specified metadata can be set for this item.
 au.com.prunge.jgenfile.CanSetNameOperation createCanSetNameOperation()
          Creates an operation that tests whether the name of this item can be changed.
 au.com.prunge.jgenfile.CanSetParentOperation createCanSetParentOperation()
          Creates an operation that tests whether the parent of this item can be changed.
 au.com.prunge.jgenfile.CopyItemOperation createCopyOperation(au.com.prunge.jgenfile.Directory destination)
          Creates an operation that copies this item to the specified destination directory.
 au.com.prunge.jgenfile.CopyItemOperation createCopyOperation(au.com.prunge.jgenfile.Directory destination, String newName)
          Creates an operation that copies this item to the specified destination directory giving the copied item a name of newName.
 au.com.prunge.jgenfile.DeleteItemOperation createDeleteItemOperation()
          Creates an operation that will delete this item.
 au.com.prunge.jgenfile.GetAbsolutePathOperation createGetAbsolutePathOperation()
          Creates an operation that gets the absolute path of this item.
 au.com.prunge.jgenfile.GetMetadataOperation createGetAllMetadataOperation()
          Creates an operation that acquires all available metadata for this item.
 au.com.prunge.jgenfile.GetAllMetadataKeysOperation createGetMetadataKeysOperation()
          Creates an operation that gets all the keys for the metadata of this item.
 au.com.prunge.jgenfile.GetMetadataOperation createGetMetadataOperation(Set metadataKeySet)
          Creates an operation that acquires the specified metadata.
 au.com.prunge.jgenfile.GetParentOperation createGetParentOperation()
          Creates an operation that will retrieve the parent of this item.
 au.com.prunge.jgenfile.GetRelativePathOperation createGetRelativePathOperation(au.com.prunge.jgenfile.Directory toAncestor)
          Creates an operation that gets the relative path of this item up to and including toAncestor.
protected  String createName()
          Creates the name of the item from the java.io.File object.
 au.com.prunge.jgenfile.SetMetadataOperation createSetMetadataOperation(Map metadataMap)
          Creates an operation that sets the specified metadata for this item.
 au.com.prunge.jgenfile.SetNameOperation createSetNameOperation(String newName)
          Creates an operation that will set the name of this item.
 au.com.prunge.jgenfile.SetParentOperation createSetParentOperation(au.com.prunge.jgenfile.Directory parent)
          Creates an operation that will set the parent of (i.e.
 boolean equals(Object obj)
           
 File getFile()
          Returns the underlying file object of this item.
 au.com.prunge.jgenfile.FileSystem getFileSystem()
          Returns the file system this item exists in.
 String getName()
          Returns the name of the item.
 int hashCode()
           
protected  boolean isRoot()
          Returns whether this item is a root of the file system.
 void setFile(File file)
          Sets the underlying file object of this item.
protected  void setupOperation(au.com.prunge.jgenfile.Operation op)
          Sets up an operation with operation hints.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalItem

public LocalItem(au.com.prunge.jgenfile.FileSystem fileSystem,
                 File file)
Constructs a LocalItem that is not a root.

Parameters:
fileSystem - the file system to create this item in.
file - the underlying file object.
Throws:
NullPointerException - if file is null.

LocalItem

public LocalItem(au.com.prunge.jgenfile.FileSystem fileSystem,
                 File file,
                 boolean isRoot)
Constructs a LocalItem.

Parameters:
fileSystem - the file system to create this item in.
file - the underlying file object.
isRoot - true if this item is a root, false if not.
Throws:
NullPointerException - if file is null.
Method Detail

getFile

public File getFile()
Returns the underlying file object of this item.

Returns:
the underlying file object of this item.

setFile

public void setFile(File file)
             throws NullPointerException
Sets the underlying file object of this item.

Parameters:
file - the new underlying file object of this item.
Throws:
NullPointerException - if file is null.

isRoot

protected boolean isRoot()
Returns whether this item is a root of the file system.

Returns:
true if this item is a root, false if not.

createName

protected String createName()
Creates the name of the item from the java.io.File object.

Returns:
the name of the item.

getName

public String getName()
               throws JGenFileException
Description copied from interface: Item
Returns the name of the item.

Specified by:
getName in interface Item
Returns:
the name of the item.
Throws:
JGenFileException - if an error occurs getting the name of the item.
See Also:
Item.getName()

setupOperation

protected void setupOperation(au.com.prunge.jgenfile.Operation op)
                       throws JGenFileException
Sets up an operation with operation hints. This method is called after every operation for this item is created.

The default operation hints registered in the file system are added to the specified operation.

Parameters:
op - the operation to set up.
Throws:
JGenFileException - if an error occurs.

createSetNameOperation

public au.com.prunge.jgenfile.SetNameOperation createSetNameOperation(String newName)
                                                               throws JGenFileException
Description copied from interface: Item
Creates an operation that will set the name of this item.

Specified by:
createSetNameOperation in interface Item
Parameters:
newName - the new name of the item.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createSetNameOperation(java.lang.String)

createCanSetNameOperation

public au.com.prunge.jgenfile.CanSetNameOperation createCanSetNameOperation()
                                                                     throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether the name of this item can be changed.

Specified by:
createCanSetNameOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanSetNameOperation()

createGetParentOperation

public au.com.prunge.jgenfile.GetParentOperation createGetParentOperation()
                                                                   throws JGenFileException
Description copied from interface: Item
Creates an operation that will retrieve the parent of this item.

Specified by:
createGetParentOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createGetParentOperation()

createCanGetParentOperation

public au.com.prunge.jgenfile.CanGetParentOperation createCanGetParentOperation()
                                                                         throws JGenFileException
Description copied from interface: Item
Creates an operation that will test whether the parent of this item can be acquired.

Specified by:
createCanGetParentOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanGetParentOperation()

createSetParentOperation

public au.com.prunge.jgenfile.SetParentOperation createSetParentOperation(au.com.prunge.jgenfile.Directory parent)
                                                                   throws JGenFileException
Description copied from interface: Item
Creates an operation that will set the parent of (i.e. move) this item.

Specified by:
createSetParentOperation in interface Item
Parameters:
parent - the new parent to attempt to set with the operation.
Throws:
JGenFileException - if the operation could not be created.
See Also:
au.com.prunge.jgenfile.Item#createSetParentOperation(au.com.prunge.jgenfile.Item)

createCanSetParentOperation

public au.com.prunge.jgenfile.CanSetParentOperation createCanSetParentOperation()
                                                                         throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether the parent of this item can be changed.

Specified by:
createCanSetParentOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanSetParentOperation()

createDeleteItemOperation

public au.com.prunge.jgenfile.DeleteItemOperation createDeleteItemOperation()
                                                                     throws JGenFileException
Description copied from interface: Item
Creates an operation that will delete this item. If this item is a directory, any files or directories contained in this directory will also be deleted.

Specified by:
createDeleteItemOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createDeleteItemOperation()

createCanDeleteOperation

public au.com.prunge.jgenfile.CanDeleteItemOperation createCanDeleteOperation()
                                                                       throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether this item can be deleted.

Specified by:
createCanDeleteOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanDeleteOperation()

createGetMetadataOperation

public au.com.prunge.jgenfile.GetMetadataOperation createGetMetadataOperation(Set metadataKeySet)
                                                                       throws JGenFileException
Description copied from interface: Item
Creates an operation that acquires the specified metadata.

Specified by:
createGetMetadataOperation in interface Item
Parameters:
metadataKeySet - a set of MetadataKey objects.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createGetMetadataOperation(java.util.Set)

createGetAllMetadataOperation

public au.com.prunge.jgenfile.GetMetadataOperation createGetAllMetadataOperation()
                                                                          throws JGenFileException
Description copied from interface: Item
Creates an operation that acquires all available metadata for this item.

Specified by:
createGetAllMetadataOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createGetAllMetadataOperation()

createCanGetMetadataOperation

public au.com.prunge.jgenfile.CanGetMetadataOperation createCanGetMetadataOperation(Set metadataKeySet)
                                                                             throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether the specified metadata is accessible for this item.

Specified by:
createCanGetMetadataOperation in interface Item
Parameters:
metadataKeySet - a set of MetadataKey objects representing the elements of metadata to test for.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanGetMetadataOperation(java.util.Set)

createSetMetadataOperation

public au.com.prunge.jgenfile.SetMetadataOperation createSetMetadataOperation(Map metadataMap)
                                                                       throws JGenFileException
Description copied from interface: Item
Creates an operation that sets the specified metadata for this item.

The map's keys should consist of MetadataKey objects, the values should be appropriate for each key.

Specified by:
createSetMetadataOperation in interface Item
Parameters:
metadataMap - a map of MetadataKeys to values.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createSetMetadataOperation(java.util.Map)

createCanSetMetadataOperation

public au.com.prunge.jgenfile.CanSetMetadataOperation createCanSetMetadataOperation(Set metadataKeySet)
                                                                             throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether the specified metadata can be set for this item.

Specified by:
createCanSetMetadataOperation in interface Item
Parameters:
metadataKeySet - a set of MetadataKey objects representing the elements of metadata to test for.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanSetMetadataOperation(java.util.Set)

createGetMetadataKeysOperation

public au.com.prunge.jgenfile.GetAllMetadataKeysOperation createGetMetadataKeysOperation()
                                                                                  throws JGenFileException
Description copied from interface: Item
Creates an operation that gets all the keys for the metadata of this item. This operation is usually less expensive than using the get all metadata operation.

An element of metadata may be either readable, writable or both. If a key exists in the set returned by this operation, the corresponding element of metadata is either readable, writable or both.

Specified by:
createGetMetadataKeysOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createGetMetadataKeysOperation()

createCopyOperation

public au.com.prunge.jgenfile.CopyItemOperation createCopyOperation(au.com.prunge.jgenfile.Directory destination)
                                                             throws JGenFileException
Description copied from interface: Item
Creates an operation that copies this item to the specified destination directory.

Specified by:
createCopyOperation in interface Item
Parameters:
destination - the destination directory.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCopyOperation(au.com.prunge.jgenfile.Directory)

createCopyOperation

public au.com.prunge.jgenfile.CopyItemOperation createCopyOperation(au.com.prunge.jgenfile.Directory destination,
                                                                    String newName)
                                                             throws JGenFileException
Description copied from interface: Item
Creates an operation that copies this item to the specified destination directory giving the copied item a name of newName.

Specified by:
createCopyOperation in interface Item
Parameters:
destination - the destination directory.
newName - the name to give the copied item.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCopyOperation(au.com.prunge.jgenfile.Directory, java.lang.String)

createCanCopyItemToDestinationOperation

public au.com.prunge.jgenfile.CanCopyItemToDestinationOperation createCanCopyItemToDestinationOperation(au.com.prunge.jgenfile.Directory destination)
                                                                                                 throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether this item can be copied into the specified directory keeping its current name.

Specified by:
createCanCopyItemToDestinationOperation in interface Item
Parameters:
destination - the destination directory.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanCopyItemToDestinationOperation(au.com.prunge.jgenfile.Directory)

createCanCopyItemToDestinationOperation

public au.com.prunge.jgenfile.CanCopyItemToDestinationOperation createCanCopyItemToDestinationOperation(au.com.prunge.jgenfile.Directory destination,
                                                                                                        String newName)
                                                                                                 throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether this item can be copied into the specified directory using the specified name.

Specified by:
createCanCopyItemToDestinationOperation in interface Item
Parameters:
destination - the destination directory.
newName - the name the copied item would have.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanCopyItemToDestinationOperation(au.com.prunge.jgenfile.Directory, java.lang.String)

createCanCopyItemOperation

public au.com.prunge.jgenfile.CanCopyItemOperation createCanCopyItemOperation()
                                                                       throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether this item can be copied.

Specified by:
createCanCopyItemOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanCopyItemOperation()

createGetAbsolutePathOperation

public au.com.prunge.jgenfile.GetAbsolutePathOperation createGetAbsolutePathOperation()
                                                                               throws JGenFileException
Description copied from interface: Item
Creates an operation that gets the absolute path of this item.

Specified by:
createGetAbsolutePathOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createGetAbsolutePathOperation()

createCanGetAbsolutePathOperation

public au.com.prunge.jgenfile.CanGetAbsolutePathOperation createCanGetAbsolutePathOperation()
                                                                                     throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether the absolute path of this item can be acquired.

Specified by:
createCanGetAbsolutePathOperation in interface Item
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanGetAbsolutePathOperation()

createGetRelativePathOperation

public au.com.prunge.jgenfile.GetRelativePathOperation createGetRelativePathOperation(au.com.prunge.jgenfile.Directory toAncestor)
                                                                               throws JGenFileException
Description copied from interface: Item
Creates an operation that gets the relative path of this item up to and including toAncestor.

Specified by:
createGetRelativePathOperation in interface Item
Parameters:
toAncestor - the ancestor to get the relative path up to. The path will start from this item and go up through each parent of this item until toAncestor is hit. toAncestor will be the most distant ancestor included in the path.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createGetRelativePathOperation(au.com.prunge.jgenfile.Directory)

createCanGetRelativePathOperation

public au.com.prunge.jgenfile.CanGetRelativePathOperation createCanGetRelativePathOperation(au.com.prunge.jgenfile.Directory toAncestor)
                                                                                     throws JGenFileException
Description copied from interface: Item
Creates an operation that tests whether the relative path of this item up to and including toAncestor can be acquired.

Specified by:
createCanGetRelativePathOperation in interface Item
Parameters:
toAncestor - the ancestor to get the relative path up to. The path will start from this item and go up through each parent of this item until toAncestor is hit.
Throws:
JGenFileException - if the operation could not be created.
See Also:
Item.createCanGetRelativePathOperation(au.com.prunge.jgenfile.Directory)

getFileSystem

public au.com.prunge.jgenfile.FileSystem getFileSystem()
                                                throws JGenFileException
Description copied from interface: Item
Returns the file system this item exists in.

Specified by:
getFileSystem in interface Item
Returns:
the file system this item exists in.
Throws:
JGenFileException - if an error occurs.
See Also:
Item.getFileSystem()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()