Class FileDataProtocol
java.lang.Object
fr.ens.biologie.genomique.eoulsan.data.protocols.FileDataProtocol
- All Implemented Interfaces:
DataProtocol
This class implements a File Protocol.
- Since:
- 1.0
- Author:
- Laurent Jourdren
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTest if the delete() method is available with this protocol.booleancanList()Test if the list() method is available with this protocol.booleancanMkdir()Test if the mkdir() and mkdirs() methods are available with this protocol.booleancanRead()Test if source is readable with this protocol.booleanTest if the renameTo() method is available with this protocol.booleanTest if the symlink() method is available with this protocol.booleancanWrite()Test if source is writable with this protocol.voidDelete a file.booleanTest a source exists.Create an InputStream from the source.Get the parent source of the source.getMetadata(DataFile src) Get the metadata for the source.getName()Get Protocol name.getSourceAsFile(DataFile dataFile) Get the underlying File object for the DataFile if the protocol allow it.getSourceAsPath(DataFile dataFile) Get the underlying File object for the DataFile if the protocol allow it.getSourceFilename(String source) Get the name of the filename that correspond to the source.List a directory.voidCreate a directory.voidCreate a directory and its parents if not exists.Create an OutputStream from the source.voidCopy data from a source to a destination sourceputData(DataFile src, DataFileMetadata md) Create an OutputStream from the source.voidRename a file.voidCreate a symbolic link.
-
Field Details
-
PROTOCOL_NAME
Protocol name.- See Also:
-
-
Constructor Details
-
FileDataProtocol
public FileDataProtocol()
-
-
Method Details
-
getName
Description copied from interface:DataProtocolGet Protocol name.- Returns:
- the name of the protocol
-
getSourceAsPath
Description copied from interface:DataProtocolGet the underlying File object for the DataFile if the protocol allow it.- Specified by:
getSourceAsPathin interfaceDataProtocol- Parameters:
dataFile- source DataFile- Returns:
- a File object or null if the protocol does not allow it
-
getSourceAsFile
Description copied from interface:DataProtocolGet the underlying File object for the DataFile if the protocol allow it.- Specified by:
getSourceAsFilein interfaceDataProtocol- Parameters:
dataFile- source DataFile- Returns:
- a File object or null if the protocol does not allow it
-
getData
Description copied from interface:DataProtocolCreate an InputStream from the source.- Parameters:
src- source to use- Returns:
- an InputStream
- Throws:
IOException- if an error occurs while creating the InputStream
-
putData
Description copied from interface:DataProtocolCreate an OutputStream from the source.- Parameters:
src- destination to use- Returns:
- an OutputStream
- Throws:
IOException- if an error occurs while creating the OutputStream
-
getMetadata
Description copied from interface:DataProtocolGet the metadata for the source.- Parameters:
src- source to use- Returns:
- always a metadataObject
- Throws:
IOException- if an error occurs while getting metadata
-
exists
Description copied from interface:DataProtocolTest a source exists.- Parameters:
src- source to usefollowLink- if the source is a symbolic file and followLink is true, it will check if the symbolic link target exists instead of the link- Returns:
- true if the source exists
-
canRead
public boolean canRead()Description copied from interface:DataProtocolTest if source is readable with this protocol.- Returns:
- true if the source is readable
-
canWrite
public boolean canWrite()Description copied from interface:DataProtocolTest if source is writable with this protocol.- Returns:
- true if the source is writable
-
mkdir
Description copied from interface:DataProtocolCreate a directory.- Specified by:
mkdirin interfaceDataProtocol- Parameters:
dir- directory to create- Throws:
IOException- if an error occurs while creating the directory
-
mkdirs
Description copied from interface:DataProtocolCreate a directory and its parents if not exists.- Specified by:
mkdirsin interfaceDataProtocol- Parameters:
dir- directory to create- Throws:
IOException- if an error occurs while creating the directory
-
canMkdir
public boolean canMkdir()Description copied from interface:DataProtocolTest if the mkdir() and mkdirs() methods are available with this protocol.- Specified by:
canMkdirin interfaceDataProtocol- Returns:
- true if mkdir() and mkdirs() are available
-
symlink
Description copied from interface:DataProtocolCreate a symbolic link.- Specified by:
symlinkin interfaceDataProtocol- Parameters:
target- target filelink- symbolic link file- Throws:
IOException- if an error occurs while creating the symbolic link
-
canSymlink
public boolean canSymlink()Description copied from interface:DataProtocolTest if the symlink() method is available with this protocol.- Specified by:
canSymlinkin interfaceDataProtocol- Returns:
- true if symlink() is available
-
delete
Description copied from interface:DataProtocolDelete a file.- Specified by:
deletein interfaceDataProtocol- Parameters:
file- file to deleterecursive- recursive deletion- Throws:
IOException- if an error occurs while deleting the file
-
canDelete
public boolean canDelete()Description copied from interface:DataProtocolTest if the delete() method is available with this protocol.- Specified by:
canDeletein interfaceDataProtocol- Returns:
- true if delete() is available
-
list
Description copied from interface:DataProtocolList a directory.- Specified by:
listin interfaceDataProtocol- Parameters:
file- directory to list- Returns:
- a list of DataFile objects
- Throws:
IOException- if an error occurs while listing the directory
-
canList
public boolean canList()Description copied from interface:DataProtocolTest if the list() method is available with this protocol.- Specified by:
canListin interfaceDataProtocol- Returns:
- true if list() is available
-
rename
Description copied from interface:DataProtocolRename a file.- Specified by:
renamein interfaceDataProtocol- Parameters:
src- the file to renamedest- the destination file- Throws:
IOException- if an error occurs while renaming the directory
-
canRename
public boolean canRename()Description copied from interface:DataProtocolTest if the renameTo() method is available with this protocol.- Specified by:
canRenamein interfaceDataProtocol- Returns:
- true if renameTo() is available
-
getSourceFilename
Description copied from interface:DataProtocolGet the name of the filename that correspond to the source.- Specified by:
getSourceFilenamein interfaceDataProtocol- Parameters:
source- the source- Returns:
- a String with the filename
-
getDataFileParent
Description copied from interface:DataProtocolGet the parent source of the source.- Specified by:
getDataFileParentin interfaceDataProtocol- Parameters:
src- source to use- Returns:
- a String with the source of the parent or null if there is parent
-
putData
Description copied from interface:DataProtocolCreate an OutputStream from the source.- Specified by:
putDatain interfaceDataProtocol- Parameters:
src- source to usemd- metadata for the stream to write- Returns:
- an OutputStream
- Throws:
IOException- if an error occurs while creating the OutputStream
-
putData
Description copied from interface:DataProtocolCopy data from a source to a destination source- Specified by:
putDatain interfaceDataProtocol- Parameters:
src- source sourcedest- destination source- Throws:
IOException- if an error occurs while copying data
-