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 FormModifier and Type | Field and Description |
---|---|
private FileEntry[] |
children |
private boolean |
directory |
(package private) static FileEntry[] |
EMPTY_FILE_ENTRY_ARRAY |
private boolean |
exists |
private java.io.File |
file |
private SerializableFileTime |
lastModified |
private long |
length |
private java.lang.String |
name |
private FileEntry |
parent |
private static long |
serialVersionUID |
Constructor 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)
Constructs 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.
|
(package private) void |
setLastModified(SerializableFileTime lastModified) |
void |
setLength(long length)
Sets the length.
|
void |
setName(java.lang.String name)
Sets the file name.
|
private static final long serialVersionUID
static final FileEntry[] EMPTY_FILE_ENTRY_ARRAY
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 SerializableFileTime lastModified
private long length
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.void setLastModified(SerializableFileTime lastModified)
public void setLength(long length)
length
- the lengthpublic void setName(java.lang.String name)
name
- the file name