Interface DataProtocol
-
- All Known Implementing Classes:
AdditionalAnnotationDataProtocol
,AnnotationDataProtocol
,DeprecatedDataProtocol
,FileDataProtocol
,FTPPathDataProtocol
,FTPURLDataProtocol
,GenomeDataProtocol
,GFFDataProtocol
,GTFDataProtocol
,HDFSPathDataProtocol
,HTTPPathDataProtocol
,HTTPSPathDataProtocol
,HTTPSURLDataProtocol
,HTTPURLDataProtocol
,PathDataProtocol
,StorageDataProtocol
,URLDataProtocol
public interface DataProtocol
This interface define a protocol.- Since:
- 1.0
- Author:
- Laurent Jourdren
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
canDelete()
Test if the delete() method is available with this protocol.boolean
canList()
Test if the list() method is available with this protocol.boolean
canMkdir()
Test if the mkdir() and mkdirs() methods are available with this protocol.boolean
canRead()
Test if source is readable with this protocol.boolean
canRename()
Test if the renameTo() method is available with this protocol.boolean
canSymlink()
Test if the symlink() method is available with this protocol.boolean
canWrite()
Test if source is writable with this protocol.void
delete(DataFile file, boolean recursive)
Delete a file.boolean
exists(DataFile src, boolean followLink)
Test a source exists.InputStream
getData(DataFile src)
Create an InputStream from the source.DataFile
getDataFileParent(DataFile src)
Get the parent source of the source.DataFileMetadata
getMetadata(DataFile src)
Get the metadata for the source.String
getName()
Get Protocol name.File
getSourceAsFile(DataFile src)
Get the underlying File object for the DataFile if the protocol allow it.String
getSourceFilename(String source)
Get the name of the filename that correspond to the source.List<DataFile>
list(DataFile dir)
List a directory.void
mkdir(DataFile dir)
Create a directory.void
mkdirs(DataFile dir)
Create a directory and its parents if not exists.OutputStream
putData(DataFile dest)
Create an OutputStream from the source.void
putData(DataFile src, DataFile dest)
Copy data from a source to a destination sourceOutputStream
putData(DataFile dest, DataFileMetadata md)
Create an OutputStream from the source.void
rename(DataFile file, DataFile dest)
Rename a file.void
symlink(DataFile target, DataFile link)
Create a symbolic link.
-
-
-
Method Detail
-
getName
String getName()
Get Protocol name.- Returns:
- the name of the protocol
-
getSourceFilename
String getSourceFilename(String source)
Get the name of the filename that correspond to the source.- Parameters:
source
- the source- Returns:
- a String with the filename
-
getDataFileParent
DataFile getDataFileParent(DataFile src)
Get the parent source of the source.- Parameters:
src
- source to use- Returns:
- a String with the source of the parent or null if there is parent
-
getData
InputStream getData(DataFile src) throws IOException
Create an InputStream from the source.- Parameters:
src
- source to use- Returns:
- an InputStream
- Throws:
IOException
- if an error occurs while creating the InputStream
-
putData
OutputStream putData(DataFile dest) throws IOException
Create an OutputStream from the source.- Parameters:
dest
- destination to use- Returns:
- an OutputStream
- Throws:
IOException
- if an error occurs while creating the OutputStream
-
putData
OutputStream putData(DataFile dest, DataFileMetadata md) throws IOException
Create an OutputStream from the source.- Parameters:
dest
- source to usemd
- metadata for the stream to write- Returns:
- an OutputStream
- Throws:
IOException
- if an error occurs while creating the OutputStream
-
putData
void putData(DataFile src, DataFile dest) throws IOException
Copy data from a source to a destination source- Parameters:
src
- source sourcedest
- destination source- Throws:
IOException
- if an error occurs while copying data
-
exists
boolean exists(DataFile src, boolean followLink)
Test 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
-
mkdir
void mkdir(DataFile dir) throws IOException
Create a directory.- Parameters:
dir
- directory to create- Throws:
IOException
- if an error occurs while creating the directory
-
mkdirs
void mkdirs(DataFile dir) throws IOException
Create a directory and its parents if not exists.- Parameters:
dir
- directory to create- Throws:
IOException
- if an error occurs while creating the directory
-
symlink
void symlink(DataFile target, DataFile link) throws IOException
Create a symbolic link.- Parameters:
target
- target filelink
- symbolic link file- Throws:
IOException
- if an error occurs while creating the symbolic link
-
delete
void delete(DataFile file, boolean recursive) throws IOException
Delete a file.- Parameters:
file
- file to deleterecursive
- recursive deletion- Throws:
IOException
- if an error occurs while deleting the file
-
list
List<DataFile> list(DataFile dir) throws IOException
List a directory.- Parameters:
dir
- directory to list- Returns:
- a list of DataFile objects
- Throws:
IOException
- if an error occurs while listing the directory
-
rename
void rename(DataFile file, DataFile dest) throws IOException
Rename a file.- Parameters:
file
- the file to renamedest
- the destination file- Throws:
IOException
- if an error occurs while renaming the directory
-
getMetadata
DataFileMetadata getMetadata(DataFile src) throws IOException
Get the metadata for the source.- Parameters:
src
- source to use- Returns:
- always a metadataObject
- Throws:
IOException
- if an error occurs while getting metadata
-
canRead
boolean canRead()
Test if source is readable with this protocol.- Returns:
- true if the source is readable
-
canWrite
boolean canWrite()
Test if source is writable with this protocol.- Returns:
- true if the source is writable
-
canMkdir
boolean canMkdir()
Test if the mkdir() and mkdirs() methods are available with this protocol.- Returns:
- true if mkdir() and mkdirs() are available
-
canSymlink
boolean canSymlink()
Test if the symlink() method is available with this protocol.- Returns:
- true if symlink() is available
-
canDelete
boolean canDelete()
Test if the delete() method is available with this protocol.- Returns:
- true if delete() is available
-
canList
boolean canList()
Test if the list() method is available with this protocol.- Returns:
- true if list() is available
-
canRename
boolean canRename()
Test if the renameTo() method is available with this protocol.- Returns:
- true if renameTo() is available
-
-