public class FileEntry extends Object implements Serializable
File
attributes at a point in time.
File.getName()
)File.exists()
)File.isDirectory()
)FileUtils.lastModifiedUnchecked(File)
)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.
Serialization is deprecated and will be removed in 3.0.
FileAlterationObserver
,
Serialized FormConstructor and Description |
---|
FileEntry(File file)
Constructs a new monitor for a specified
File . |
FileEntry(FileEntry parent,
File file)
Constructs a new monitor for a specified
File . |
Modifier and Type | Method and Description |
---|---|
FileEntry[] |
getChildren()
Gets the directory's files.
|
File |
getFile()
Gets the file being monitored.
|
long |
getLastModified()
Gets the last modified time from the last time it
was checked.
|
FileTime |
getLastModifiedFileTime()
Gets the last modified time from the last time it was checked.
|
long |
getLength()
Gets the length.
|
int |
getLevel()
Gets the level
|
String |
getName()
Gets the file name.
|
FileEntry |
getParent()
Gets the parent entry.
|
boolean |
isDirectory()
Tests whether the file is a directory or not.
|
boolean |
isExists()
Tests whether the file existed the last time it
was checked.
|
FileEntry |
newChildInstance(File file)
Creates a new child instance.
|
boolean |
refresh(File file)
Refreshes the attributes from the
File , indicating
whether the file has changed. |
void |
setChildren(FileEntry... children)
Sets the directory's files.
|
void |
setDirectory(boolean directory)
Sets whether the file is a directory or not.
|
void |
setExists(boolean exists)
Sets whether the file existed the last time it
was checked.
|
void |
setLastModified(FileTime lastModified)
Sets the last modified time from the last time it was checked.
|
void |
setLastModified(long lastModified)
Sets the last modified time from the last time it
was checked.
|
void |
setLength(long length)
Sets the length.
|
void |
setName(String name)
Sets the file name.
|
public FileEntry(File file)
File
.file
- The file being monitoredpublic FileEntry[] getChildren()
public long getLastModified()
public FileTime getLastModifiedFileTime()
public long getLength()
public int getLevel()
public boolean isDirectory()
public boolean isExists()
public FileEntry newChildInstance(File file)
Custom implementations should override this method to return a new instance of the appropriate type.
file
- The child filepublic 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 false
public void setChildren(FileEntry... children)
children
- This directory's files, may be nullpublic void setDirectory(boolean directory)
directory
- whether the file is a directory or notpublic void setExists(boolean exists)
exists
- whether the file exists or notpublic void setLastModified(FileTime lastModified)
lastModified
- The last modified time.public void setLastModified(long lastModified)
lastModified
- The last modified time in milliseconds.public void setLength(long length)
length
- the lengthCopyright © 2002–2023 The Apache Software Foundation. All rights reserved.