com.lightdev.lib.filesystem
Class FileRef

java.lang.Object
  extended by com.lightdev.lib.filesystem.FileRef
All Implemented Interfaces:
Serializable

public class FileRef
extends Object
implements Serializable

A reference to a file consisting of the file's absolute path and additional information about whether or not the referenced file is a directory, is hidden, etc. Note that FileRef only references a file, the file itself and its contents are not modelled by this class.

Version:
2, 12.01.2008
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the BSD License, for details see file license.txt in the distribution package of this software
See Also:
Serialized Form

Constructor Summary
FileRef(String absolutePath)
          Create a new instance of class FileRef with a given absolute path.
FileRef(String absolutePath, boolean isDirectory)
          Create a new instance of class FileRef with a given absolute path and an indicator whether or not the new FileRef denotes a directory.
FileRef(String absolutePath, boolean isDirectory, boolean isHidden, long lastModified, long length)
          create a new instance of FileRef.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some object is equal to this instance of class FileRef.
 String getAbsolutePath()
          get the absolute path that denotes this file
 long getLastModified()
          Returns the time that this file was last modified.
 long getLength()
          Returns the length of this file.
 String getName(String separatorChar)
          get the name of this file without path
 boolean isDirectory()
          Tests whether the file denoted by this abstract pathname is a directory.
 boolean isFile()
          Tests whether the file denoted by this abstract pathname is a file.
 boolean isHidden()
          Tests whether the file denoted by this abstract pathname is a hidden file.
 String toString()
          get a string representation of this instance of FileRef
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileRef

public FileRef(String absolutePath,
               boolean isDirectory,
               boolean isHidden,
               long lastModified,
               long length)
create a new instance of FileRef. Note that the created FileRef is only a reference to a file, the file itself will not be created.

Parameters:
absolutePath - the absolute path that denotes this instance of FileRef
isDirectory - whether or not this file is a directory
isHidden - whether or not this file is a hidden file
lastModified - the date/time this file was last modified measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
length - the length of this file in bytes

FileRef

public FileRef(String absolutePath)
Create a new instance of class FileRef with a given absolute path. Other characteristics of the file are created with default settings (i.e. not a directory, not hidden, unknown modification date and length). Note that the created FileRef is only a reference to a file, the file itself will not be created.

Parameters:
absolutePath - the absolute path that denotes this instance of FileRef

FileRef

public FileRef(String absolutePath,
               boolean isDirectory)
Create a new instance of class FileRef with a given absolute path and an indicator whether or not the new FileRef denotes a directory. Other characteristics of the file are created with default settings (i.e. not hidden, unknown modification date and length). Note that the created FileRef is only a reference to a file, the file itself will not be created.

Parameters:
absolutePath - the absolute path that denotes this instance of FileRef
isDirectory - true, if the file to create should denote a directory
Method Detail

getAbsolutePath

public String getAbsolutePath()
get the absolute path that denotes this file

Returns:
the path

isDirectory

public boolean isDirectory()
Tests whether the file denoted by this abstract pathname is a directory.

Returns:
true if this file is a directory, false otherwise

isFile

public boolean isFile()
Tests whether the file denoted by this abstract pathname is a file.

Returns:
true if this file is a file, false otherwise

isHidden

public boolean isHidden()
Tests whether the file denoted by this abstract pathname is a hidden file.

Returns:
true if this file is a hidden file, false otherwise

getLastModified

public long getLastModified()
Returns the time that this file was last modified.

Returns:
A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)

getLength

public long getLength()
Returns the length of this file. The return value is unspecified if this file denotes a directory.

Returns:
The length, in bytes, of this file

getName

public String getName(String separatorChar)
get the name of this file without path

Parameters:
separatorChar - the string that is used to separate directories and file names in path expressions
Returns:
the name of this file without path

toString

public String toString()
get a string representation of this instance of FileRef

Overrides:
toString in class Object
Returns:
the string representation of this FileRef object

equals

public boolean equals(Object obj)
Indicates whether some object is equal to this instance of class FileRef. Two GenericFiles are regarded as equal when their absolute paths are equal case independently.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with this instance of FileRef
Returns:
true, if obj is equal to this instance of FileRef, false if not