Class StorageDataProtocol
- java.lang.Object
-
- fr.ens.biologie.genomique.eoulsan.data.protocols.StorageDataProtocol
-
- All Implemented Interfaces:
DataProtocol
- Direct Known Subclasses:
AdditionalAnnotationDataProtocol,GenomeDataProtocol,GFFDataProtocol,GTFDataProtocol
public abstract class StorageDataProtocol extends Object
This abstract class define a storage protocol. It is useful to easily access common resources like genomes or annotations.- Since:
- 1.1
- Author:
- Laurent Jourdren
-
-
Constructor Summary
Constructors Constructor Description StorageDataProtocol()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancanDelete()Test 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.booleancanRename()Test if the renameTo() method is available with this protocol.booleancanSymlink()Test if the symlink() method is available with this protocol.booleancanWrite()Test if source is writable with this protocol.voiddelete(DataFile file, boolean recursive)Delete a file.booleanexists(DataFile src, boolean followLink)Test a source exists.protected abstract StringgetBasePath()Get the path where searching the files.InputStreamgetData(DataFile src)Create an InputStream from the source.DataFilegetDataFileParent(DataFile src)Get the parent source of the source.protected StringgetExtension()Get the file extensions of the files to search.protected List<String>getExtensions()Get the list of the file extensions of the files to search.DataFileMetadatagetMetadata(DataFile src)Get the metadata for the source.FilegetSourceAsFile(DataFile src)Get the underlying File object for the DataFile if the protocol allow it.StringgetSourceFilename(String source)Get the name of the filename that correspond to the source.DataFilegetUnderLyingData(DataFile src)Get the underlying Data.List<DataFile>list(DataFile file)List a directory.voidmkdir(DataFile dir)Create a directory.voidmkdirs(DataFile dir)Create a directory and its parents if not exists.OutputStreamputData(DataFile dest)Create an OutputStream from the source.voidputData(DataFile src, DataFile dest)Copy data from a source to a destination sourceOutputStreamputData(DataFile src, DataFileMetadata md)Create an OutputStream from the source.voidrename(DataFile oldName, DataFile newName)Rename a file.voidsymlink(DataFile target, DataFile link)Create a symbolic link.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fr.ens.biologie.genomique.eoulsan.data.protocols.DataProtocol
getName
-
-
-
-
Method Detail
-
getBasePath
protected abstract String getBasePath()
Get the path where searching the files.- Returns:
- a string with the path where search the files
-
getExtension
protected String getExtension()
Get the file extensions of the files to search.- Returns:
- a string with file extension of the files to search
-
getExtensions
protected List<String> getExtensions()
Get the list of the file extensions of the files to search.- Returns:
- a list with file extensions of the files to search
-
getData
public InputStream getData(DataFile src) throws IOException
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
public OutputStream putData(DataFile dest) throws IOException
Description copied from interface:DataProtocolCreate an OutputStream from the source.- Parameters:
dest- destination to use- Returns:
- an OutputStream
- Throws:
IOException- if an error occurs while creating the OutputStream
-
exists
public boolean exists(DataFile src, boolean followLink)
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
-
getMetadata
public DataFileMetadata getMetadata(DataFile src) throws IOException
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
-
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
-
getSourceAsFile
public File getSourceAsFile(DataFile src)
Description copied from interface:DataProtocolGet the underlying File object for the DataFile if the protocol allow it.- Specified by:
getSourceAsFilein interfaceDataProtocol- Returns:
- a File object or null if the protocol does not allow it
-
getUnderLyingData
public DataFile getUnderLyingData(DataFile src) throws IOException
Get the underlying Data.- Parameters:
src- source to use- Returns:
- a the underlying DataFile
- Throws:
IOException- if an error occurs while getting the underlying DataFile
-
getSourceFilename
public String getSourceFilename(String source)
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
public DataFile getDataFileParent(DataFile src)
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
public OutputStream putData(DataFile src, DataFileMetadata md) throws IOException
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
public void putData(DataFile src, DataFile dest) throws IOException
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
-
mkdir
public void mkdir(DataFile dir) throws IOException
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
public void mkdirs(DataFile dir) throws IOException
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
public void symlink(DataFile target, DataFile link) throws IOException
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
public void delete(DataFile file, boolean recursive) throws IOException
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
public List<DataFile> list(DataFile file) throws IOException
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
-
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
-
rename
public void rename(DataFile oldName, DataFile newName) throws IOException
Description copied from interface:DataProtocolRename a file.- Specified by:
renamein interfaceDataProtocol- Parameters:
oldName- the file to renamenewName- the destination file- Throws:
IOException- if an error occurs while renaming the directory
-
-