|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gubutech.xload.XloadDirectory
Class that represents a directory/folder on the file system.
An instance of this class represents a directory on the file system and information can be gleaned from this directory using appropriate methods. There are also a number of operations that can be performed on the represented directory.
All contained files and directories within a directory represented by an XloadDirectory
object, are termed directory items
.
Method Summary | |
XloadDirectory |
createDirectory(java.lang.String direct)
Creates a directory within the directory represented by this object. |
boolean |
delete()
Deletes this objects directory (and contained files) and all sub-directories and files. |
boolean |
directoryExists(java.lang.String direct)
Determines whether or not a directory exists within this objects directory or not. |
boolean |
equals(java.lang.Object o)
Determines whether or not an object passed as a parameter is an XloadDirectory object and represents the same directory
as this object does. |
boolean |
exists()
Determines whether or not this objects directory exists or not. |
boolean |
fileExists(java.lang.String fileName)
Determines whether or not a file exists within this objects directory or not. |
XloadDirectory |
getDirectory(java.lang.String dirName)
Returns a directory represented as an XloadDirectory object if one exists in the directory represented by this object. |
java.lang.String |
getDirectoryPath()
Returns the absolute directory path of this objects directory on the file system. |
XloadFile |
getFile(java.lang.String fileName)
Returns a file represented as an XloadFile object if one exists in the directory represented by this object. |
float |
getMegabyteSize(boolean includeSubfolders)
Determines the total size of files inside this objects represented directory. |
java.lang.String |
getName()
Returns the name of this directory on the file system. |
XloadDirectoryItem |
getNext()
Returns the next directory item in sequence depending upon the settings provided by the sortBy(int, boolean) , sortBy(int) , setOmmitFiles(boolean) and
setOmmitDirectories(boolean) methods. |
int |
getSize()
Gets the number of files and/or directories in this directory depending whether or not the programmer has specified to ommit files and/or directories in that calculation using setOmmitFiles(boolean) or setOmmitDirectories(boolean) . |
boolean |
hasMore()
Indicates whether or not there are any more existing directory items in this objects directory. |
boolean |
isDeleted()
Determines whether or not the directory represented by this object has been deleted or not. |
boolean |
isDirectory()
Determines whether or not this object represents a directory or not. |
boolean |
isFile()
Determines whether or not this object represents a file or not. |
void |
reset()
Resets the iteration list cursor provided by this class back to the beginning of the list for all directory items within this objects
directory. |
void |
setOmmitDirectories(boolean b)
When set to true , then when using certain methods, directories contained in this objects represented directory are
ommitted in certain calculations. |
void |
setOmmitFiles(boolean b)
When set to true , then when using certain methods, files contained in this objects represented directory are
ommitted in certain calculations. |
void |
sortBy(int sortBy)
Convenience method performing exactly the same function as sortBy(int sortBy, boolean ascending) with the ascending parameter
set to true . |
void |
sortBy(int sortBy,
boolean ascending)
Sets the 'sort by' algorithm for when any iteration is performed on this object using the hasMore() and associated methods. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public boolean isFile()
XloadDirectoryItem
objects.
isFile
in interface XloadDirectoryItem
false
.public boolean isDirectory()
XloadDirectoryItem
objects.
isDirectory
in interface XloadDirectoryItem
true
if this objects represented directory exists, false
otherwise.
java.lang.SecurityException
- Thrown if a there is a problem accessing the directory on the file system with regard to permissions
set by any existing SecurityManager
.public boolean isDeleted()
isDeleted
in interface XloadDirectoryItem
true
if the directory represented has been deleted, false
otherwise.
java.lang.SecurityException
- Thrown if a there is a problem accessing the directory on the file system with regard to permissions
set by any existing SecurityManager
.public XloadDirectory createDirectory(java.lang.String direct) throws java.io.IOException
direct
- The name of the new directory to be created as a String
object.
XloadDirectory
object representing the new directory created (or one that already exists
with the same name) or null
if this objects directory does not exist.
java.io.IOException
- Thrown if the new directory cannot be created for some reason such as an incorrect system dependant naming convention or
access permission restrictions.
XloadNullArgumentException
- Thrown if the parameter direct
is null
.
java.lang.SecurityException
- Thrown if a there is a problem creating the directory on the file system with regard to permissions
set by any existing SecurityManager
.public float getMegabyteSize(boolean includeSubfolders) throws java.io.IOException
includeSubfolders
- boolean
parameter specifying whether or not sub-folders(directories) of this objects directory
should be included when computing the total size of files contained within this objects directory.
includeSubfolders
parameter),
in megabytes as a floating point
value. This method returns zero if this objects directory has been deleted.
java.io.IOException
- Thrown if there is a problem accessing any of the directories involved in the computation. (Maybe due to access permisssion
restrictions).
java.lang.SecurityException
- Thrown if a there is a problem accessing the appropriate directories and/or files on the file system with regard to permissions
set by any existing SecurityManager
.public boolean delete()
delete
in interface XloadDirectoryItem
true
if this objects directory has been successfully deleted and false
if this objects directory cannot be deleted,
which maybe due to operating system access permissions.
java.lang.SecurityException
- Thrown if a there is a problem accessing the appropriate directories and/or files on the file system with regard to permissions
set by any existing SecurityManager
. Please note that if this exception is thrown then there will be some directories
and/or files that are left not deleted.public int getSize() throws java.io.IOException
setOmmitFiles(boolean)
or setOmmitDirectories(boolean)
.
java.io.IOException
- Thrown if there is a problem accessing the directory (this may be due to system access permission restrictions).
java.lang.SecurityException
- Thrown if a there is a problem accessing the directory on the file system with regard to permissions
set by any existing SecurityManager
.public void setOmmitFiles(boolean b)
true
, then when using certain methods, files contained in this objects represented directory are
ommitted in certain calculations.
b
- boolean
parameter to control whether or not files are ommitted with the use of certain methods.getNext()
,
hasMore()
,
reset()
,
getSize()
public void setOmmitDirectories(boolean b)
true
, then when using certain methods, directories contained in this objects represented directory are
ommitted in certain calculations.
b
- boolean
parameter to control whether or not files are ommitted with the use of certain methods.getNext()
,
hasMore()
,
reset()
,
getSize()
public XloadFile getFile(java.lang.String fileName) throws java.io.IOException
XloadFile
object if one exists in the directory represented by this object. The XloadFile
object returned will represent the correct type of file on the file system for example if the file requested is a XloadFile
instance will be returned altenatively an ordinary file will be represented.
fileName
- Name of the file requested.
XloadFile
instance if a file with the correct fileName
exists or null
if it does not exist.
java.io.IOException
- Thrown if there is a problem accessing the directory (this may be due to system access permission restrictions).
java.lang.SecurityException
- Thrown if a there is a problem accessing the directory on the file system with regard to permissions
set by any existing SecurityManager
.
XloadNullArgumentException
- Thrown if the parameter fileName
is null
public XloadDirectory getDirectory(java.lang.String dirName) throws java.io.IOException
XloadDirectory
object if one exists in the directory represented by this object.
dirName
- Name of the directory requested.
XloadDirectory
instance if a directory with the correct dirName
exists or null
if it does not exist.
java.io.IOException
- Thrown if there is a problem accessing this objects directory (this may be due to system access permission restrictions).
java.lang.SecurityException
- Thrown if a there is a problem accessing the directory on the file system with regard to permissions
set by any existing SecurityManager
.public java.lang.String getName()
null
if it does not exist.
java.lang.SecurityException
- Thrown if a there is a problem accessing the directory on the file system with regard to permissions
set by any existing SecurityManager
.public void sortBy(int sortBy, boolean ascending)
hasMore()
and associated methods.
sortBy
- Parameter stating algorithm type. Allowable input parameters are:ascending
- States in which order to sort the directory items, ascending(true
) or descending(false
).
XloadIncorrectSortByCodeException
- Thrown if an incorrect sort by code number is chosen.hasMore()
,
getNext()
,
reset()
public void sortBy(int sortBy)
sortBy(int sortBy, boolean ascending)
with the ascending parameter
set to true
.
sortBy
- Parameter stating algorithm type. Allowable input parameters are:XloadIncorrectSortByCodeException
- Thrown if an incorrect sort by code number is chosen.sortBy(int, boolean)
,
hasMore()
,
getNext()
,
reset()
public boolean hasMore() throws java.io.IOException
directory items
in this objects directory. This method works in
conjunction with the getNext()
method which retrieves the next element in the list and the reset()
method which
resets the list back to the beginning. The order of the list will depend upon the settings given by using the sortBy(int, boolean)
and
sortBy(int)
methods. The default ordering of directory items
is determined by the underlying operating system and no
guarantees can be made. What is contained in the list will depend upon the settings used in the setOmmitFiles(boolean)
and
setOmmitDirectories(boolean)
methods (e.g. if setOmmitFiles(true)
is called then the list only contains directories).
If, while iterating through the list, the contents of this objects directory (or any settings) are altered in some way then this alteration will not be shown
until the reset()
has been called and a new list is created from the underlying directory contents. This method will not
however display any fail-fast behaviour as is associated with the iterator
interface if modifications do occur.
true
if there are anymore directory items in the list, false
otherwise.
java.io.IOException
- Thrown if there is a problem accessing this objects directory (this may be due to system access permission restrictions).
java.lang.SecurityException
- Thrown if there is a problem accessing files and/or directories on the file system with regard to permissions set by the SecurityManager
.getNext()
,
reset()
public void reset()
directory items
within this objects
directory. This allows the programmer to iterate over all directory items
more than once (as the cursor is always at the beginning of the
list when this object is created). When this method is called, any changes or different settings will be taken into account when iterating over the list the next time.
java.lang.SecurityException
- Thrown if there is a problem accessing the directory on the file system with regard to permissions set by the SecurityManager
.hasMore()
,
getNext()
public XloadDirectoryItem getNext()
sortBy(int, boolean)
, sortBy(int)
, setOmmitFiles(boolean)
and
setOmmitDirectories(boolean)
methods. (see hasMore()
for further information).
XloadDirectoryItem
object in sequence or null
if at any stage the returned underlying
directory or file has been deleted. This method will return the correct type of file (i.e. if the file is a file deployment
or not).
java.util.NoSuchElementException
- Thrown if this method is used in an inappropriate location (i.e. outside the confines of an hasMore()
loop or if
there are no more directory items to return when this method is called.
java.lang.SecurityException
- Thrown if there is a problem accessing the directory item (directory or file) on the file system with regard to permissions
set by the SecurityManager
.hasMore()
,
reset()
public boolean fileExists(java.lang.String fileName)
fileName
- The name of the file to check existance for.
true
if the file exists in this objects directory, false
otherwise.
XloadNullArgumentException
- Thrown if fileName
is null
.
java.lang.SecurityException
- Thrown if there is a problem accessing the directory on the file system with regard to permissions
set by the SecurityManager
.public boolean directoryExists(java.lang.String direct)
direct
- The name of the directory to check existence for.
true
if the file exists in this objects directory, false
otherwise.
XloadNullArgumentException
- Thrown if direct
is null
.
java.lang.SecurityException
- Thrown if there is a problem accessing the directory on the file system with regard to permissions
set by the SecurityManager
.public java.lang.String getDirectoryPath()
String
object which will be system dependant.
java.lang.SecurityException
- Thrown if there is a problem accessing the directory on the file system with regard to permissions
set by the SecurityManager
.public boolean exists()
exists
in interface XloadDirectoryItem
true
if this objects directory exists, false
otherwise.
java.lang.SecurityException
- Thrown if there is a problem accessing the directory on the file system with regard to permissions
set by the SecurityManager
.public boolean equals(java.lang.Object o)
XloadDirectory
object and represents the same directory
as this object does.
equals
in interface XloadDirectoryItem
o
- Object to be tested for equality.
true
if this object is equal to the object represented by the parameter o
, false
otherwise; o
is only equal, if and only if, it is an instance of XloadDirectory
and it represents exactly
the same directory on the file system as this objects represented directory such that -
this.directory.equals(o.directory)
(where directory
is of type java.io.File
)
java.lang.SecurityException
- Thrown if there is a problem accessing the directories on the file system with regard to permissions
set by the SecurityManager
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |