public class FileMetaDataImpl extends Object implements FileMetaData
A FileMetaData
implementation.
Constructor and Description |
---|
FileMetaDataImpl(FileMetaData parent,
String name,
FileOwner owner,
FileMode mode,
Date lastModifiedDate)
Creates the meta data of a directory.
|
FileMetaDataImpl(FileMetaData parent,
String name,
FileOwner owner,
FileMode mode,
long length,
Date lastModifiedDate)
Creates the meta data of a regular file.
|
FileMetaDataImpl(FileMetaData parent,
String name,
String targetPath,
FileOwner owner,
FileMode mode,
Date lastModifiedDate)
Creates the meta data of a symbolic link.
|
FileMetaDataImpl(String path,
String name,
FileOwner owner,
FileMode mode,
Date lastModifiedDate)
Creates the meta data of a directory.
|
FileMetaDataImpl(String path,
String name,
FileOwner owner,
FileMode mode,
long length,
Date lastModifiedDate)
Creates the meta data of a regular file.
|
FileMetaDataImpl(String path,
String name,
String targetPath,
FileOwner owner,
FileMode mode,
Date lastModifiedDate)
Creates the meta data of a symbolic link.
|
Modifier and Type | Method and Description |
---|---|
static FileMetaData |
createDirectoryMetaData(String absolutePath,
FileOwner owner,
FileMode mode,
Date lastModifiedDate)
Creates the meta data for a directory.
|
static FileMetaData |
createFileMetaData(String absolutePath,
FileOwner owner,
FileMode mode,
long length,
Date lastModifiedDate)
Creates the meta data for a regular file.
|
static FileMetaData |
createSymbolicLinkMetaData(String absolutePath,
String targetPath,
FileOwner owner,
FileMode mode,
Date lastModifiedDate)
Creates the meta data for a symbolic link.
|
String |
getAbsolutePath()
Returns the absolute path consisting of the path and the name of the
file.
|
Date |
getLastModifiedDate()
Returns the timestamp of the last modification.
|
long |
getLength()
Returns the of the file in bytes.
|
FileMode |
getMode()
Returns the mode of the file.
|
String |
getModeAsText()
Returns the textual representation of the mode including the directory
flag.
|
String |
getName()
Returns the name of the file.
|
FileOwner |
getOwner()
Returns the owner of the file.
|
String |
getPath()
Returns the path of the file excluding the name.
|
String |
getTargetPath()
Returns the target path of the symbolic link.
|
boolean |
isDirectory()
Returns the flag if the file is a directory.
|
boolean |
isFile()
Returns the flag if the file is a regular file.
|
boolean |
isSymbolicLink()
Returns the flag if the file is a symbolic link.
|
public FileMetaDataImpl(String path, String name, FileOwner owner, FileMode mode, Date lastModifiedDate)
Creates the meta data of a directory.
path
- The path of the file excluding the name.name
- The name of the file.owner
- The owner of the file.mode
- The mode of the file.lastModifiedDate
- The timestamp of the last modification.IllegalArgumentException
- If any of the parameters are null
, the path is
empty, the name contains a slash or is empty also the path is
not "/".public FileMetaDataImpl(FileMetaData parent, String name, FileOwner owner, FileMode mode, Date lastModifiedDate)
Creates the meta data of a directory.
parent
- The parent directory.name
- The name of the file.owner
- The owner of the file.mode
- The mode of the file.lastModifiedDate
- The timestamp of the last modification.IllegalArgumentException
- If any of the parameters are null
, the parent is
not a directory, the name contains a slash or is empty.public FileMetaDataImpl(String path, String name, FileOwner owner, FileMode mode, long length, Date lastModifiedDate)
Creates the meta data of a regular file.
path
- The path of the file excluding the name.name
- The name of the file.owner
- The owner of the file.mode
- The mode of the file.length
- The length of the file or -1
, if the length is
unknown.lastModifiedDate
- The timestamp of the last modification.IllegalArgumentException
- If any of the parameters are null
, the path is
empty, the name contains a slash, the name is empty or the
length is less than -1
.public FileMetaDataImpl(FileMetaData parent, String name, FileOwner owner, FileMode mode, long length, Date lastModifiedDate)
Creates the meta data of a regular file.
parent
- The parent directory.name
- The name of the file.owner
- The owner of the file.mode
- The mode of the file.length
- The length of the file or -1
, if the length is
unknown.lastModifiedDate
- The timestamp of the last modification.IllegalArgumentException
- If any of the parameters are null
, the parent is
not a directory, the name contains a slash or the length is
less than -1
.public FileMetaDataImpl(String path, String name, String targetPath, FileOwner owner, FileMode mode, Date lastModifiedDate)
Creates the meta data of a symbolic link.
path
- The path of the file excluding the name.name
- The name of the file.targetPath
- The target path of the symbolic link.owner
- The owner of the file.mode
- The mode of the file.lastModifiedDate
- The timestamp of the last modification.IllegalArgumentException
- If any of the parameters are null
, the path is
empty, the name contains a slash, the path is empty or if the
target path is empty.public FileMetaDataImpl(FileMetaData parent, String name, String targetPath, FileOwner owner, FileMode mode, Date lastModifiedDate)
Creates the meta data of a symbolic link.
parent
- The parent directory.name
- The name of the file.targetPath
- The target path of the symbolic link.owner
- The owner of the file.mode
- The mode of the file.lastModifiedDate
- The timestamp of the last modification.IllegalArgumentException
- If any of the parameters are null
, the parent is
not a directory, the name contains a slash, the name is empty
or the target path is empty.public String getPath()
FileMetaData
Returns the path of the file excluding the name.
getPath
in interface FileMetaData
FileMetaData.getName()
,
FileMetaData.getAbsolutePath()
public String getName()
FileMetaData
Returns the name of the file.
getName
in interface FileMetaData
FileMetaData.getPath()
,
FileMetaData.getAbsolutePath()
public String getAbsolutePath()
FileMetaData
Returns the absolute path consisting of the path and the name of the file.
If the file is a directory a trailing slash will be added.
getAbsolutePath
in interface FileMetaData
FileMetaData.getPath()
,
FileMetaData.getName()
public boolean isFile()
FileMetaData
Returns the flag if the file is a regular file.
A symbolic link is also a file.
isFile
in interface FileMetaData
true
, if the file is a regular file,
false
otherwise.FileMetaData.isDirectory()
,
FileMetaData.isSymbolicLink()
public boolean isDirectory()
FileMetaData
Returns the flag if the file is a directory.
isDirectory
in interface FileMetaData
true
, if the file is a directory,
false
otherwise.FileMetaData.isFile()
public boolean isSymbolicLink()
FileMetaData
Returns the flag if the file is a symbolic link.
isSymbolicLink
in interface FileMetaData
true
, if the file is a symbolic link,
false
otherwise.FileMetaData.isFile()
,
FileMetaData.getTargetPath()
public String getTargetPath()
FileMetaData
Returns the target path of the symbolic link.
getTargetPath
in interface FileMetaData
null
, if this meta data does not
represent a symbolic link.FileMetaData.isSymbolicLink()
public FileOwner getOwner()
FileMetaData
Returns the owner of the file.
getOwner
in interface FileMetaData
public FileMode getMode()
FileMetaData
Returns the mode of the file.
getMode
in interface FileMetaData
public String getModeAsText()
FileMetaData
Returns the textual representation of the mode including the directory flag.
The returned value may look like this:
drwxrwxrwx
or like this:
----------
getModeAsText
in interface FileMetaData
FileMode.getText()
public long getLength()
FileMetaData
Returns the of the file in bytes.
getLength
in interface FileMetaData
-1
, if the length is unknown or the
file is not a regular file.public Date getLastModifiedDate()
FileMetaData
Returns the timestamp of the last modification.
getLastModifiedDate
in interface FileMetaData
public static FileMetaData createDirectoryMetaData(String absolutePath, FileOwner owner, FileMode mode, Date lastModifiedDate)
Creates the meta data for a directory.
absolutePath
- The absolute path.owner
- The owner of the file.mode
- The mode of the file.lastModifiedDate
- The timestamp of the last modification.IllegalArgumentException
- If any of the parameters are null
or the
absolute path is empty.public static FileMetaData createFileMetaData(String absolutePath, FileOwner owner, FileMode mode, long length, Date lastModifiedDate)
Creates the meta data for a regular file.
absolutePath
- The absolute path.owner
- The owner of the file.mode
- The mode of the file.length
- The length of the file or -1
, if the length is
unknown.lastModifiedDate
- The timestamp of the last modification.IllegalArgumentException
- If any of the parameters are null
, the absolute
path is empty or the length is less than -1
.public static FileMetaData createSymbolicLinkMetaData(String absolutePath, String targetPath, FileOwner owner, FileMode mode, Date lastModifiedDate)
Creates the meta data for a symbolic link.
absolutePath
- The absolute path.targetPath
- The target path of the symbolic link.owner
- The owner of the symbolic link.mode
- The mode of the symbolic link.lastModifiedDate
- The timestamp of the last modification.IllegalArgumentException
- If any of the parameters are null
, the absolute
path is empty or the target is empty.Copyright © 2015–2019. All rights reserved.