Package psidev.psi.mi.jami.tab.io.writer
Class AbstractMitabWriter<T extends Interaction,B extends BinaryInteraction,P extends Participant>
- java.lang.Object
-
- psidev.psi.mi.jami.tab.io.writer.AbstractMitabWriter<T,B,P>
-
- All Implemented Interfaces:
InteractionWriter<T>
- Direct Known Subclasses:
LightMitab25Writer,Mitab25EvidenceWriter,Mitab25EvidenceWriter,Mitab25ModelledWriter,Mitab25ModelledWriter,Mitab25Writer,Mitab25Writer
public abstract class AbstractMitabWriter<T extends Interaction,B extends BinaryInteraction,P extends Participant> extends Object implements InteractionWriter<T>
Abstract writer for Mitab 2.5. The general options when calling methodinitialiseContext(java.util.Map<java.lang.String, java.lang.Object>)are : - output_file_key : File. Specifies the file where to write - output_stream_key : OutputStream. Specifies the stream where to write - output_writer_key : Writer. Specifies the writer. If these three options are given, output_file_key will take priority, then output_stream_key an finally output_writer_key. At leats one of these options should be provided when initialising the context of the writer - complex_expansion_key : ComplexExpansionMethod. Specifies the ComplexExpansion object to use. By default, it is SpokeExpansion if nothing is specified - mitab_header_key : Boolean. Specifies if the writer should write the MITAB header when starting to write or not- Since:
11/06/13
- Version:
- $Id$
- Author:
- Marine Dumousseau (marine@ebi.ac.uk)
-
-
Constructor Summary
Constructors Constructor Description AbstractMitabWriter()Constructor for AbstractMitabWriter.AbstractMitabWriter(File file)Constructor for AbstractMitabWriter.AbstractMitabWriter(File file, ComplexExpansionMethod<T,B> expansionMethod)Constructor for AbstractMitabWriter.AbstractMitabWriter(OutputStream output)Constructor for AbstractMitabWriter.AbstractMitabWriter(OutputStream output, ComplexExpansionMethod<T,B> expansionMethod)Constructor for AbstractMitabWriter.AbstractMitabWriter(Writer writer)Constructor for AbstractMitabWriter.AbstractMitabWriter(Writer writer, ComplexExpansionMethod<T,B> expansionMethod)Constructor for AbstractMitabWriter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()close.voidend()end.voidflush()flush.protected AbstractMitab25BinaryWriter<B,P>getBinaryWriter()Getter for the fieldbinaryWriter.protected ComplexExpansionMethod<T,B>getExpansionMethod()Getter for the fieldexpansionMethod.abstract MitabVersiongetVersion()getVersion.protected booleanhasStarted()hasStarted.voidinitialiseContext(Map<String,Object> options)Initialise the context of the InteractionWriter given a map of optionsprotected abstract voidinitialiseExpansionMethod(ComplexExpansionMethod<T,B> expansionMethod)initialiseExpansionMethod.protected abstract voidinitialiseFile(File file)initialiseFile.protected abstract voidinitialiseOutputStream(OutputStream output)initialiseOutputStream.protected abstract voidinitialiseWriter(Writer writer)initialiseWriter.booleanisWriteHeader()isWriteHeader.voidreset()reset.protected voidsetBinaryWriter(AbstractMitab25BinaryWriter<B,P> binaryWriter)Setter for the fieldbinaryWriter.protected voidsetExpansionMethod(ComplexExpansionMethod<T,B> expansionMethod)Setter for the fieldexpansionMethod.protected voidsetStarted(boolean hasStarted)setStarted.voidsetWriteHeader(boolean writeHeader)setWriteHeader.voidstart()start.voidwrite(Collection<? extends T> interactions)write.voidwrite(Iterator<? extends T> interactions)Writes Interaction objects using iteratorvoidwrite(T interaction)write.
-
-
-
Constructor Detail
-
AbstractMitabWriter
public AbstractMitabWriter()
Constructor for AbstractMitabWriter.
-
AbstractMitabWriter
public AbstractMitabWriter(File file) throws IOException
Constructor for AbstractMitabWriter.
- Parameters:
file- aFileobject.- Throws:
IOException- if any.
-
AbstractMitabWriter
public AbstractMitabWriter(OutputStream output)
Constructor for AbstractMitabWriter.
- Parameters:
output- aOutputStreamobject.
-
AbstractMitabWriter
public AbstractMitabWriter(Writer writer)
Constructor for AbstractMitabWriter.
- Parameters:
writer- aWriterobject.
-
AbstractMitabWriter
public AbstractMitabWriter(File file, ComplexExpansionMethod<T,B> expansionMethod) throws IOException
Constructor for AbstractMitabWriter.
- Parameters:
file- aFileobject.expansionMethod- aComplexExpansionMethodobject.- Throws:
IOException- if any.
-
AbstractMitabWriter
public AbstractMitabWriter(OutputStream output, ComplexExpansionMethod<T,B> expansionMethod)
Constructor for AbstractMitabWriter.
- Parameters:
output- aOutputStreamobject.expansionMethod- aComplexExpansionMethodobject.
-
AbstractMitabWriter
public AbstractMitabWriter(Writer writer, ComplexExpansionMethod<T,B> expansionMethod)
Constructor for AbstractMitabWriter.
- Parameters:
writer- aWriterobject.expansionMethod- aComplexExpansionMethodobject.
-
-
Method Detail
-
initialiseContext
public void initialiseContext(Map<String,Object> options)
Initialise the context of the InteractionWriter given a map of options- Specified by:
initialiseContextin interfaceInteractionWriter<T extends Interaction>- Parameters:
options- : the options given by the user
-
end
public void end() throws MIIOExceptionend.
- Specified by:
endin interfaceInteractionWriter<T extends Interaction>- Throws:
MIIOException- if any.
-
start
public void start() throws MIIOExceptionstart.
- Specified by:
startin interfaceInteractionWriter<T extends Interaction>- Throws:
MIIOException- if any.
-
write
public void write(T interaction) throws MIIOException
write.
- Specified by:
writein interfaceInteractionWriter<T extends Interaction>- Parameters:
interaction- a T object.- Throws:
MIIOException- if any.
-
write
public void write(Collection<? extends T> interactions) throws MIIOException
write.
- Specified by:
writein interfaceInteractionWriter<T extends Interaction>- Parameters:
interactions- aCollectionobject.- Throws:
MIIOException- if any.
-
write
public void write(Iterator<? extends T> interactions) throws MIIOException
Writes Interaction objects using iterator- Specified by:
writein interfaceInteractionWriter<T extends Interaction>- Parameters:
interactions- : the iterator of interactions to write- Throws:
MIIOException- : if cannot write
-
flush
public void flush() throws MIIOExceptionflush.
- Specified by:
flushin interfaceInteractionWriter<T extends Interaction>- Throws:
MIIOException- if any.
-
close
public void close() throws MIIOExceptionclose.
- Specified by:
closein interfaceInteractionWriter<T extends Interaction>- Throws:
MIIOException- if any.
-
reset
public void reset() throws MIIOExceptionreset.
- Specified by:
resetin interfaceInteractionWriter<T extends Interaction>- Throws:
MIIOException- if any.
-
getVersion
public abstract MitabVersion getVersion()
getVersion.
- Returns:
- a
MitabVersionobject.
-
isWriteHeader
public boolean isWriteHeader()
isWriteHeader.
- Returns:
- a boolean.
-
setWriteHeader
public void setWriteHeader(boolean writeHeader)
setWriteHeader.
- Parameters:
writeHeader- a boolean.
-
initialiseExpansionMethod
protected abstract void initialiseExpansionMethod(ComplexExpansionMethod<T,B> expansionMethod)
initialiseExpansionMethod.
- Parameters:
expansionMethod- aComplexExpansionMethodobject.
-
initialiseWriter
protected abstract void initialiseWriter(Writer writer)
initialiseWriter.
- Parameters:
writer- aWriterobject.
-
initialiseOutputStream
protected abstract void initialiseOutputStream(OutputStream output)
initialiseOutputStream.
- Parameters:
output- aOutputStreamobject.
-
initialiseFile
protected abstract void initialiseFile(File file) throws IOException
initialiseFile.
- Parameters:
file- aFileobject.- Throws:
IOException- if any.
-
setExpansionMethod
protected void setExpansionMethod(ComplexExpansionMethod<T,B> expansionMethod)
Setter for the field
expansionMethod.- Parameters:
expansionMethod- aComplexExpansionMethodobject.
-
setBinaryWriter
protected void setBinaryWriter(AbstractMitab25BinaryWriter<B,P> binaryWriter)
Setter for the field
binaryWriter.- Parameters:
binaryWriter- aAbstractMitab25BinaryWriterobject.
-
getBinaryWriter
protected AbstractMitab25BinaryWriter<B,P> getBinaryWriter()
Getter for the field
binaryWriter.- Returns:
- a
AbstractMitab25BinaryWriterobject.
-
getExpansionMethod
protected ComplexExpansionMethod<T,B> getExpansionMethod()
Getter for the field
expansionMethod.- Returns:
- a
ComplexExpansionMethodobject.
-
hasStarted
protected boolean hasStarted()
hasStarted.
- Returns:
- a boolean.
-
setStarted
protected void setStarted(boolean hasStarted)
setStarted.
- Parameters:
hasStarted- a boolean.
-
-