org.metasyntactic.io.filesystem
Interface Entry

All Known Subinterfaces:
Directory, File
All Known Implementing Classes:
AbstractDirectory, AbstractEntry, AbstractFile

public interface Entry

The base interface that all FileSystem elements must implement to be allowed to be contained within the FileSystem. Currently Files and Directories can be stored in the FileSystem. In the future conveniences, such as Links, will hopefully be added.

All entries have a name in the form of a String, and a unique path with which they can be reached from the root of any file System. The name does not have to be unique but the path must be. For example /java/util/Set.java and /org/metasyntactic/math/Set.java both have the same name "Set.java", however, their path names are unique

NOTE! Entry names should be case sensitive. However, if the underlying FileSystem does not support this feature then too bad!


Method Summary
 boolean delete()
          Deletes this entry from the FileSystem.
 boolean equals(java.lang.Object o)
           
 FileSystem getFileSystem()
          Returns the FileSystem that this entry is contained in
 java.lang.String getName()
          Returns the name of the file or directory denoted by this abstract pathname.
 Directory getParent()
          Returns the directory that this Entry is located in.
 java.lang.String getPath()
          Returns the absolute pathname string of this directory.
 int hashCode()
           
 java.lang.String toString()
           
 

Method Detail

getFileSystem

public FileSystem getFileSystem()
Returns the FileSystem that this entry is contained in


getName

public java.lang.String getName()
Returns the name of the file or directory denoted by this abstract pathname. This is just the last name in the pathname's name sequence. If the pathname's name sequence is empty, then the empty string is returned.

Returns:
The name of the file or directory denoted by this abstract pathname, or the empty string if this pathname's name sequence is empty

getPath

public java.lang.String getPath()
                         throws NoPermissionException
Returns the absolute pathname string of this directory.

NoPermissionException

getParent

public Directory getParent()
                    throws NoPermissionException
Returns the directory that this Entry is located in. If this it called on the root element of a FileSystem it should return Null. Not the root directory again. Note! If a call to this method does return null, then the implementing class should decide whether or not it would be appropriate to see if the FileSystem this directory is contained within is actually contained within another FileSystem, and if traversal should commence to that FileSystem.

NoPermissionException

delete

public boolean delete()
               throws NoPermissionException
Deletes this entry from the FileSystem. The semantics of this will be different for all implementing classes. For example, a directory implementation may or may not allow deletion depending on whether or not there are still entries contained within itself.

Returns:
true If and only if the deletion was successful.
NoPermissionException

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object