Package psidev.psi.mi.jami.commons
Class MIFileAnalyzer
- java.lang.Object
-
- psidev.psi.mi.jami.commons.MIFileAnalyzer
-
public class MIFileAnalyzer extends Object
The file source analyzer will recognise what kind of molecular interaction source a given file is from.- Since:
01/03/13
- Version:
- $Id$
- Author:
- Marine Dumousseau (marine@ebi.ac.uk)
-
-
Field Summary
Fields Modifier and Type Field Description static String
CSV_EXTENSION
ConstantCSV_EXTENSION=".csv"
static String
MITAB_25_TITLE
ConstantMITAB_25_TITLE="#ID(s) interactor A\tID(s) interactor B"{trunked}
static String
TSV_EXTENSION
ConstantTSV_EXTENSION=".tsv"
static String
TXT_EXTENSION
ConstantTXT_EXTENSION=".txt"
static String
XML_EXTENSION
ConstantXML_EXTENSION=".xml"
-
Constructor Summary
Constructors Constructor Description MIFileAnalyzer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OpenedInputStream
extractMIFileTypeAndCopiedInputStream(Reader reader)
Recognize the MIFileDataSource from the reader.OpenedInputStream
extractMIFileTypeFrom(InputStream stream)
Recognize the MIFileDataSource from the inputStream.MIFileType
identifyMIFileTypeFor(File file)
Recognize the MIFileDataSource from the file signature and first line.MIFileType
identifyMIFileTypeFor(InputStream stream)
Recognize the MIFileDataSource from the inputStream.MIFileType
identifyMIFileTypeFor(Reader reader)
Recognize the MIFileDataSource from the reader.boolean
isFileSignature(File file, String signature)
isFileSignature.
-
-
-
Field Detail
-
XML_EXTENSION
public static String XML_EXTENSION
ConstantXML_EXTENSION=".xml"
-
TXT_EXTENSION
public static String TXT_EXTENSION
ConstantTXT_EXTENSION=".txt"
-
CSV_EXTENSION
public static String CSV_EXTENSION
ConstantCSV_EXTENSION=".csv"
-
TSV_EXTENSION
public static String TSV_EXTENSION
ConstantTSV_EXTENSION=".tsv"
-
MITAB_25_TITLE
public static final String MITAB_25_TITLE
ConstantMITAB_25_TITLE="#ID(s) interactor A\tID(s) interactor B"{trunked}
- See Also:
- Constant Field Values
-
-
Method Detail
-
identifyMIFileTypeFor
public MIFileType identifyMIFileTypeFor(File file) throws IOException
Recognize the MIFileDataSource from the file signature and first line. It will recognize psi25-xml and mitab files. If it is neither of them, it will return MIFileType.other- Parameters:
file
- : the file to analyze- Returns:
- the MIFileType that matches the file
- Throws:
IOException
- if any.
-
extractMIFileTypeFrom
public OpenedInputStream extractMIFileTypeFrom(InputStream stream) throws IOException
Recognize the MIFileDataSource from the inputStream. Because it needs to open the inputStream to analyze its content, it will return an OpenedInputStream which contains the MIFileType and a PushbackReader which should be used instead of the given 'stream' which have been opened. As for a normal InputStream, it needs to be closed after being used. It will recognize psi25-xml and mitab files. If it is neither of them, it will return an OpenedInputStream MIFileType.other- Parameters:
stream
- : the stream to recognize- Returns:
- a
OpenedInputStream
object. - Throws:
IOException
- if any.
-
extractMIFileTypeAndCopiedInputStream
public OpenedInputStream extractMIFileTypeAndCopiedInputStream(Reader reader) throws IOException
Recognize the MIFileDataSource from the reader. Because it needs to open the reader to analyze its content, it will return an OpenedInputStream which contains the MIFileType and a PushbackReader which should be used instead of the given 'stream' which have been opened.. As for a normal InputStream, it needs to be closed after being used. It will recognize psi25-xml and mitab files. If it is neither of them, it will return an OpenedInputStream MIFileType.other- Parameters:
reader
- : the reader for the source to recognize- Returns:
- a
OpenedInputStream
object. - Throws:
IOException
- if any.
-
identifyMIFileTypeFor
public MIFileType identifyMIFileTypeFor(InputStream stream) throws IOException
Recognize the MIFileDataSource from the inputStream. Because it needs to open the inputStream to analyze its content, it will consume the provided stream. It will recognize psi25-xml and mitab files. If it is neither of them, it will return a MIFileType.other- Parameters:
stream
- : the stream to recognize- Returns:
- a
MIFileType
object. - Throws:
IOException
- if any.
-
identifyMIFileTypeFor
public MIFileType identifyMIFileTypeFor(Reader reader) throws IOException
Recognize the MIFileDataSource from the reader. Because it needs to read the first line to analyze its content, it will consume the provided reader. It does not need a BufferedReader as it creates a new BufferedReader from this reader It will recognize psi25-xml and mitab files. If it is neither of them, it will return a MIFileType.other- Parameters:
reader
- : the reader for the source to recognize- Returns:
- a
MIFileType
object. - Throws:
IOException
- if any.
-
-