|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.io.monitor.FileEntry
public class FileEntry
FileEntry
represents the state of a file or directory, capturing
the following File
attributes at a point in time.
File.getName()
)File.exists()
)File.isDirectory()
)File.lastModified()
)File.length()
) - directories treated as zeroFile.listFiles(java.io.FileFilter)
)
File
attributes is required then create a custom
FileEntry
with properties for those attributes. Override the
newChildInstance(File)
to return a new instance of the appropriate type.
You may also want to override the refresh(File)
method.
FileAlterationObserver
,
Serialized FormField Summary | |
---|---|
private FileEntry[] |
children
|
private boolean |
directory
|
(package private) static FileEntry[] |
EMPTY_ENTRIES
|
private boolean |
exists
|
private java.io.File |
file
|
private long |
lastModified
|
private long |
length
|
private java.lang.String |
name
|
private FileEntry |
parent
|
Constructor Summary | |
---|---|
FileEntry(java.io.File file)
Construct a new monitor for a specified File . |
|
FileEntry(FileEntry parent,
java.io.File file)
Construct a new monitor for a specified File . |
Method Summary | |
---|---|
FileEntry[] |
getChildren()
Return the directory's files. |
java.io.File |
getFile()
Return the file being monitored. |
long |
getLastModified()
Return the last modified time from the last time it was checked. |
long |
getLength()
Return the length. |
int |
getLevel()
Return the level |
java.lang.String |
getName()
Return the file name. |
FileEntry |
getParent()
Return the parent entry. |
boolean |
isDirectory()
Indicate whether the file is a directory or not. |
boolean |
isExists()
Indicate whether the file existed the last time it was checked. |
FileEntry |
newChildInstance(java.io.File file)
Create a new child instance. |
boolean |
refresh(java.io.File file)
Refresh the attributes from the File , indicating
whether the file has changed. |
void |
setChildren(FileEntry[] children)
Set the directory's files. |
void |
setDirectory(boolean directory)
Set whether the file is a directory or not. |
void |
setExists(boolean exists)
Set whether the file existed the last time it was checked. |
void |
setLastModified(long lastModified)
Return the last modified time from the last time it was checked. |
void |
setLength(long length)
Set the length. |
void |
setName(java.lang.String name)
Set the file name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final FileEntry[] EMPTY_ENTRIES
private final FileEntry parent
private FileEntry[] children
private final java.io.File file
private java.lang.String name
private boolean exists
private boolean directory
private long lastModified
private long length
Constructor Detail |
---|
public FileEntry(java.io.File file)
File
.
file
- The file being monitoredpublic FileEntry(FileEntry parent, java.io.File file)
File
.
parent
- The parentfile
- The file being monitoredMethod Detail |
---|
public boolean refresh(java.io.File file)
File
, indicating
whether the file has changed.
This implementation refreshes the name
, exists
,
directory
, lastModified
and length
properties.
The exists
, directory
, lastModified
and length
properties are compared for changes
file
- the file instance to compare to
true
if the file has changed, otherwise false
public FileEntry newChildInstance(java.io.File file)
Custom implementations should override this method to return a new instance of the appropriate type.
file
- The child file
public FileEntry getParent()
public int getLevel()
public FileEntry[] getChildren()
public void setChildren(FileEntry[] children)
children
- This directory's files, may be nullpublic java.io.File getFile()
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the file namepublic long getLastModified()
public void setLastModified(long lastModified)
lastModified
- The last modified timepublic long getLength()
public void setLength(long length)
length
- the lengthpublic boolean isExists()
public void setExists(boolean exists)
exists
- whether the file exists or notpublic boolean isDirectory()
public void setDirectory(boolean directory)
directory
- whether the file is a directory or not
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |