Package psidev.psi.mi.jami.xml.io.parser
Class AbstractPsiXmlParser<T extends Interaction>
- java.lang.Object
-
- psidev.psi.mi.jami.xml.io.parser.AbstractPsiXmlParser<T>
-
- All Implemented Interfaces:
PsiXmlParser<T>
- Direct Known Subclasses:
LightXmlParser
,XmlComplexParser
,XmlEvidenceParser
,XmlModelledParser
,XmlParser
public abstract class AbstractPsiXmlParser<T extends Interaction> extends Object implements PsiXmlParser<T>
Parser for PSI-XML Returns an Iterator of interactions. // Needs to parse each entry. Between each entry, clear the XmlEntryContext and resolve references // for each entry, read all experiments and interactors and stop when reading interactions- Since:
14/10/13
- Version:
- $Id$
- Author:
- Marine Dumousseau (marine@ebi.ac.uk)
-
-
Constructor Summary
Constructors Constructor Description AbstractPsiXmlParser(File file)
Constructor for AbstractPsiXmlParser.AbstractPsiXmlParser(InputStream inputStream)
Constructor for AbstractPsiXmlParser.AbstractPsiXmlParser(Reader reader)
Constructor for AbstractPsiXmlParser.AbstractPsiXmlParser(URL url)
Constructor for AbstractPsiXmlParser.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
close.protected boolean
containsUnresolvedReferences(XmlEntryContext entryContext)
containsUnresolvedReferences.protected abstract javax.xml.bind.Unmarshaller
createJAXBUnmarshaller()
createJAXBUnmarshaller.protected PsiXmlParserException
createPsiXmlExceptionFrom(String message, Exception e)
createPsiXmlExceptionFrom.protected String
getCurrentElement()
Getter for the fieldcurrentElement
.XmlInteractorFactory
getInteractorFactory()
Getter for the fieldinteractorFactory
.PsiXmlParserListener
getListener()
Getter for the fieldlistener
.protected String
getNextPsiXmlStartElement()
getNextPsiXmlStartElement.protected XMLStreamReader
getStreamReader()
Getter for the fieldstreamReader
.PsiXmlVersion
getVersion()
Getter for the fieldversion
.boolean
hasFinished()
hasFinished.protected void
loadEntry(XmlEntryContext entryContext, T currentInteraction)
Some interactions contains references and we want to load the remaining interactions until the end of the entryprotected void
parseAttributeList(XmlEntryContext entryContext)
parseAttributeList.protected void
parseAvailabilityList(XmlEntryContext entryContext)
parseAvailabilityList.protected void
parseExperimentList()
parseExperimentList.protected T
parseInteractionList(XmlEntryContext entryContext, T loadedInteraction)
parseInteractionList.protected T
parseInteractionTag(XmlEntryContext entryContext)
The unmarshaller must be able to return the expected interaction typeprotected void
parseInteractorList()
parseInteractorList.T
parseNextInteraction()
parseNextInteraction.protected T
parseNextPreLoadedInteraction()
parseNextPreLoadedInteraction.protected void
parseSource(XmlEntryContext entryContext)
parseSource.protected void
processAvailabilityList(XmlEntryContext entryContext)
processAvailabilityList.protected T
processEntry(XmlEntryContext entryContext)
Creates a new Entry, parses the entry and return the next available interactionprotected T
processEntryAndLoadNextInteraction(XmlEntryContext entryContext, Location startEntry)
Process an entry that is opened (source, experimentList, etc) and read the first interactionprotected void
processUnexpectedNode()
processUnexpectedNode.void
reInit()
reInit.void
setCacheOfObjects(PsiXmlIdCache indexOfObjects)
setCacheOfObjects.protected void
setCurrentElement(String currentElement)
Setter for the fieldcurrentElement
.void
setInteractorFactory(XmlInteractorFactory interactorFactory)
setInteractorFactory.void
setListener(PsiXmlParserListener listener)
setListener.protected void
skipNextElement()
skipNextElement.protected T
unmarshallInteraction()
unmarshallInteraction.
-
-
-
Constructor Detail
-
AbstractPsiXmlParser
public AbstractPsiXmlParser(File file)
Constructor for AbstractPsiXmlParser.
- Parameters:
file
- aFile
object.
-
AbstractPsiXmlParser
public AbstractPsiXmlParser(InputStream inputStream)
Constructor for AbstractPsiXmlParser.
- Parameters:
inputStream
- aInputStream
object.
-
AbstractPsiXmlParser
public AbstractPsiXmlParser(URL url)
Constructor for AbstractPsiXmlParser.
- Parameters:
url
- aURL
object.
-
-
Method Detail
-
parseNextInteraction
public T parseNextInteraction() throws PsiXmlParserException
parseNextInteraction.
- Specified by:
parseNextInteraction
in interfacePsiXmlParser<T extends Interaction>
- Returns:
- a T object.
- Throws:
PsiXmlParserException
- if any.
-
close
public void close() throws MIIOException
close.
- Specified by:
close
in interfacePsiXmlParser<T extends Interaction>
- Throws:
MIIOException
- if any.
-
hasFinished
public boolean hasFinished() throws PsiXmlParserException
hasFinished.
- Specified by:
hasFinished
in interfacePsiXmlParser<T extends Interaction>
- Returns:
- a boolean.
- Throws:
PsiXmlParserException
- if any.
-
reInit
public void reInit() throws MIIOException
reInit.
- Specified by:
reInit
in interfacePsiXmlParser<T extends Interaction>
- Throws:
MIIOException
- if any.
-
getListener
public PsiXmlParserListener getListener()
Getter for the field
listener
.- Specified by:
getListener
in interfacePsiXmlParser<T extends Interaction>
- Returns:
- a
PsiXmlParserListener
object.
-
setListener
public void setListener(PsiXmlParserListener listener)
setListener.
- Specified by:
setListener
in interfacePsiXmlParser<T extends Interaction>
- Parameters:
listener
- aPsiXmlParserListener
object.
-
setCacheOfObjects
public void setCacheOfObjects(PsiXmlIdCache indexOfObjects)
setCacheOfObjects.
- Specified by:
setCacheOfObjects
in interfacePsiXmlParser<T extends Interaction>
- Parameters:
indexOfObjects
- aPsiXmlIdCache
object.
-
getInteractorFactory
public XmlInteractorFactory getInteractorFactory()
Getter for the field
interactorFactory
.- Specified by:
getInteractorFactory
in interfacePsiXmlParser<T extends Interaction>
- Returns:
- a
XmlInteractorFactory
object.
-
setInteractorFactory
public void setInteractorFactory(XmlInteractorFactory interactorFactory)
setInteractorFactory.
- Specified by:
setInteractorFactory
in interfacePsiXmlParser<T extends Interaction>
- Parameters:
interactorFactory
- aXmlInteractorFactory
object.
-
getNextPsiXmlStartElement
protected String getNextPsiXmlStartElement() throws PsiXmlParserException
getNextPsiXmlStartElement.
- Returns:
- a
String
object. - Throws:
PsiXmlParserException
- if any.
-
createPsiXmlExceptionFrom
protected PsiXmlParserException createPsiXmlExceptionFrom(String message, Exception e)
createPsiXmlExceptionFrom.
- Parameters:
message
- aString
object.e
- aException
object.- Returns:
- a
PsiXmlParserException
object.
-
createJAXBUnmarshaller
protected abstract javax.xml.bind.Unmarshaller createJAXBUnmarshaller() throws javax.xml.bind.JAXBException
createJAXBUnmarshaller.
- Returns:
- the unmarshaller with the class context
- Throws:
javax.xml.bind.JAXBException
- if any.
-
processEntryAndLoadNextInteraction
protected T processEntryAndLoadNextInteraction(XmlEntryContext entryContext, Location startEntry) throws PsiXmlParserException
Process an entry that is opened (source, experimentList, etc) and read the first interaction- Parameters:
entryContext
- aXmlEntryContext
object.startEntry
- aLocation
object.- Returns:
- a T object.
- Throws:
PsiXmlParserException
- if any.
-
parseAttributeList
protected void parseAttributeList(XmlEntryContext entryContext) throws PsiXmlParserException
parseAttributeList.
- Parameters:
entryContext
- aXmlEntryContext
object.- Throws:
PsiXmlParserException
- if any.
-
parseInteractionList
protected T parseInteractionList(XmlEntryContext entryContext, T loadedInteraction) throws PsiXmlParserException
parseInteractionList.
- Parameters:
entryContext
- aXmlEntryContext
object.loadedInteraction
- a T object.- Returns:
- a T object.
- Throws:
PsiXmlParserException
- if any.
-
parseInteractorList
protected void parseInteractorList() throws PsiXmlParserException
parseInteractorList.
- Throws:
PsiXmlParserException
- if any.
-
parseExperimentList
protected void parseExperimentList() throws PsiXmlParserException
parseExperimentList.
- Throws:
PsiXmlParserException
- if any.
-
parseAvailabilityList
protected void parseAvailabilityList(XmlEntryContext entryContext) throws PsiXmlParserException
parseAvailabilityList.
- Parameters:
entryContext
- aXmlEntryContext
object.- Throws:
PsiXmlParserException
- if any.
-
parseSource
protected void parseSource(XmlEntryContext entryContext) throws PsiXmlParserException
parseSource.
- Parameters:
entryContext
- aXmlEntryContext
object.- Throws:
PsiXmlParserException
- if any.
-
processEntry
protected T processEntry(XmlEntryContext entryContext) throws PsiXmlParserException
Creates a new Entry, parses the entry and return the next available interaction- Parameters:
entryContext
- aXmlEntryContext
object.- Returns:
- a T object.
- Throws:
PsiXmlParserException
- if any.
-
loadEntry
protected void loadEntry(XmlEntryContext entryContext, T currentInteraction) throws PsiXmlParserException
Some interactions contains references and we want to load the remaining interactions until the end of the entry- Parameters:
entryContext
- aXmlEntryContext
object.currentInteraction
- a T object.- Throws:
PsiXmlParserException
- if any.
-
parseNextPreLoadedInteraction
protected T parseNextPreLoadedInteraction() throws PsiXmlParserException
parseNextPreLoadedInteraction.
- Returns:
- the next interaction preloaded in the interactionIterator. Deletes the returned interaction
- Throws:
PsiXmlParserException
- if any.
-
parseInteractionTag
protected T parseInteractionTag(XmlEntryContext entryContext) throws PsiXmlParserException
The unmarshaller must be able to return the expected interaction type- Parameters:
entryContext
- aXmlEntryContext
object.- Returns:
- next interaction parsed in the interaction list. Will load the all entry if we have references to solve
- Throws:
PsiXmlParserException
- if any.
-
containsUnresolvedReferences
protected boolean containsUnresolvedReferences(XmlEntryContext entryContext)
containsUnresolvedReferences.
- Parameters:
entryContext
- aXmlEntryContext
object.- Returns:
- a boolean.
-
unmarshallInteraction
protected T unmarshallInteraction() throws javax.xml.bind.JAXBException
unmarshallInteraction.
- Returns:
- a T object.
- Throws:
javax.xml.bind.JAXBException
- if any.
-
processAvailabilityList
protected void processAvailabilityList(XmlEntryContext entryContext) throws PsiXmlParserException
processAvailabilityList.
- Parameters:
entryContext
- aXmlEntryContext
object.- Throws:
PsiXmlParserException
- if any.
-
getStreamReader
protected XMLStreamReader getStreamReader()
Getter for the field
streamReader
.- Returns:
- a
XMLStreamReader
object.
-
getCurrentElement
protected String getCurrentElement()
Getter for the field
currentElement
.- Returns:
- a
String
object.
-
setCurrentElement
protected void setCurrentElement(String currentElement)
Setter for the field
currentElement
.- Parameters:
currentElement
- aString
object.
-
skipNextElement
protected void skipNextElement() throws PsiXmlParserException
skipNextElement.
- Throws:
PsiXmlParserException
- if any.
-
processUnexpectedNode
protected void processUnexpectedNode() throws PsiXmlParserException
processUnexpectedNode.
- Throws:
PsiXmlParserException
- if any.
-
getVersion
public PsiXmlVersion getVersion()
Getter for the field
version
.- Specified by:
getVersion
in interfacePsiXmlParser<T extends Interaction>
- Returns:
- a
PsiXmlVersion
object.
-
-