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 void
close()
close.void
end()
end.void
flush()
flush.protected AbstractMitab25BinaryWriter<B,P>
getBinaryWriter()
Getter for the fieldbinaryWriter
.protected ComplexExpansionMethod<T,B>
getExpansionMethod()
Getter for the fieldexpansionMethod
.abstract MitabVersion
getVersion()
getVersion.protected boolean
hasStarted()
hasStarted.void
initialiseContext(Map<String,Object> options)
Initialise the context of the InteractionWriter given a map of optionsprotected abstract void
initialiseExpansionMethod(ComplexExpansionMethod<T,B> expansionMethod)
initialiseExpansionMethod.protected abstract void
initialiseFile(File file)
initialiseFile.protected abstract void
initialiseOutputStream(OutputStream output)
initialiseOutputStream.protected abstract void
initialiseWriter(Writer writer)
initialiseWriter.boolean
isWriteHeader()
isWriteHeader.void
reset()
reset.protected void
setBinaryWriter(AbstractMitab25BinaryWriter<B,P> binaryWriter)
Setter for the fieldbinaryWriter
.protected void
setExpansionMethod(ComplexExpansionMethod<T,B> expansionMethod)
Setter for the fieldexpansionMethod
.protected void
setStarted(boolean hasStarted)
setStarted.void
setWriteHeader(boolean writeHeader)
setWriteHeader.void
start()
start.void
write(Collection<? extends T> interactions)
write.void
write(Iterator<? extends T> interactions)
Writes Interaction objects using iteratorvoid
write(T interaction)
write.
-
-
-
Constructor Detail
-
AbstractMitabWriter
public AbstractMitabWriter()
Constructor for AbstractMitabWriter.
-
AbstractMitabWriter
public AbstractMitabWriter(File file) throws IOException
Constructor for AbstractMitabWriter.
- Parameters:
file
- aFile
object.- Throws:
IOException
- if any.
-
AbstractMitabWriter
public AbstractMitabWriter(OutputStream output)
Constructor for AbstractMitabWriter.
- Parameters:
output
- aOutputStream
object.
-
AbstractMitabWriter
public AbstractMitabWriter(Writer writer)
Constructor for AbstractMitabWriter.
- Parameters:
writer
- aWriter
object.
-
AbstractMitabWriter
public AbstractMitabWriter(File file, ComplexExpansionMethod<T,B> expansionMethod) throws IOException
Constructor for AbstractMitabWriter.
- Parameters:
file
- aFile
object.expansionMethod
- aComplexExpansionMethod
object.- Throws:
IOException
- if any.
-
AbstractMitabWriter
public AbstractMitabWriter(OutputStream output, ComplexExpansionMethod<T,B> expansionMethod)
Constructor for AbstractMitabWriter.
- Parameters:
output
- aOutputStream
object.expansionMethod
- aComplexExpansionMethod
object.
-
AbstractMitabWriter
public AbstractMitabWriter(Writer writer, ComplexExpansionMethod<T,B> expansionMethod)
Constructor for AbstractMitabWriter.
- Parameters:
writer
- aWriter
object.expansionMethod
- aComplexExpansionMethod
object.
-
-
Method Detail
-
initialiseContext
public void initialiseContext(Map<String,Object> options)
Initialise the context of the InteractionWriter given a map of options- Specified by:
initialiseContext
in interfaceInteractionWriter<T extends Interaction>
- Parameters:
options
- : the options given by the user
-
end
public void end() throws MIIOException
end.
- Specified by:
end
in interfaceInteractionWriter<T extends Interaction>
- Throws:
MIIOException
- if any.
-
start
public void start() throws MIIOException
start.
- Specified by:
start
in interfaceInteractionWriter<T extends Interaction>
- Throws:
MIIOException
- if any.
-
write
public void write(T interaction) throws MIIOException
write.
- Specified by:
write
in 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:
write
in interfaceInteractionWriter<T extends Interaction>
- Parameters:
interactions
- aCollection
object.- Throws:
MIIOException
- if any.
-
write
public void write(Iterator<? extends T> interactions) throws MIIOException
Writes Interaction objects using iterator- Specified by:
write
in interfaceInteractionWriter<T extends Interaction>
- Parameters:
interactions
- : the iterator of interactions to write- Throws:
MIIOException
- : if cannot write
-
flush
public void flush() throws MIIOException
flush.
- Specified by:
flush
in interfaceInteractionWriter<T extends Interaction>
- Throws:
MIIOException
- if any.
-
close
public void close() throws MIIOException
close.
- Specified by:
close
in interfaceInteractionWriter<T extends Interaction>
- Throws:
MIIOException
- if any.
-
reset
public void reset() throws MIIOException
reset.
- Specified by:
reset
in interfaceInteractionWriter<T extends Interaction>
- Throws:
MIIOException
- if any.
-
getVersion
public abstract MitabVersion getVersion()
getVersion.
- Returns:
- a
MitabVersion
object.
-
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
- aComplexExpansionMethod
object.
-
initialiseWriter
protected abstract void initialiseWriter(Writer writer)
initialiseWriter.
- Parameters:
writer
- aWriter
object.
-
initialiseOutputStream
protected abstract void initialiseOutputStream(OutputStream output)
initialiseOutputStream.
- Parameters:
output
- aOutputStream
object.
-
initialiseFile
protected abstract void initialiseFile(File file) throws IOException
initialiseFile.
- Parameters:
file
- aFile
object.- Throws:
IOException
- if any.
-
setExpansionMethod
protected void setExpansionMethod(ComplexExpansionMethod<T,B> expansionMethod)
Setter for the field
expansionMethod
.- Parameters:
expansionMethod
- aComplexExpansionMethod
object.
-
setBinaryWriter
protected void setBinaryWriter(AbstractMitab25BinaryWriter<B,P> binaryWriter)
Setter for the field
binaryWriter
.- Parameters:
binaryWriter
- aAbstractMitab25BinaryWriter
object.
-
getBinaryWriter
protected AbstractMitab25BinaryWriter<B,P> getBinaryWriter()
Getter for the field
binaryWriter
.- Returns:
- a
AbstractMitab25BinaryWriter
object.
-
getExpansionMethod
protected ComplexExpansionMethod<T,B> getExpansionMethod()
Getter for the field
expansionMethod
.- Returns:
- a
ComplexExpansionMethod
object.
-
hasStarted
protected boolean hasStarted()
hasStarted.
- Returns:
- a boolean.
-
setStarted
protected void setStarted(boolean hasStarted)
setStarted.
- Parameters:
hasStarted
- a boolean.
-
-