Class AbstractPsiXmlStream<T extends Interaction>
- java.lang.Object
-
- psidev.psi.mi.jami.xml.model.extension.datasource.AbstractPsiXmlStream<T>
-
- All Implemented Interfaces:
ErrorHandler
,InteractionStream<T>
,MIDataSource
,MIFileDataSource
,MIFileParserListener
,PsiXmlParserListener
,PsiXmlStreamSource<T>
- Direct Known Subclasses:
AbstractPsiXmlBinaryStream
,AbstractPsiXmlSource
,LightXmlStreamSource
,XmlComplexStreamSource
,XmlEvidenceStreamSource
,XmlModelledStreamSource
,XmlStreamSource
public abstract class AbstractPsiXmlStream<T extends Interaction> extends Object implements PsiXmlStreamSource<T>
Abstract class for psiXml data source- Since:
16/10/13
- Version:
- $Id$
- Author:
- Marine Dumousseau (marine@ebi.ac.uk)
-
-
Field Summary
Fields Modifier and Type Field Description static String
SCHEMA_FEATURE
ConstantSCHEMA_FEATURE="http://apache.org/xml/features/validati"{trunked}
static String
VALIDATION_FEATURE
ConstantVALIDATION_FEATURE="http://xml.org/sax/features/validation"
-
Fields inherited from interface psidev.psi.mi.jami.datasource.MIFileDataSource
FILE_URI_PREFIX, URL_PREFIX_REGEXP
-
-
Constructor Summary
Constructors Constructor Description AbstractPsiXmlStream()
Constructor for AbstractPsiXmlStream.AbstractPsiXmlStream(File file)
Constructor for AbstractPsiXmlStream.AbstractPsiXmlStream(InputStream input)
Constructor for AbstractPsiXmlStream.AbstractPsiXmlStream(Reader reader)
Constructor for AbstractPsiXmlStream.AbstractPsiXmlStream(URL url)
Constructor for AbstractPsiXmlStream.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
This method close the file data source and all opened streams and readersprotected abstract Iterator<T>
createXmlIterator()
createXmlIterator.void
error(SAXParseException exception)
void
fatalError(SAXParseException exception)
protected PsiXmlIdCache
getElementCache()
Getter for the fieldelementCache
.MIFileParserListener
getFileParserListener()
The MIFileParserListener can be null if not initialisedIterator<T>
getInteractionsIterator()
The iterator of Interactions for this datasourceXmlInteractorFactory
getInteractorFactory()
Getter for the fieldinteractorFactory
.protected PsiXmlParser<T>
getParser()
Getter for the fieldparser
.void
initialiseContext(Map<String,Object> options)
Initialise the context of the MIDataSource given a map of optionsprotected abstract void
initialiseExpansionMethod(ComplexExpansionMethod<? extends Interaction,? extends BinaryInteraction> expansionMethod)
initialiseExpansionMethod.protected abstract void
initialiseXmlParser(File file)
initialiseXmlParser.protected abstract void
initialiseXmlParser(InputStream input)
initialiseXmlParser.protected abstract void
initialiseXmlParser(Reader reader)
initialiseXmlParser.protected abstract void
initialiseXmlParser(URL url)
initialiseXmlParser.protected boolean
isInitialised()
isInitialised.void
onAliasWithoutName(FileSourceContext context)
Listen to an event fired when an alias does not have a namevoid
onAnnotationWithoutTopic(FileSourceContext context)
Listen to an event fired when an annotation does not have a topicvoid
onInteractionWithoutParticipants(Interaction interaction, FileSourceContext context)
Listen to an event fired when an interaction is read and does not have any participants.void
onInvalidOrganismTaxid(String taxid, FileSourceContext context)
Listen to an event fired when an organism does not have a valid taxid (positive integer or -1, -2, -3, -4, -5)void
onInvalidPosition(String message, FileSourceContext context)
Listen to an event fired when a position is not validvoid
onInvalidRange(String message, FileSourceContext context)
Listen to an event fired when a range is not validvoid
onInvalidStoichiometry(String message, FileSourceContext context)
Listen to an event fired when a stoichiometry is not validvoid
onInvalidSyntax(FileSourceContext context, Exception e)
Listen to an invalid syntax causing an Exceptionvoid
onMissingChecksumMethod(FileSourceContext context)
Listen to an event fired when a checksum does not have a methodvoid
onMissingChecksumValue(FileSourceContext context)
Listen to an event fired when a checksum does not have a valuevoid
onMissingConfidenceType(FileSourceContext context)
Listen to an event fired when a confidence does not have a confidence typevoid
onMissingConfidenceValue(FileSourceContext context)
Listen to an event fired when a confidence does not have a valuevoid
onMissingCvTermName(CvTerm term, FileSourceContext context, String message)
Listen to an event fired when a CvTerm is read and does not have any names.void
onMissingInteractorName(Interactor interactor, FileSourceContext context)
Listen to an event fired when an interactor is read and does not have any names.void
onMissingParameterType(FileSourceContext context)
Listen to an event fired when a parameter does not have a typevoid
onMissingParameterValue(FileSourceContext context)
Listen to an event fired when a parameter does not have a valuevoid
onParticipantWithoutInteractor(Participant participant, FileSourceContext context)
Listen to en event fired when a Participant is read and no interactor details has been provided.void
onSeveralExperimentalRolesFound(Collection<CvTerm> roles, FileSourceLocator locator)
onSeveralExperimentalRolesFound.void
onSeveralExperimentsFound(Collection<Experiment> experiments, FileSourceLocator locator)
onSeveralExperimentsFound.void
onSeveralExpressedInOrganismFound(Collection<Organism> organisms, FileSourceLocator locator)
onSeveralExpressedInOrganismFound.void
onSeveralHostOrganismFound(Collection<Organism> organisms, FileSourceLocator locator)
onSeveralHostOrganismFound.void
onSyntaxWarning(FileSourceContext context, String message)
Listen to an event fired when the syntax of the file is valid but the content is not expected or some information may be lost.void
onUnresolvedReference(XmlIdReference ref, String message)
onUnresolvedReference.void
onXrefWithoutDatabase(FileSourceContext context)
Listen to an event fired when a xref does not have a databasevoid
onXrefWithoutId(FileSourceContext context)
Listen to an event fired when a xref does not have an idprotected void
reInit()
reInit.void
reset()
This method will reset the data sources from all loaded options.void
setFileParserListener(MIFileParserListener listener)
setFileParserListenervoid
setInteractorFactory(XmlInteractorFactory interactorFactory)
Setter for the fieldinteractorFactory
.protected void
setMIFileParserListener(MIFileParserListener listener)
setMIFileParserListener.protected void
setParser(PsiXmlParser<T> parser)
Setter for the fieldparser
.protected void
setXmlFileParserListener(PsiXmlParserListener listener)
setXmlFileParserListener.boolean
validateSyntax()
Validate the syntax of this MIFileDataSource.boolean
validateSyntax(MIFileParserListener listener)
Validate the syntax of this MIFileDataSource and uses the provided MIFileParserListener to listen to the events.void
warning(SAXParseException exception)
-
-
-
Field Detail
-
VALIDATION_FEATURE
public static final String VALIDATION_FEATURE
ConstantVALIDATION_FEATURE="http://xml.org/sax/features/validation"
- See Also:
- Constant Field Values
-
SCHEMA_FEATURE
public static final String SCHEMA_FEATURE
ConstantSCHEMA_FEATURE="http://apache.org/xml/features/validati"{trunked}
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractPsiXmlStream
public AbstractPsiXmlStream()
Constructor for AbstractPsiXmlStream.
-
AbstractPsiXmlStream
public AbstractPsiXmlStream(File file)
Constructor for AbstractPsiXmlStream.
- Parameters:
file
- aFile
object.
-
AbstractPsiXmlStream
public AbstractPsiXmlStream(InputStream input)
Constructor for AbstractPsiXmlStream.
- Parameters:
input
- aInputStream
object.
-
AbstractPsiXmlStream
public AbstractPsiXmlStream(Reader reader)
Constructor for AbstractPsiXmlStream.
- Parameters:
reader
- aReader
object.
-
-
Method Detail
-
getInteractionsIterator
public Iterator<T> getInteractionsIterator() throws MIIOException
The iterator of Interactions for this datasource- Specified by:
getInteractionsIterator
in interfaceInteractionStream<T extends Interaction>
- Returns:
- iterator of Interactions for this datasource
- Throws:
MIIOException
- exception thrown when it cannot iterate MI data
-
getFileParserListener
public MIFileParserListener getFileParserListener()
The MIFileParserListener can be null if not initialised- Specified by:
getFileParserListener
in interfaceMIFileDataSource
- Returns:
- the file parser listener that listen to the different parsing events
-
setFileParserListener
public void setFileParserListener(MIFileParserListener listener)
setFileParserListener
- Specified by:
setFileParserListener
in interfaceMIFileDataSource
- Parameters:
listener
- aMIFileParserListener
object.
-
validateSyntax
public boolean validateSyntax() throws MIIOException
Validate the syntax of this MIFileDataSource. It returns true if the file syntax is valid, false otherwise. When the file syntax is invalid, the syntax errors are fired and should be retrieved using a proper MIFileParserListener- Specified by:
validateSyntax
in interfaceMIFileDataSource
- Returns:
- a boolean.
- Throws:
MIIOException
- if any.
-
validateSyntax
public boolean validateSyntax(MIFileParserListener listener) throws MIIOException
Validate the syntax of this MIFileDataSource and uses the provided MIFileParserListener to listen to the events. The provided listener will be set as the MIFileParserListener of this datasource- Specified by:
validateSyntax
in interfaceMIFileDataSource
- Parameters:
listener
- : the listener for parsing events- Returns:
- true if the file syntax is valid
- Throws:
MIIOException
- : if some severe syntax errors are found in the file and it stops the parsing
-
getInteractorFactory
public XmlInteractorFactory getInteractorFactory()
Getter for the field
interactorFactory
.- Returns:
- a
XmlInteractorFactory
object.
-
setInteractorFactory
public void setInteractorFactory(XmlInteractorFactory interactorFactory)
Setter for the field
interactorFactory
.- Parameters:
interactorFactory
- aXmlInteractorFactory
object.
-
initialiseContext
public void initialiseContext(Map<String,Object> options)
Initialise the context of the MIDataSource given a map of options- Specified by:
initialiseContext
in interfaceMIDataSource
- Parameters:
options
- : the options provided by the user
-
close
public void close() throws MIIOException
This method close the file data source and all opened streams and readers- Specified by:
close
in interfaceMIDataSource
- Throws:
MIIOException
- if the dataSource cannot be closed
-
reset
public void reset() throws MIIOException
This method will reset the data sources from all loaded options. The data source will be back to what is was before the initialiseContext was called. To re-use the data source after calling the reset() method, the data source needs to be re-initialised with initialiseContext. Any provided inputStream or reader will not be closed and will have to be closed separately.- Specified by:
reset
in interfaceMIDataSource
- Throws:
MIIOException
- if the dataSource cannot be reset
-
onUnresolvedReference
public void onUnresolvedReference(XmlIdReference ref, String message)
onUnresolvedReference.
- Specified by:
onUnresolvedReference
in interfacePsiXmlParserListener
- Parameters:
ref
- aXmlIdReference
object.message
- aString
object.
-
onSeveralHostOrganismFound
public void onSeveralHostOrganismFound(Collection<Organism> organisms, FileSourceLocator locator)
onSeveralHostOrganismFound.
- Specified by:
onSeveralHostOrganismFound
in interfacePsiXmlParserListener
- Parameters:
organisms
- aCollection
object.locator
- aFileSourceLocator
object.
-
onSeveralExpressedInOrganismFound
public void onSeveralExpressedInOrganismFound(Collection<Organism> organisms, FileSourceLocator locator)
onSeveralExpressedInOrganismFound.
- Specified by:
onSeveralExpressedInOrganismFound
in interfacePsiXmlParserListener
- Parameters:
organisms
- aCollection
object.locator
- aFileSourceLocator
object.
-
onSeveralExperimentalRolesFound
public void onSeveralExperimentalRolesFound(Collection<CvTerm> roles, FileSourceLocator locator)
onSeveralExperimentalRolesFound.
- Specified by:
onSeveralExperimentalRolesFound
in interfacePsiXmlParserListener
- Parameters:
roles
- aCollection
object.locator
- aFileSourceLocator
object.
-
onSeveralExperimentsFound
public void onSeveralExperimentsFound(Collection<Experiment> experiments, FileSourceLocator locator)
onSeveralExperimentsFound.
- Specified by:
onSeveralExperimentsFound
in interfacePsiXmlParserListener
- Parameters:
experiments
- aCollection
object.locator
- aFileSourceLocator
object.
-
onInvalidSyntax
public void onInvalidSyntax(FileSourceContext context, Exception e)
Listen to an invalid syntax causing an Exception- Specified by:
onInvalidSyntax
in interfaceMIFileParserListener
- Parameters:
context
- : file contexte
- aException
object.
-
onSyntaxWarning
public void onSyntaxWarning(FileSourceContext context, String message)
Listen to an event fired when the syntax of the file is valid but the content is not expected or some information may be lost.- Specified by:
onSyntaxWarning
in interfaceMIFileParserListener
- Parameters:
context
- : file contextmessage
- : warning message
-
onMissingCvTermName
public void onMissingCvTermName(CvTerm term, FileSourceContext context, String message)
Listen to an event fired when a CvTerm is read and does not have any names. At least a shortname is expected for each CvTerm so such a term may be loaded with an automatically generated shortname.- Specified by:
onMissingCvTermName
in interfaceMIFileParserListener
- Parameters:
term
- : cv without namecontext
- : file contextmessage
- : error message
-
onMissingInteractorName
public void onMissingInteractorName(Interactor interactor, FileSourceContext context)
Listen to an event fired when an interactor is read and does not have any names. At least a shortname is expected for each interactor so such an interactor may be loaded with an automatically generated shortname.- Specified by:
onMissingInteractorName
in interfaceMIFileParserListener
- Parameters:
interactor
- : interactor without namecontext
- : file context
-
onParticipantWithoutInteractor
public void onParticipantWithoutInteractor(Participant participant, FileSourceContext context)
Listen to en event fired when a Participant is read and no interactor details has been provided. In such a case, the interactor can be automatically generated as an unknown interactor- Specified by:
onParticipantWithoutInteractor
in interfaceMIFileParserListener
- Parameters:
participant
- : participant without interactorcontext
- : file context
-
onInteractionWithoutParticipants
public void onInteractionWithoutParticipants(Interaction interaction, FileSourceContext context)
Listen to an event fired when an interaction is read and does not have any participants. The interaction may be loaded as an empty interaction.- Specified by:
onInteractionWithoutParticipants
in interfaceMIFileParserListener
- Parameters:
interaction
- : interaction without participantscontext
- : file context
-
warning
public void warning(SAXParseException exception) throws SAXException
- Specified by:
warning
in interfaceErrorHandler
- Throws:
SAXException
-
error
public void error(SAXParseException exception) throws SAXException
- Specified by:
error
in interfaceErrorHandler
- Throws:
SAXException
-
fatalError
public void fatalError(SAXParseException exception) throws SAXException
- Specified by:
fatalError
in interfaceErrorHandler
- Throws:
SAXException
-
onInvalidOrganismTaxid
public void onInvalidOrganismTaxid(String taxid, FileSourceContext context)
Listen to an event fired when an organism does not have a valid taxid (positive integer or -1, -2, -3, -4, -5)- Specified by:
onInvalidOrganismTaxid
in interfaceMIFileParserListener
- Parameters:
taxid
- : invalid taxidcontext
- : file context
-
onMissingParameterValue
public void onMissingParameterValue(FileSourceContext context)
Listen to an event fired when a parameter does not have a value- Specified by:
onMissingParameterValue
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
onMissingParameterType
public void onMissingParameterType(FileSourceContext context)
Listen to an event fired when a parameter does not have a type- Specified by:
onMissingParameterType
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
onMissingConfidenceValue
public void onMissingConfidenceValue(FileSourceContext context)
Listen to an event fired when a confidence does not have a value- Specified by:
onMissingConfidenceValue
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
onMissingConfidenceType
public void onMissingConfidenceType(FileSourceContext context)
Listen to an event fired when a confidence does not have a confidence type- Specified by:
onMissingConfidenceType
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
onMissingChecksumValue
public void onMissingChecksumValue(FileSourceContext context)
Listen to an event fired when a checksum does not have a value- Specified by:
onMissingChecksumValue
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
onMissingChecksumMethod
public void onMissingChecksumMethod(FileSourceContext context)
Listen to an event fired when a checksum does not have a method- Specified by:
onMissingChecksumMethod
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
onInvalidPosition
public void onInvalidPosition(String message, FileSourceContext context)
Listen to an event fired when a position is not valid- Specified by:
onInvalidPosition
in interfaceMIFileParserListener
- Parameters:
message
- : error messagecontext
- : file context
-
onInvalidRange
public void onInvalidRange(String message, FileSourceContext context)
Listen to an event fired when a range is not valid- Specified by:
onInvalidRange
in interfaceMIFileParserListener
- Parameters:
message
- : error messagecontext
- : file context
-
onInvalidStoichiometry
public void onInvalidStoichiometry(String message, FileSourceContext context)
Listen to an event fired when a stoichiometry is not valid- Specified by:
onInvalidStoichiometry
in interfaceMIFileParserListener
- Parameters:
message
- : : error messagecontext
- : file context
-
onXrefWithoutDatabase
public void onXrefWithoutDatabase(FileSourceContext context)
Listen to an event fired when a xref does not have a database- Specified by:
onXrefWithoutDatabase
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
onXrefWithoutId
public void onXrefWithoutId(FileSourceContext context)
Listen to an event fired when a xref does not have an id- Specified by:
onXrefWithoutId
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
onAnnotationWithoutTopic
public void onAnnotationWithoutTopic(FileSourceContext context)
Listen to an event fired when an annotation does not have a topic- Specified by:
onAnnotationWithoutTopic
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
onAliasWithoutName
public void onAliasWithoutName(FileSourceContext context)
Listen to an event fired when an alias does not have a name- Specified by:
onAliasWithoutName
in interfaceMIFileParserListener
- Parameters:
context
- : file context
-
initialiseXmlParser
protected abstract void initialiseXmlParser(Reader reader)
initialiseXmlParser.
- Parameters:
reader
- aReader
object.
-
initialiseXmlParser
protected abstract void initialiseXmlParser(File file)
initialiseXmlParser.
- Parameters:
file
- aFile
object.
-
initialiseXmlParser
protected abstract void initialiseXmlParser(InputStream input)
initialiseXmlParser.
- Parameters:
input
- aInputStream
object.
-
initialiseXmlParser
protected abstract void initialiseXmlParser(URL url)
initialiseXmlParser.
- Parameters:
url
- aURL
object.
-
setXmlFileParserListener
protected void setXmlFileParserListener(PsiXmlParserListener listener)
setXmlFileParserListener.
- Parameters:
listener
- aPsiXmlParserListener
object.
-
setMIFileParserListener
protected void setMIFileParserListener(MIFileParserListener listener)
setMIFileParserListener.
- Parameters:
listener
- aMIFileParserListener
object.
-
reInit
protected void reInit() throws MIIOException
reInit.
- Throws:
MIIOException
- if any.
-
initialiseExpansionMethod
protected abstract void initialiseExpansionMethod(ComplexExpansionMethod<? extends Interaction,? extends BinaryInteraction> expansionMethod)
initialiseExpansionMethod.
- Parameters:
expansionMethod
- aComplexExpansionMethod
object.
-
createXmlIterator
protected abstract Iterator<T> createXmlIterator()
createXmlIterator.
- Returns:
- a
Iterator
object.
-
getParser
protected PsiXmlParser<T> getParser()
Getter for the field
parser
.- Returns:
- a
PsiXmlParser
object.
-
setParser
protected void setParser(PsiXmlParser<T> parser)
Setter for the field
parser
.- Parameters:
parser
- aPsiXmlParser
object.
-
isInitialised
protected boolean isInitialised()
isInitialised.
- Returns:
- a boolean.
-
getElementCache
protected PsiXmlIdCache getElementCache()
Getter for the field
elementCache
.- Returns:
- a
PsiXmlIdCache
object.
-
-