Package org.apache.commons.io.monitor
Class FileEntry
java.lang.Object
org.apache.commons.io.monitor.FileEntry
- All Implemented Interfaces:
- Serializable
The state of a file or directory, capturing the following 
File attributes at a point in time.
 - File Name (see File.getName())
- Exists - whether the file exists or not (see File.exists())
- Directory - whether the file is a directory or not (see File.isDirectory())
- Last Modified Date/Time (see FileUtils.lastModifiedUnchecked(File))
- Length (see File.length()) - directories treated as zero
- Children - contents of a directory (see File.listFiles(java.io.FileFilter))
Custom Implementations
 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.
 
Deprecating Serialization
Serialization is deprecated and will be removed in 3.0.
- Since:
- 2.0
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionGets the directory's files.getFile()Gets the file being monitored.longGets the last modified time from the last time it was checked.Gets the last modified time from the last time it was checked.longGets the length.intgetLevel()Gets the levelgetName()Gets the file name.Gets the parent entry.booleanTests whether the file is a directory or not.booleanisExists()Tests whether the file existed the last time it was checked.newChildInstance(File file) Constructs a new child instance.booleanRefreshes the attributes from theFile, indicating whether the file has changed.voidsetChildren(FileEntry... children) Sets the directory's files.voidsetDirectory(boolean directory) Sets whether the file is a directory or not.voidsetExists(boolean exists) Sets whether the file existed the last time it was checked.voidsetLastModified(long lastModified) Sets the last modified time from the last time it was checked.voidsetLastModified(FileTime lastModified) Sets the last modified time from the last time it was checked.voidsetLength(long length) Sets the length.voidSets the file name.
- 
Constructor Details
- 
Method Details- 
getChildrenGets the directory's files.- Returns:
- This directory's files or an empty array if the file is not a directory or the directory is empty
 
- 
getFileGets the file being monitored.- Returns:
- the file being monitored
 
- 
getLastModifiedGets the last modified time from the last time it was checked.- Returns:
- the last modified time in milliseconds.
 
- 
getLastModifiedFileTimeGets the last modified time from the last time it was checked.- Returns:
- the last modified time.
- Since:
- 2.12.0
 
- 
getLengthGets the length.- Returns:
- the length
 
- 
getLevelGets the level- Returns:
- the level
 
- 
getNameGets the file name.- Returns:
- the file name
 
- 
getParentGets the parent entry.- Returns:
- the parent entry
 
- 
isDirectoryTests whether the file is a directory or not.- Returns:
- whether the file is a directory or not
 
- 
isExistsTests whether the file existed the last time it was checked.- Returns:
- whether the file existed
 
- 
newChildInstanceConstructs a new child instance.Custom implementations should override this method to return a new instance of the appropriate type. - Parameters:
- file- The child file
- Returns:
- a new child instance
 
- 
refreshRefreshes the attributes from theFile, indicating whether the file has changed.This implementation refreshes the name,exists,directory,lastModifiedandlengthproperties.The exists,directory,lastModifiedandlengthproperties are compared for changes- Parameters:
- file- the file instance to compare to
- Returns:
- trueif the file has changed, otherwise- false
 
- 
setChildrenSets the directory's files.- Parameters:
- children- This directory's files, may be null
 
- 
setDirectorySets whether the file is a directory or not.- Parameters:
- directory- whether the file is a directory or not
 
- 
setExistsSets whether the file existed the last time it was checked.- Parameters:
- exists- whether the file exists or not
 
- 
setLastModifiedSets the last modified time from the last time it was checked.- Parameters:
- lastModified- The last modified time.
- Since:
- 2.12.0
 
- 
setLastModifiedSets the last modified time from the last time it was checked.- Parameters:
- lastModified- The last modified time in milliseconds.
 
- 
setLengthSets the length.- Parameters:
- length- the length
 
- 
setNameSets the file name.- Parameters:
- name- the file name
 
 
-