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.protectedAbstractXmlWriter(PsiXmlVersion version, XMLStreamWriter streamWriter, PsiXmlObjectCache elementCache)Constructor for AbstractXmlWriter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()close.voidend()Method to call when we reach the endprotected SourceextractSourceFromInteraction()extractSourceFromInteraction.voidflush()Flushes the writer (commit or write on disk)protected PsiXmlInteractionWriter<ModelledInteraction>getComplexWriter()Getter for the fieldcomplexWriter.protected TgetCurrentInteraction()Getter for the fieldcurrentInteraction.protected SourcegetCurrentSource()Getter for the fieldcurrentSource.protected PsiXmlObjectCachegetElementCache()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 XMLStreamWritergetStreamWriter()Getter for the fieldstreamWriter.protected PsiXmlElementWriterFactorygetSubWritersFactory()Getter for the fieldsubWritersFactory.protected PsiXmlVersiongetVersion()Getter for the fieldversion.voidinitialiseContext(Map<String,Object> options)Initialise the context of the InteractionWriter given a map of optionsprotected abstract voidinitialiseDefaultElementCache()initialiseDefaultElementCache.protected voidinitialiseDefaultInteractionSet()initialiseDefaultInteractionSet.protected voidinitialiseDefaultSource()initialiseDefaultSource.protected abstract voidinitialiseOptionalWriters(PsiXmlExperimentWriter experimentWriter, PsiXmlElementWriter<String> availabilityWriter, PsiXmlElementWriter<Interactor> interactorWriter)initialiseOptionalWriters.protected abstract voidinitialiseSubWriters()initialiseSubWriters.protected voidinitialiseSubWriters(boolean extended, boolean named, PsiXmlType xmlType, InteractionCategory interactionCategory, ComplexType complexType)initialiseSubWriters.protected booleanisStarted()isStarted.protected ExtendedPsiXmlSourcenewXmlSource(String shortName)voidreset()reset.voidsetAnnotationsWriter(PsiXmlElementWriter<Annotation> annotationsWriter)Setter for the fieldannotationsWriter.voidsetComplexWriter(PsiXmlInteractionWriter<ModelledInteraction> complexWriter)Setter for the fieldcomplexWriter.protected voidsetCurrentInteraction(T currentInteraction)Setter for the fieldcurrentInteraction.protected voidsetCurrentSource(Source currentSource)Setter for the fieldcurrentSource.voidsetDefaultReleaseDate(XMLGregorianCalendar defaultReleaseDate)Setter for the fielddefaultReleaseDate.voidsetDefaultSource(Source defaultSource)Setter for the fielddefaultSource.voidsetElementCache(PsiXmlObjectCache elementCache)Setter for the fieldelementCache.voidsetEntryAnnotations(Collection<Annotation> entryAnnotations)Setter for the fieldentryAnnotations.voidsetInteractionSet(Set<Interaction> processedInteractions)setInteractionSet.protected voidsetInteractionsIterator(Iterator<? extends T> interactionsIterator)Setter for the fieldinteractionsIterator.protected voidsetInteractionWriter(PsiXmlInteractionWriter<T> interactionWriter)Setter for the fieldinteractionWriter.voidsetSourceWriter(PsiXmlSourceWriter sourceWriter)Setter for the fieldsourceWriter.voidsetStarted(boolean started)Setter for the fieldstarted.protected voidsetSubWritersFactory(PsiXmlElementWriterFactory subWritersFactory)Setter for the fieldsubWritersFactory.voidsetVersion(PsiXmlVersion version)Setter for the fieldversion.voidsetWriteComplexesAsInteractors(boolean writeComplexesAsInteractors)Setter for the fieldwriteComplexesAsInteractors.voidstart()Method to call before starting to write but after initialising the contextvoidwrite(Collection<? extends T> interactions)Writes a collection of Interaction objectsvoidwrite(Iterator<? extends T> interactions)Writes Interaction objects using iteratorvoidwrite(T interaction)Writes an interactionprotected voidwriteComplex(ModelledInteraction modelled)writeComplex.protected booleanwriteComplexesAsInteractors()writeComplexesAsInteractors.protected voidwriteEndEntry()writeEndEntry.protected voidwriteEndEntryContent()writeEndEntryContent.protected voidwriteEndInteractionList()writeEndInteractionList.protected voidwriteEntryAttributes()writeEntryAttributes.protected voidwriteEntrySetAttributes(String level, String version, String minorVersion, String namespaceURI, String schemaLocation)writeEntrySetAttributes.protected voidwriteInteraction()writeInteraction.protected voidwriteInteractionListContent()writeInteractionListContent.protected voidwriteSource()writeSource.protected voidwriteStartEntry()writeStartEntry.protected abstract voidwriteStartEntryContent()writeStartEntryContent.protected voidwriteStartInteractionList()writeStartInteractionList.protected voidwriteSubComplexInEntry()writeSubComplexInEntry.
-
-
-
Constructor Detail
-
AbstractXmlWriter
public AbstractXmlWriter(PsiXmlVersion version)
Constructor for AbstractXmlWriter.
- Parameters:
version- aPsiXmlVersionobject.
-
AbstractXmlWriter
public AbstractXmlWriter(PsiXmlVersion version, File file) throws IOException, XMLStreamException
Constructor for AbstractXmlWriter.
- Parameters:
version- aPsiXmlVersionobject.file- aFileobject.- Throws:
IOException- if any.XMLStreamException- if any.
-
AbstractXmlWriter
public AbstractXmlWriter(PsiXmlVersion version, OutputStream output) throws XMLStreamException
Constructor for AbstractXmlWriter.
- Parameters:
version- aPsiXmlVersionobject.output- aOutputStreamobject.- Throws:
XMLStreamException- if any.
-
AbstractXmlWriter
public AbstractXmlWriter(PsiXmlVersion version, Writer writer) throws XMLStreamException
Constructor for AbstractXmlWriter.
- Parameters:
version- aPsiXmlVersionobject.writer- aWriterobject.- Throws:
XMLStreamException- if any.
-
AbstractXmlWriter
protected AbstractXmlWriter(PsiXmlVersion version, XMLStreamWriter streamWriter, PsiXmlObjectCache elementCache)
Constructor for AbstractXmlWriter.
- Parameters:
version- aPsiXmlVersionobject.streamWriter- aXMLStreamWriterobject.elementCache- aPsiXmlObjectCacheobject.
-
-
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 MIIOExceptionMethod to call when we reach the end- Specified by:
endin interfaceInteractionWriter<T extends Interaction>- Throws:
MIIOException- : if cannot end
-
start
public void start() throws MIIOExceptionMethod to call before starting to write but after initialising the context- Specified by:
startin 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:
writein 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:
writein 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:
writein interfaceInteractionWriter<T extends Interaction>- Parameters:
interactions- : the iterator of interactions to write- Throws:
MIIOException- : if cannot write
-
flush
public void flush() throws MIIOExceptionFlushes the writer (commit or write on disk)- Specified by:
flushin interfaceInteractionWriter<T extends Interaction>- Throws:
MIIOException- : if cannot flush
-
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.
-
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- aSetobject.
-
setSourceWriter
public void setSourceWriter(PsiXmlSourceWriter sourceWriter)
Setter for the field
sourceWriter.- Parameters:
sourceWriter- aPsiXmlSourceWriterobject.
-
setComplexWriter
public void setComplexWriter(PsiXmlInteractionWriter<ModelledInteraction> complexWriter)
Setter for the field
complexWriter.- Parameters:
complexWriter- aPsiXmlInteractionWriterobject.
-
setElementCache
public void setElementCache(PsiXmlObjectCache elementCache)
Setter for the field
elementCache.- Parameters:
elementCache- aPsiXmlObjectCacheobject.
-
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- aSourceobject.
-
setDefaultReleaseDate
public void setDefaultReleaseDate(XMLGregorianCalendar defaultReleaseDate)
Setter for the field
defaultReleaseDate.- Parameters:
defaultReleaseDate- aXMLGregorianCalendarobject.
-
setEntryAnnotations
public void setEntryAnnotations(Collection<Annotation> entryAnnotations)
Setter for the field
entryAnnotations.- Parameters:
entryAnnotations- aCollectionobject.
-
setAnnotationsWriter
public void setAnnotationsWriter(PsiXmlElementWriter<Annotation> annotationsWriter)
Setter for the field
annotationsWriter.- Parameters:
annotationsWriter- aPsiXmlElementWriterobject.
-
setVersion
public void setVersion(PsiXmlVersion version)
Setter for the field
version.- Parameters:
version- aPsiXmlVersionobject.
-
getProcessedInteractions
protected Set<Interaction> getProcessedInteractions()
Getter for the field
processedInteractions.- Returns:
- a
Setobject.
-
writeEndEntryContent
protected void writeEndEntryContent() throws XMLStreamExceptionwriteEndEntryContent.
- Throws:
XMLStreamException- if any.
-
writeEntryAttributes
protected void writeEntryAttributes() throws XMLStreamExceptionwriteEntryAttributes.
- Throws:
XMLStreamException- if any.
-
writeInteractionListContent
protected void writeInteractionListContent()
writeInteractionListContent.
-
writeStartEntryContent
protected abstract void writeStartEntryContent() throws XMLStreamExceptionwriteStartEntryContent.
- Throws:
XMLStreamException- if any.
-
writeStartInteractionList
protected void writeStartInteractionList() throws XMLStreamExceptionwriteStartInteractionList.
- Throws:
XMLStreamException- if any.
-
writeEndInteractionList
protected void writeEndInteractionList() throws XMLStreamExceptionwriteEndInteractionList.
- Throws:
XMLStreamException- if any.
-
writeInteraction
protected void writeInteraction() throws XMLStreamExceptionwriteInteraction.
- Throws:
XMLStreamException- if any.
-
writeSubComplexInEntry
protected void writeSubComplexInEntry() throws XMLStreamExceptionwriteSubComplexInEntry.
- Throws:
XMLStreamException- if any.
-
writeComplex
protected void writeComplex(ModelledInteraction modelled)
writeComplex.
- Parameters:
modelled- aModelledInteractionobject.
-
extractSourceFromInteraction
protected Source extractSourceFromInteraction()
extractSourceFromInteraction.
- Returns:
- a
Sourceobject.
-
initialiseDefaultSource
protected void initialiseDefaultSource()
initialiseDefaultSource.
-
writeSource
protected void writeSource() throws XMLStreamExceptionwriteSource.
- Throws:
XMLStreamException- if any.
-
writeStartEntry
protected void writeStartEntry() throws XMLStreamExceptionwriteStartEntry.
- Throws:
XMLStreamException- if any.
-
writeEndEntry
protected void writeEndEntry() throws XMLStreamExceptionwriteEndEntry.
- 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- aPsiXmlTypeobject.interactionCategory- aInteractionCategoryobject.complexType- aComplexTypeobject.
-
initialiseOptionalWriters
protected abstract void initialiseOptionalWriters(PsiXmlExperimentWriter experimentWriter, PsiXmlElementWriter<String> availabilityWriter, PsiXmlElementWriter<Interactor> interactorWriter)
initialiseOptionalWriters.
- Parameters:
experimentWriter- aPsiXmlExperimentWriterobject.availabilityWriter- aPsiXmlElementWriterobject.interactorWriter- aPsiXmlElementWriterobject.
-
initialiseDefaultElementCache
protected abstract void initialiseDefaultElementCache()
initialiseDefaultElementCache.
-
getInteractionWriter
protected PsiXmlInteractionWriter<T> getInteractionWriter()
Getter for the field
interactionWriter.- Returns:
- a
PsiXmlInteractionWriterobject.
-
getComplexWriter
protected PsiXmlInteractionWriter<ModelledInteraction> getComplexWriter()
Getter for the field
complexWriter.- Returns:
- a
PsiXmlInteractionWriterobject.
-
getElementCache
protected PsiXmlObjectCache getElementCache()
Getter for the field
elementCache.- Returns:
- a
PsiXmlObjectCacheobject.
-
setCurrentSource
protected void setCurrentSource(Source currentSource)
Setter for the field
currentSource.- Parameters:
currentSource- aSourceobject.
-
getCurrentSource
protected Source getCurrentSource()
Getter for the field
currentSource.- Returns:
- a
Sourceobject.
-
getInteractionsIterator
protected Iterator<? extends T> getInteractionsIterator()
Getter for the field
interactionsIterator.- Returns:
- a
Iteratorobject.
-
setInteractionsIterator
protected void setInteractionsIterator(Iterator<? extends T> interactionsIterator)
Setter for the field
interactionsIterator.- Parameters:
interactionsIterator- aIteratorobject.
-
setInteractionWriter
protected void setInteractionWriter(PsiXmlInteractionWriter<T> interactionWriter)
Setter for the field
interactionWriter.- Parameters:
interactionWriter- aPsiXmlInteractionWriterobject.
-
getStreamWriter
protected XMLStreamWriter getStreamWriter()
Getter for the field
streamWriter.- Returns:
- a
XMLStreamWriterobject.
-
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
PsiXmlVersionobject.
-
initialiseSubWriters
protected abstract void initialiseSubWriters()
initialiseSubWriters.
-
getSubWritersFactory
protected PsiXmlElementWriterFactory getSubWritersFactory()
Getter for the field
subWritersFactory.- Returns:
- a
PsiXmlElementWriterFactoryobject.
-
setSubWritersFactory
protected void setSubWritersFactory(PsiXmlElementWriterFactory subWritersFactory)
Setter for the field
subWritersFactory.- Parameters:
subWritersFactory- aPsiXmlElementWriterFactoryobject.
-
newXmlSource
protected ExtendedPsiXmlSource newXmlSource(String shortName)
-
-