public class FileEntry extends Object implements Serializable
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))
If the state of additional 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 Form| Constructor and Description |
|---|
FileEntry(File file)
Construct a new monitor for a specified
File. |
FileEntry(FileEntry parent,
File file)
Construct a new monitor for a specified
File. |
| Modifier and Type | Method and Description |
|---|---|
FileEntry[] |
getChildren()
Return the directory's files.
|
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
|
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(File file)
Create a new child instance.
|
boolean |
refresh(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(String name)
Set the file name.
|
public FileEntry(File file)
File.file - The file being monitoredpublic boolean refresh(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 totrue if the file has changed, otherwise falsepublic FileEntry newChildInstance(File file)
Custom implementations should override this method to return a new instance of the appropriate type.
file - The child filepublic int getLevel()
public FileEntry[] getChildren()
public void setChildren(FileEntry... children)
children - This directory's files, may be nullpublic 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 notCopyright © 2002–2020 The Apache Software Foundation. All rights reserved.