public class FileEntry
extends java.lang.Object
implements java.io.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(java.io.File file)
Constructs a new monitor for a specified
File . |
FileEntry(FileEntry parent,
java.io.File file)
Constructs a new monitor for a specified
File . |
Modifier and Type | Method and Description |
---|---|
FileEntry[] |
getChildren()
Gets the directory's files.
|
java.io.File |
getFile()
Gets the file being monitored.
|
long |
getLastModified()
Gets the last modified time from the last time it
was checked.
|
java.nio.file.attribute.FileTime |
getLastModifiedFileTime()
Gets the last modified time from the last time it was checked.
|
long |
getLength()
Gets the length.
|
int |
getLevel()
Gets the level
|
java.lang.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(java.io.File file)
Creates a new child instance.
|
boolean |
refresh(java.io.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(java.nio.file.attribute.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(java.lang.String name)
Sets the file name.
|
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 monitoredpublic FileEntry[] getChildren()
public java.io.File getFile()
public long getLastModified()
public java.nio.file.attribute.FileTime getLastModifiedFileTime()
public long getLength()
public int getLevel()
public java.lang.String getName()
public FileEntry getParent()
public boolean isDirectory()
public boolean isExists()
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 filepublic 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 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(java.nio.file.attribute.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 lengthpublic void setName(java.lang.String name)
name
- the file nameCopyright © 2010 - 2023 Adobe. All Rights Reserved