Class AbstractXmlWriter<T extends Interaction>
- java.lang.Object
-
- psidev.psi.mi.jami.xml.io.writer.AbstractXmlWriter<T>
-
- All Implemented Interfaces:
InteractionWriter<T>
- Direct Known Subclasses:
AbstractCompactXmlWriter
,AbstractExpandedXmlWriter
public abstract class AbstractXmlWriter<T extends Interaction> extends Object implements InteractionWriter<T>
Abstract class for XML writer of interactions- Since:
11/11/13
- Version:
- $Id$
- Author:
- Marine Dumousseau (marine@ebi.ac.uk)
-
-
Constructor Summary
Constructors Modifier Constructor Description AbstractXmlWriter(PsiXmlVersion version)
Constructor for AbstractXmlWriter.AbstractXmlWriter(PsiXmlVersion version, File file)
Constructor for AbstractXmlWriter.AbstractXmlWriter(PsiXmlVersion version, OutputStream output)
Constructor for AbstractXmlWriter.AbstractXmlWriter(PsiXmlVersion version, Writer writer)
Constructor for AbstractXmlWriter.protected
AbstractXmlWriter(PsiXmlVersion version, XMLStreamWriter streamWriter, PsiXmlObjectCache elementCache)
Constructor for AbstractXmlWriter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
close.void
end()
Method to call when we reach the endprotected Source
extractSourceFromInteraction()
extractSourceFromInteraction.void
flush()
Flushes the writer (commit or write on disk)protected PsiXmlInteractionWriter<ModelledInteraction>
getComplexWriter()
Getter for the fieldcomplexWriter
.protected T
getCurrentInteraction()
Getter for the fieldcurrentInteraction
.protected Source
getCurrentSource()
Getter for the fieldcurrentSource
.protected PsiXmlObjectCache
getElementCache()
Getter for the fieldelementCache
.protected Iterator<? extends T>
getInteractionsIterator()
Getter for the fieldinteractionsIterator
.protected PsiXmlInteractionWriter<T>
getInteractionWriter()
Getter for the fieldinteractionWriter
.protected Set<Interaction>
getProcessedInteractions()
Getter for the fieldprocessedInteractions
.protected XMLStreamWriter
getStreamWriter()
Getter for the fieldstreamWriter
.protected PsiXmlElementWriterFactory
getSubWritersFactory()
Getter for the fieldsubWritersFactory
.protected PsiXmlVersion
getVersion()
Getter for the fieldversion
.void
initialiseContext(Map<String,Object> options)
Initialise the context of the InteractionWriter given a map of optionsprotected abstract void
initialiseDefaultElementCache()
initialiseDefaultElementCache.protected void
initialiseDefaultInteractionSet()
initialiseDefaultInteractionSet.protected void
initialiseDefaultSource()
initialiseDefaultSource.protected abstract void
initialiseOptionalWriters(PsiXmlExperimentWriter experimentWriter, PsiXmlElementWriter<String> availabilityWriter, PsiXmlElementWriter<Interactor> interactorWriter)
initialiseOptionalWriters.protected abstract void
initialiseSubWriters()
initialiseSubWriters.protected void
initialiseSubWriters(boolean extended, boolean named, PsiXmlType xmlType, InteractionCategory interactionCategory, ComplexType complexType)
initialiseSubWriters.protected boolean
isStarted()
isStarted.protected ExtendedPsiXmlSource
newXmlSource(String shortName)
void
reset()
reset.void
setAnnotationsWriter(PsiXmlElementWriter<Annotation> annotationsWriter)
Setter for the fieldannotationsWriter
.void
setComplexWriter(PsiXmlInteractionWriter<ModelledInteraction> complexWriter)
Setter for the fieldcomplexWriter
.protected void
setCurrentInteraction(T currentInteraction)
Setter for the fieldcurrentInteraction
.protected void
setCurrentSource(Source currentSource)
Setter for the fieldcurrentSource
.void
setDefaultReleaseDate(XMLGregorianCalendar defaultReleaseDate)
Setter for the fielddefaultReleaseDate
.void
setDefaultSource(Source defaultSource)
Setter for the fielddefaultSource
.void
setElementCache(PsiXmlObjectCache elementCache)
Setter for the fieldelementCache
.void
setEntryAnnotations(Collection<Annotation> entryAnnotations)
Setter for the fieldentryAnnotations
.void
setInteractionSet(Set<Interaction> processedInteractions)
setInteractionSet.protected void
setInteractionsIterator(Iterator<? extends T> interactionsIterator)
Setter for the fieldinteractionsIterator
.protected void
setInteractionWriter(PsiXmlInteractionWriter<T> interactionWriter)
Setter for the fieldinteractionWriter
.void
setSourceWriter(PsiXmlSourceWriter sourceWriter)
Setter for the fieldsourceWriter
.void
setStarted(boolean started)
Setter for the fieldstarted
.protected void
setSubWritersFactory(PsiXmlElementWriterFactory subWritersFactory)
Setter for the fieldsubWritersFactory
.void
setVersion(PsiXmlVersion version)
Setter for the fieldversion
.void
setWriteComplexesAsInteractors(boolean writeComplexesAsInteractors)
Setter for the fieldwriteComplexesAsInteractors
.void
start()
Method to call before starting to write but after initialising the contextvoid
write(Collection<? extends T> interactions)
Writes a collection of Interaction objectsvoid
write(Iterator<? extends T> interactions)
Writes Interaction objects using iteratorvoid
write(T interaction)
Writes an interactionprotected void
writeComplex(ModelledInteraction modelled)
writeComplex.protected boolean
writeComplexesAsInteractors()
writeComplexesAsInteractors.protected void
writeEndEntry()
writeEndEntry.protected void
writeEndEntryContent()
writeEndEntryContent.protected void
writeEndInteractionList()
writeEndInteractionList.protected void
writeEntryAttributes()
writeEntryAttributes.protected void
writeEntrySetAttributes(String level, String version, String minorVersion, String namespaceURI, String schemaLocation)
writeEntrySetAttributes.protected void
writeInteraction()
writeInteraction.protected void
writeInteractionListContent()
writeInteractionListContent.protected void
writeSource()
writeSource.protected void
writeStartEntry()
writeStartEntry.protected abstract void
writeStartEntryContent()
writeStartEntryContent.protected void
writeStartInteractionList()
writeStartInteractionList.protected void
writeSubComplexInEntry()
writeSubComplexInEntry.
-
-
-
Constructor Detail
-
AbstractXmlWriter
public AbstractXmlWriter(PsiXmlVersion version)
Constructor for AbstractXmlWriter.
- Parameters:
version
- aPsiXmlVersion
object.
-
AbstractXmlWriter
public AbstractXmlWriter(PsiXmlVersion version, File file) throws IOException, XMLStreamException
Constructor for AbstractXmlWriter.
- Parameters:
version
- aPsiXmlVersion
object.file
- aFile
object.- Throws:
IOException
- if any.XMLStreamException
- if any.
-
AbstractXmlWriter
public AbstractXmlWriter(PsiXmlVersion version, OutputStream output) throws XMLStreamException
Constructor for AbstractXmlWriter.
- Parameters:
version
- aPsiXmlVersion
object.output
- aOutputStream
object.- Throws:
XMLStreamException
- if any.
-
AbstractXmlWriter
public AbstractXmlWriter(PsiXmlVersion version, Writer writer) throws XMLStreamException
Constructor for AbstractXmlWriter.
- Parameters:
version
- aPsiXmlVersion
object.writer
- aWriter
object.- Throws:
XMLStreamException
- if any.
-
AbstractXmlWriter
protected AbstractXmlWriter(PsiXmlVersion version, XMLStreamWriter streamWriter, PsiXmlObjectCache elementCache)
Constructor for AbstractXmlWriter.
- Parameters:
version
- aPsiXmlVersion
object.streamWriter
- aXMLStreamWriter
object.elementCache
- aPsiXmlObjectCache
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
Method to call when we reach the end- Specified by:
end
in interfaceInteractionWriter<T extends Interaction>
- Throws:
MIIOException
- : if cannot end
-
start
public void start() throws MIIOException
Method to call before starting to write but after initialising the context- Specified by:
start
in interfaceInteractionWriter<T extends Interaction>
- Throws:
MIIOException
- if cannot start writing
-
writeEntrySetAttributes
protected void writeEntrySetAttributes(String level, String version, String minorVersion, String namespaceURI, String schemaLocation) throws XMLStreamException
writeEntrySetAttributes.
-
write
public void write(T interaction) throws MIIOException
Writes an interaction- Specified by:
write
in interfaceInteractionWriter<T extends Interaction>
- Parameters:
interaction
- : the interaction to write- Throws:
MIIOException
- : if cannot write
-
write
public void write(Collection<? extends T> interactions) throws MIIOException
Writes a collection of Interaction objects- Specified by:
write
in interfaceInteractionWriter<T extends Interaction>
- Parameters:
interactions
- : the interactions to write- Throws:
MIIOException
- : if cannot write
-
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
Flushes the writer (commit or write on disk)- Specified by:
flush
in interfaceInteractionWriter<T extends Interaction>
- Throws:
MIIOException
- : if cannot flush
-
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.
-
setWriteComplexesAsInteractors
public void setWriteComplexesAsInteractors(boolean writeComplexesAsInteractors)
Setter for the field
writeComplexesAsInteractors
.- Parameters:
writeComplexesAsInteractors
- a boolean.
-
setInteractionSet
public void setInteractionSet(Set<Interaction> processedInteractions)
setInteractionSet.
- Parameters:
processedInteractions
- aSet
object.
-
setSourceWriter
public void setSourceWriter(PsiXmlSourceWriter sourceWriter)
Setter for the field
sourceWriter
.- Parameters:
sourceWriter
- aPsiXmlSourceWriter
object.
-
setComplexWriter
public void setComplexWriter(PsiXmlInteractionWriter<ModelledInteraction> complexWriter)
Setter for the field
complexWriter
.- Parameters:
complexWriter
- aPsiXmlInteractionWriter
object.
-
setElementCache
public void setElementCache(PsiXmlObjectCache elementCache)
Setter for the field
elementCache
.- Parameters:
elementCache
- aPsiXmlObjectCache
object.
-
setStarted
public void setStarted(boolean started)
Setter for the field
started
.- Parameters:
started
- a boolean.
-
setDefaultSource
public void setDefaultSource(Source defaultSource)
Setter for the field
defaultSource
.- Parameters:
defaultSource
- aSource
object.
-
setDefaultReleaseDate
public void setDefaultReleaseDate(XMLGregorianCalendar defaultReleaseDate)
Setter for the field
defaultReleaseDate
.- Parameters:
defaultReleaseDate
- aXMLGregorianCalendar
object.
-
setEntryAnnotations
public void setEntryAnnotations(Collection<Annotation> entryAnnotations)
Setter for the field
entryAnnotations
.- Parameters:
entryAnnotations
- aCollection
object.
-
setAnnotationsWriter
public void setAnnotationsWriter(PsiXmlElementWriter<Annotation> annotationsWriter)
Setter for the field
annotationsWriter
.- Parameters:
annotationsWriter
- aPsiXmlElementWriter
object.
-
setVersion
public void setVersion(PsiXmlVersion version)
Setter for the field
version
.- Parameters:
version
- aPsiXmlVersion
object.
-
getProcessedInteractions
protected Set<Interaction> getProcessedInteractions()
Getter for the field
processedInteractions
.- Returns:
- a
Set
object.
-
writeEndEntryContent
protected void writeEndEntryContent() throws XMLStreamException
writeEndEntryContent.
- Throws:
XMLStreamException
- if any.
-
writeEntryAttributes
protected void writeEntryAttributes() throws XMLStreamException
writeEntryAttributes.
- Throws:
XMLStreamException
- if any.
-
writeInteractionListContent
protected void writeInteractionListContent()
writeInteractionListContent.
-
writeStartEntryContent
protected abstract void writeStartEntryContent() throws XMLStreamException
writeStartEntryContent.
- Throws:
XMLStreamException
- if any.
-
writeStartInteractionList
protected void writeStartInteractionList() throws XMLStreamException
writeStartInteractionList.
- Throws:
XMLStreamException
- if any.
-
writeEndInteractionList
protected void writeEndInteractionList() throws XMLStreamException
writeEndInteractionList.
- Throws:
XMLStreamException
- if any.
-
writeInteraction
protected void writeInteraction() throws XMLStreamException
writeInteraction.
- Throws:
XMLStreamException
- if any.
-
writeSubComplexInEntry
protected void writeSubComplexInEntry() throws XMLStreamException
writeSubComplexInEntry.
- Throws:
XMLStreamException
- if any.
-
writeComplex
protected void writeComplex(ModelledInteraction modelled)
writeComplex.
- Parameters:
modelled
- aModelledInteraction
object.
-
extractSourceFromInteraction
protected Source extractSourceFromInteraction()
extractSourceFromInteraction.
- Returns:
- a
Source
object.
-
initialiseDefaultSource
protected void initialiseDefaultSource()
initialiseDefaultSource.
-
writeSource
protected void writeSource() throws XMLStreamException
writeSource.
- Throws:
XMLStreamException
- if any.
-
writeStartEntry
protected void writeStartEntry() throws XMLStreamException
writeStartEntry.
- Throws:
XMLStreamException
- if any.
-
writeEndEntry
protected void writeEndEntry() throws XMLStreamException
writeEndEntry.
- Throws:
XMLStreamException
- if any.
-
initialiseSubWriters
protected void initialiseSubWriters(boolean extended, boolean named, PsiXmlType xmlType, InteractionCategory interactionCategory, ComplexType complexType)
initialiseSubWriters.
- Parameters:
extended
- a boolean.named
- a boolean.xmlType
- aPsiXmlType
object.interactionCategory
- aInteractionCategory
object.complexType
- aComplexType
object.
-
initialiseOptionalWriters
protected abstract void initialiseOptionalWriters(PsiXmlExperimentWriter experimentWriter, PsiXmlElementWriter<String> availabilityWriter, PsiXmlElementWriter<Interactor> interactorWriter)
initialiseOptionalWriters.
- Parameters:
experimentWriter
- aPsiXmlExperimentWriter
object.availabilityWriter
- aPsiXmlElementWriter
object.interactorWriter
- aPsiXmlElementWriter
object.
-
initialiseDefaultElementCache
protected abstract void initialiseDefaultElementCache()
initialiseDefaultElementCache.
-
getInteractionWriter
protected PsiXmlInteractionWriter<T> getInteractionWriter()
Getter for the field
interactionWriter
.- Returns:
- a
PsiXmlInteractionWriter
object.
-
getComplexWriter
protected PsiXmlInteractionWriter<ModelledInteraction> getComplexWriter()
Getter for the field
complexWriter
.- Returns:
- a
PsiXmlInteractionWriter
object.
-
getElementCache
protected PsiXmlObjectCache getElementCache()
Getter for the field
elementCache
.- Returns:
- a
PsiXmlObjectCache
object.
-
setCurrentSource
protected void setCurrentSource(Source currentSource)
Setter for the field
currentSource
.- Parameters:
currentSource
- aSource
object.
-
getCurrentSource
protected Source getCurrentSource()
Getter for the field
currentSource
.- Returns:
- a
Source
object.
-
getInteractionsIterator
protected Iterator<? extends T> getInteractionsIterator()
Getter for the field
interactionsIterator
.- Returns:
- a
Iterator
object.
-
setInteractionsIterator
protected void setInteractionsIterator(Iterator<? extends T> interactionsIterator)
Setter for the field
interactionsIterator
.- Parameters:
interactionsIterator
- aIterator
object.
-
setInteractionWriter
protected void setInteractionWriter(PsiXmlInteractionWriter<T> interactionWriter)
Setter for the field
interactionWriter
.- Parameters:
interactionWriter
- aPsiXmlInteractionWriter
object.
-
getStreamWriter
protected XMLStreamWriter getStreamWriter()
Getter for the field
streamWriter
.- Returns:
- a
XMLStreamWriter
object.
-
getCurrentInteraction
protected T getCurrentInteraction()
Getter for the field
currentInteraction
.- Returns:
- a T object.
-
setCurrentInteraction
protected void setCurrentInteraction(T currentInteraction)
Setter for the field
currentInteraction
.- Parameters:
currentInteraction
- a T object.
-
isStarted
protected boolean isStarted()
isStarted.
- Returns:
- a boolean.
-
writeComplexesAsInteractors
protected boolean writeComplexesAsInteractors()
writeComplexesAsInteractors.
- Returns:
- a boolean.
-
initialiseDefaultInteractionSet
protected void initialiseDefaultInteractionSet()
initialiseDefaultInteractionSet.
-
getVersion
protected PsiXmlVersion getVersion()
Getter for the field
version
.- Returns:
- a
PsiXmlVersion
object.
-
initialiseSubWriters
protected abstract void initialiseSubWriters()
initialiseSubWriters.
-
getSubWritersFactory
protected PsiXmlElementWriterFactory getSubWritersFactory()
Getter for the field
subWritersFactory
.- Returns:
- a
PsiXmlElementWriterFactory
object.
-
setSubWritersFactory
protected void setSubWritersFactory(PsiXmlElementWriterFactory subWritersFactory)
Setter for the field
subWritersFactory
.- Parameters:
subWritersFactory
- aPsiXmlElementWriterFactory
object.
-
newXmlSource
protected ExtendedPsiXmlSource newXmlSource(String shortName)
-
-