org.sbml.jsbml.xml.stax
public class SBMLReader extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.List<AnnotationReader> |
annotationParsers |
private MathContainer |
astNodeParent
The parent of the mathML we are parsing through the readMathML methods.
|
private java.util.Map<java.lang.String,ReadingParser> |
initializedParsers
Contains all the initialized parsers.
|
private static SBMLCoreParser |
sbmlCoreParser
Initialize a static instance of the core parser.
|
Constructor and Description |
---|
SBMLReader() |
Modifier and Type | Method and Description |
---|---|
private void |
addAnnotationParsers(javax.xml.stream.events.StartElement startElement)
Associates any unknown namespaces with the
AnnotationParser . |
void |
initializeAnnotationParsers()
Initializes the packageParser
HashMap of this class. |
private java.util.Map<java.lang.String,ReadingParser> |
initializePackageParsers()
Creates the ReadingParser instances and stores them in a
HashMap.
|
static void |
main(java.lang.String[] args)
Reads the file that is passed as argument and write it to the console,
using the method
SBMLWriter.write(SBMLDocument, java.io.OutputStream) . |
private void |
processAttributes(java.util.Iterator<javax.xml.stream.events.Attribute> att,
javax.xml.namespace.QName currentNode,
java.util.Stack<java.lang.Object> sbmlElements,
ReadingParser parser,
boolean hasAttributes,
boolean isInsideAnnotation)
Process Attributes of the current element on the stack.
|
private SBMLDocument |
processEndElement(javax.xml.namespace.QName currentNode,
java.lang.Boolean isNested,
java.lang.Boolean isText,
java.lang.Boolean isHTML,
int level,
int version,
ReadingParser parser,
java.util.Stack<java.lang.Object> sbmlElements,
boolean isInsideAnnotation)
Process the end of an element.
|
private void |
processNamespaces(java.util.Iterator<javax.xml.stream.events.Namespace> nam,
javax.xml.namespace.QName currentNode,
java.util.Stack<java.lang.Object> sbmlElements,
ReadingParser parser,
boolean hasAttributes)
Process Namespaces of the current element on the stack.
|
private ReadingParser |
processStartElement(javax.xml.stream.events.StartElement startElement,
javax.xml.namespace.QName currentNode,
java.lang.Boolean isHTML,
java.util.Stack<java.lang.Object> sbmlElements,
boolean isInsideAnnotation)
Process a
StartElement event. |
ASTNode |
readMathML(java.lang.String mathML) |
ASTNode |
readMathML(java.lang.String mathML,
TreeNodeChangeListener listener)
Reads a mathML String into an
ASTNode . |
ASTNode |
readMathML(java.lang.String mathML,
TreeNodeChangeListener listener,
MathContainer parent)
Reads a mathML
String into an ASTNode . |
XMLNode |
readNotes(java.lang.String notesXHTML) |
XMLNode |
readNotes(java.lang.String notesXHTML,
TreeNodeChangeListener listener)
Reads a notes XML
String into an XMLNode . |
SBMLDocument |
readSBML(java.io.File file) |
SBMLDocument |
readSBML(java.io.File file,
TreeNodeChangeListener listener)
Reads a SBML String from the given file.
|
SBMLDocument |
readSBML(java.lang.String file)
Reads SBML from a given file.
|
SBMLDocument |
readSBML(javax.xml.stream.XMLEventReader xmlEventReader) |
SBMLDocument |
readSBML(javax.xml.stream.XMLEventReader xmlEventReader,
TreeNodeChangeListener listener)
Reads an
SBMLDocument from the given XMLEventReader |
SBMLDocument |
readSBMLFile(java.lang.String fileName)
Reads the SBML file 'fileName' and creates/initialises a SBMLDocument
instance.
|
SBMLDocument |
readSBMLFromStream(java.io.InputStream stream) |
SBMLDocument |
readSBMLFromStream(java.io.InputStream stream,
TreeNodeChangeListener listener)
Reads a SBML document from the given
stream . |
SBMLDocument |
readSBMLFromString(java.lang.String xml) |
SBMLDocument |
readSBMLFromString(java.lang.String xml,
TreeNodeChangeListener listener)
Reads a SBML model from the given XML String.
|
private java.lang.Object |
readXMLFromStream(java.io.InputStream stream,
TreeNodeChangeListener listener)
Reads a XML document from the given
stream . |
private java.lang.Object |
readXMLFromString(java.lang.String xml,
TreeNodeChangeListener listener)
Reads an XML
String that should the part of a SBML model. |
private java.lang.Object |
readXMLFromXMLEventReader(javax.xml.stream.XMLEventReader xmlEventReader,
TreeNodeChangeListener listener)
Reads an XML document from the given
XMLEventReader . |
private java.util.Map<java.lang.String,ReadingParser> initializedParsers
private MathContainer astNodeParent
private java.util.List<AnnotationReader> annotationParsers
private static SBMLCoreParser sbmlCoreParser
private java.util.Map<java.lang.String,ReadingParser> initializePackageParsers()
private void addAnnotationParsers(javax.xml.stream.events.StartElement startElement)
AnnotationParser
.public void initializeAnnotationParsers()
HashMap
of this class.public static void main(java.lang.String[] args) throws java.io.IOException, javax.xml.stream.XMLStreamException, SBMLException
SBMLWriter.write(SBMLDocument, java.io.OutputStream)
.args
- the command line arguments, we are taking the first one as
the file name to read.java.io.IOException
- if the file name is not valid.SBMLException
- if there are any problems reading or writing the SBML model.javax.xml.stream.XMLStreamException
- if there are any problems reading or writing the XML file.public SBMLDocument readSBML(java.io.File file) throws java.io.IOException, javax.xml.stream.XMLStreamException
file
- javax.xml.stream.XMLStreamException
java.io.IOException
public SBMLDocument readSBML(java.io.File file, TreeNodeChangeListener listener) throws java.io.IOException, javax.xml.stream.XMLStreamException
file
- A file containing SBML content.java.io.IOException
javax.xml.stream.XMLStreamException
public SBMLDocument readSBML(java.lang.String file) throws javax.xml.stream.XMLStreamException, java.io.IOException
file
- The path to an SBML file.javax.xml.stream.XMLStreamException
java.io.IOException
public SBMLDocument readSBMLFile(java.lang.String fileName) throws javax.xml.stream.XMLStreamException, java.io.IOException
fileName
- name of the SBML file to read.javax.xml.stream.XMLStreamException
java.io.IOException
public SBMLDocument readSBML(javax.xml.stream.XMLEventReader xmlEventReader, TreeNodeChangeListener listener) throws javax.xml.stream.XMLStreamException
SBMLDocument
from the given XMLEventReader
xmlEventReader
- listener
- javax.xml.stream.XMLStreamException
public SBMLDocument readSBML(javax.xml.stream.XMLEventReader xmlEventReader) throws javax.xml.stream.XMLStreamException
xmlEventReader
- javax.xml.stream.XMLStreamException
public ASTNode readMathML(java.lang.String mathML, TreeNodeChangeListener listener) throws javax.xml.stream.XMLStreamException
ASTNode
.mathML
- listener
- ASTNode
representing the given mathML String.javax.xml.stream.XMLStreamException
public ASTNode readMathML(java.lang.String mathML, TreeNodeChangeListener listener, MathContainer parent) throws javax.xml.stream.XMLStreamException
String
into an ASTNode
.mathML
- listener
- parent
- the parent MathContainer
of the mathML to parseASTNode
representing the given mathML String
.javax.xml.stream.XMLStreamException
public ASTNode readMathML(java.lang.String mathML) throws javax.xml.stream.XMLStreamException
mathML
- javax.xml.stream.XMLStreamException
public XMLNode readNotes(java.lang.String notesXHTML, TreeNodeChangeListener listener) throws javax.xml.stream.XMLStreamException
String
into an XMLNode
.notesXHTML
- listener
- XMLNode
representing the given notes String
.javax.xml.stream.XMLStreamException
public XMLNode readNotes(java.lang.String notesXHTML) throws javax.xml.stream.XMLStreamException
notesXHTML
- javax.xml.stream.XMLStreamException
public SBMLDocument readSBMLFromStream(java.io.InputStream stream, TreeNodeChangeListener listener) throws javax.xml.stream.XMLStreamException
stream
.stream
- listener
- javax.xml.stream.XMLStreamException
public SBMLDocument readSBMLFromStream(java.io.InputStream stream) throws javax.xml.stream.XMLStreamException
stream
- javax.xml.stream.XMLStreamException
private java.lang.Object readXMLFromStream(java.io.InputStream stream, TreeNodeChangeListener listener) throws javax.xml.stream.XMLStreamException
stream
. It need to be a self contain part of
an SBML document.stream
- listener
- javax.xml.stream.XMLStreamException
private java.lang.Object readXMLFromXMLEventReader(javax.xml.stream.XMLEventReader xmlEventReader, TreeNodeChangeListener listener) throws javax.xml.stream.XMLStreamException
XMLEventReader
. It need to represent a self contain part of
an SBML document. It can be either a math element, a notes element or the whole SBML model. If math or notes are given,
a Rule containing the math or notes will be returned, otherwise an SBMLDocument is returned.xmlEventReader
- listener
- Object
representing the given XML.javax.xml.stream.XMLStreamException
public SBMLDocument readSBMLFromString(java.lang.String xml, TreeNodeChangeListener listener) throws javax.xml.stream.XMLStreamException
xml
- listener
- javax.xml.stream.XMLStreamException
public SBMLDocument readSBMLFromString(java.lang.String xml) throws javax.xml.stream.XMLStreamException
xml
- javax.xml.stream.XMLStreamException
private java.lang.Object readXMLFromString(java.lang.String xml, TreeNodeChangeListener listener) throws javax.xml.stream.XMLStreamException
String
that should the part of a SBML model.xml
- listener
- javax.xml.stream.XMLStreamException
private ReadingParser processStartElement(javax.xml.stream.events.StartElement startElement, javax.xml.namespace.QName currentNode, java.lang.Boolean isHTML, java.util.Stack<java.lang.Object> sbmlElements, boolean isInsideAnnotation)
StartElement
event.startElement
- currentNode
- isHTML
- initializedParsers
- sbmlElements
- private void processNamespaces(java.util.Iterator<javax.xml.stream.events.Namespace> nam, javax.xml.namespace.QName currentNode, java.util.Stack<java.lang.Object> sbmlElements, ReadingParser parser, boolean hasAttributes)
nam
- currentNode
- initializedParsers
- sbmlElements
- hasAttributes
- private void processAttributes(java.util.Iterator<javax.xml.stream.events.Attribute> att, javax.xml.namespace.QName currentNode, java.util.Stack<java.lang.Object> sbmlElements, ReadingParser parser, boolean hasAttributes, boolean isInsideAnnotation)
att
- currentNode
- initializedParsers
- sbmlElements
- parser
- hasAttributes
- private SBMLDocument processEndElement(javax.xml.namespace.QName currentNode, java.lang.Boolean isNested, java.lang.Boolean isText, java.lang.Boolean isHTML, int level, int version, ReadingParser parser, java.util.Stack<java.lang.Object> sbmlElements, boolean isInsideAnnotation)
currentNode
- isNested
- isText
- isHTML
- level
- version
- parser
- sbmlElements
- isRDFSBMLSpecificAnnotation
-