Class DataFile
java.lang.Object
fr.ens.biologie.genomique.eoulsan.data.DataFile
- All Implemented Interfaces:
Serializable,Comparable<DataFile>
This class define a DataFile.
- Since:
- 1.0
- Author:
- Laurent Jourdren
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe separator char ('/') as a String.static final charThe separator char ('/'). -
Constructor Summary
ConstructorsConstructorDescriptionPublic constructor.Public constructor.Public constructor.Public constructor.Public constructor.Public constructor.Public constructor. -
Method Summary
Modifier and TypeMethodDescriptionintvoidCopy this DataFile in a other DataFile.create()Create an OutputStream for the DataFile.voiddelete()Delete the DataFile.voiddelete(boolean recursive) Delete the DataFile.booleanbooleanexists()Check if this DataFile exists.booleanexists(boolean followLink) Check if this DataFile exists.Get the base name of this DataFile without all its extensions.Get the compression extension of this DataFile.fr.ens.biologie.genomique.kenetre.io.CompressionTypeGet the compression Type of this DataFile.Get the DataFormat of the DataFile.Get the extension of this DataFile without compression extension.Get the base name of this DataFile with all its extensions (include compression extension).Get the metadata for this DataFile.getName()Get the name of this DataFile.Get the parent of this DataFile.Get the protocol of this DataFile.Get the prefix of the protocol in the source name of the DataFile.Get the source of this DataFile.inthashCode()booleanTest if the DataFile use the defaultProtocol.list()List the content of a directory.voidmkdir()Create a directory with the path of the DataFile.voidmkdirs()Create a directory and its parents if not exists with the path of the DataFile.open()Create an InputStream for the DataFile.Create an OutputStream for the DataFile.rawOpen()Create an InputStream for the DataFile.voidRename the DataFile.voidCreate a symbolic link that target is the current file.voidCreate a symbolic link that target is the current file.Convert the the DataFile to a absolute DataFile.toFile()Convert the DataFile object to File object if the underlying protocol allow it.toPath()Convert the DataFile object to Path object if the underlying protocol allow it.Convert the the DataFile to a DataFile where all the indirection has been solved.toString()toUri()Convert the DataFile object to an URI.
-
Field Details
-
separatorChar
public static final char separatorCharThe separator char ('/').- See Also:
-
separator
The separator char ('/') as a String.- See Also:
-
-
Constructor Details
-
DataFile
Public constructor.- Parameters:
source- the source of the DataFile
-
DataFile
Public constructor.- Parameters:
parentFile- the parent file of the DataFilefilename- the filename of the DataFile
-
DataFile
Public constructor.- Parameters:
parentFile- the parent file of the DataFilefilename- the filename of the DataFile
-
DataFile
Public constructor.- Parameters:
parentPath- the parent file of the DataFilefilename- the filename of the DataFile
-
DataFile
Public constructor.- Parameters:
file- the source file of the DataFile
-
DataFile
Public constructor.- Parameters:
path- the source path of the DataFile
-
DataFile
Public constructor.- Parameters:
uri- the URI of the DataFile
-
-
Method Details
-
getSource
Get the source of this DataFile.- Returns:
- a String with the source of this DataFile
-
getName
Get the name of this DataFile.- Returns:
- a String with the name of this DataFile
-
getBasename
Get the base name of this DataFile without all its extensions. The result is computed with the output of the getName() method.- Returns:
- a String with the base name of this DataFile
-
getExtension
Get the extension of this DataFile without compression extension. The result is computed with the output of the getName() method.- Returns:
- a String with the extension of this DataFile. The result String is empty if there is no extension
-
getFullExtension
Get the base name of this DataFile with all its extensions (include compression extension). The result is computed with the output of the getName() method.- Returns:
- a String with the base name of this DataFile. The result String is empty if there is no extension
-
getCompressionExtension
Get the compression extension of this DataFile. The result is computed with the output of the getName() method.- Returns:
- a String with the compression extension of this DataFile. The result String is empty if there is no compression extension
-
getCompressionType
public fr.ens.biologie.genomique.kenetre.io.CompressionType getCompressionType()Get the compression Type of this DataFile. The result is computed with the output of the getName() method.- Returns:
- a CompressionType object
-
getDataFormat
Get the DataFormat of the DataFile. The result is computed with the output of the getName() method. This is an alias for getDataFormatFromFilename() of the DataFormatRegistry.- Returns:
- the DataFormat of the DataFile
-
getParent
Get the parent of this DataFile.- Returns:
- the parent DataFile
- Throws:
IOException- if an error occurs while the parent
-
getProtocol
Get the protocol of this DataFile.- Returns:
- a DataProtocol
- Throws:
IOException- if the protocol is unknown
-
getMetaData
Get the metadata for this DataFile.- Returns:
- a DataFileMetadata with all metadata information about this DataFile
- Throws:
IOException- if the protocol is unknown or if the DataFile does not exists
-
getProtocolPrefixInSource
Get the prefix of the protocol in the source name of the DataFile.- Returns:
- the prefix of the protocol
-
isLocalFile
public boolean isLocalFile()Test if the DataFile use the defaultProtocol.- Returns:
- true if the DataFile use the default protocol
-
toFile
Convert the DataFile object to File object if the underlying protocol allow it. Only local protocol can return a value.- Returns:
- a File object or null if the underlying protocol does not allow it
-
toPath
Convert the DataFile object to Path object if the underlying protocol allow it.- Returns:
- a Path object or null if the underlying protocol does not allow it
-
toUri
Convert the DataFile object to an URI.- Returns:
- an URI object or null if the DataFile cannot be converted into URI
-
toRealDataFile
Convert the the DataFile to a DataFile where all the indirection has been solved. This method use the JDK Path.toRealPath() method. This method has only an effect for local DataFiles.- Returns:
- a DataFile
-
toAbsoluteDataFile
Convert the the DataFile to a absolute DataFile. This method use the JDK File.getAbsoluteFile() method. This method has only an effect for local DataFiles.- Returns:
- a DataFile
-
create
Create an OutputStream for the DataFile. If the DataFile is declared as compressed by its content type or its extension, the output stream will be automatically compress data.- Returns:
- an OutputStream object
- Throws:
IOException- if an error occurs while creating the DataFile
-
rawCreate
Create an OutputStream for the DataFile. The output stream will not automatically compress data.- Returns:
- an OutputStream object
- Throws:
IOException- if an error occurs while creating the DataFile
-
open
Create an InputStream for the DataFile. If the DataFile is compressed, the input stream will be automatically uncompress.- Returns:
- an InputStream object
- Throws:
IOException- if an error occurs while opening the DataFile
-
rawOpen
Create an InputStream for the DataFile. The input stream will not automatically uncompress data.- Returns:
- an InputStream object
- Throws:
IOException- if an error occurs while opening the DataFile
-
copyTo
Copy this DataFile in a other DataFile.- Parameters:
dest- destination DataFile- Throws:
IOException- if an error occurs while copying the DataFile
-
exists
public boolean exists()Check if this DataFile exists.- Returns:
- true if this DataFile exists
-
exists
public boolean exists(boolean followLink) Check if this DataFile exists.- Parameters:
followLink- follow the link target if the file is a symbolic link- Returns:
- true if this DataFile exists
-
mkdir
Create a directory with the path of the DataFile.- Throws:
IOException- if an error occurs while creating the directory
-
mkdirs
Create a directory and its parents if not exists with the path of the DataFile.- Throws:
IOException- if an error occurs while creating the directory
-
symlink
Create a symbolic link that target is the current file.- Parameters:
link- symbolic file- Throws:
IOException- if an error occurs while creating the symbolic link
-
symlink
Create a symbolic link that target is the current file.- Parameters:
link- symbolic filerelativize- relativize the link target path- Throws:
IOException- if an error occurs while creating the symbolic link
-
delete
Delete the DataFile.- Throws:
IOException- if an error occurs while deleting the DataFile
-
delete
Delete the DataFile.- Parameters:
recursive- recursive deletion- Throws:
IOException- if an error occurs while deleting the DataFile
-
list
List the content of a directory.- Returns:
- a List with the content of the directory
- Throws:
IOException- if an error occurs while listing the directory
-
renameTo
Rename the DataFile.- Parameters:
dest- destination DataFile- Throws:
IOException- if an error occurs while renaming the DataFile
-
compareTo
- Specified by:
compareToin interfaceComparable<DataFile>
-
equals
-
hashCode
public int hashCode() -
toString
-