public class MathMLStaxParser extends java.lang.Object implements ReadingParser
Modifier and Type | Field and Description |
---|---|
private short |
indent
The number of white spaces for the indent if this is to be used.
|
private boolean |
indenting
Decides whether or not the content of the MathML string should be
indented.
|
private boolean |
isFunctionDefinition |
static java.lang.String |
JSBML_MATH_COUNT |
private boolean |
lastElementWasApply |
private static org.apache.log4j.Logger |
logger
A
Logger for this class. |
private static java.util.List<java.lang.String> |
namespaces |
private boolean |
omitXMLDeclaration
If true no XML declaration will be written into the MathML output,
otherwise the XML version will appear at the beginning of the output.
|
private int |
piecewiseCount
integer used to count the number of piecewise elements open
|
private java.util.ArrayList<java.lang.Integer> |
piecewiseOtherwiseCount
list used to count the number of otherwise elements open related to a piecewise element.
|
private java.util.ArrayList<java.lang.Integer> |
piecewisePieceCount
list used to count the number of piece elements open related to a piecewise element.
|
Constructor and Description |
---|
MathMLStaxParser() |
Modifier and Type | Method and Description |
---|---|
int |
getIndent()
Returns the indent
|
boolean |
getIndenting()
Returns true if indenting
|
java.util.List<java.lang.String> |
getNamespaces()
Returns a
List of all the namespaces that this parser is handling. |
boolean |
getOmitXMLDeclaration()
Returns true if we need to omit the XML declaration.
|
boolean |
processAttribute(java.lang.String elementName,
java.lang.String attributeName,
java.lang.String value,
java.lang.String uri,
java.lang.String prefix,
boolean isLastAttribute,
java.lang.Object contextObject)
Process the XML attribute and modify 'contextObject' in consequence.
|
void |
processCharactersOf(java.lang.String elementName,
java.lang.String characters,
java.lang.Object contextObject)
Process the text of a XML element and modify 'contextObject' in
consequence.
|
void |
processEndDocument(SBMLDocument sbmlDocument)
Process the end of the document.
|
boolean |
processEndElement(java.lang.String elementName,
java.lang.String prefix,
boolean isNested,
java.lang.Object contextObject)
Process the end of the element 'elementName'.
|
private void |
processMathElement(java.lang.Object contextObject)
Process a
MathContainer to add one to the number of math element encountered. |
void |
processNamespace(java.lang.String elementName,
java.lang.String uri,
java.lang.String prefix,
java.lang.String localName,
boolean hasAttributes,
boolean isLastNamespace,
java.lang.Object contextObject)
Process the namespace and modify the contextObject in consequence.
|
java.lang.Object |
processStartElement(java.lang.String elementName,
java.lang.String uri,
java.lang.String prefix,
boolean hasAttributes,
boolean hasNamespaces,
java.lang.Object contextObject)
Process the XML element and modify 'contextObject' in consequence.
|
void |
setIndent(int indent) |
void |
setIndenting(boolean indenting) |
void |
setOmitXMLDeclaration(boolean omitXMLDeclaration) |
private short indent
private boolean indenting
private boolean omitXMLDeclaration
private static final transient org.apache.log4j.Logger logger
Logger
for this class.public static final java.lang.String JSBML_MATH_COUNT
private boolean lastElementWasApply
private boolean isFunctionDefinition
private int piecewiseCount
private java.util.ArrayList<java.lang.Integer> piecewisePieceCount
The size of the list should be equals to piecewiseCount.
private java.util.ArrayList<java.lang.Integer> piecewiseOtherwiseCount
The size of the list should be equals to piecewiseCount.
private static final java.util.List<java.lang.String> namespaces
public int getIndent()
public boolean getIndenting()
public boolean getOmitXMLDeclaration()
public boolean processAttribute(java.lang.String elementName, java.lang.String attributeName, java.lang.String value, java.lang.String uri, java.lang.String prefix, boolean isLastAttribute, java.lang.Object contextObject)
ReadingParser
For example, if the contextObject is an instance of Reaction
and the
attributeName is 'fast', this method will set the 'fast' variable of the
'contextObject' to 'value'. Then it will return the modified
Reaction
instance.
processAttribute
in interface ReadingParser
elementName
- the localName of the XML element.attributeName
- the attribute localName of the XML element.value
- the value of the XML attribute.prefix
- the attribute prefixisLastAttribute
- boolean value to know if this attribute is the last attribute of the
XML element.contextObject
- the object to set or modify depending on the identity of the current
attribute. This object
represents the context of the XML attribute in the SBMLDocument.public void processCharactersOf(java.lang.String elementName, java.lang.String characters, java.lang.Object contextObject)
ReadingParser
For example, if the contextObject is an instance of
Creator
and the elementName is 'Family',
this method will set the familyName of the 'contextObject' to the text
value. Then it will return the changed Creator
instance.
processCharactersOf
in interface ReadingParser
elementName
- the localName of the XML element.characters
- the text of this XML element.contextObject
- the object to set or modify depending on the identity of the current
element. This object
represents the context of the XML element in the SBMLDocument.public void processEndDocument(SBMLDocument sbmlDocument)
ReadingParser
processEndDocument
in interface ReadingParser
sbmlDocument
- the final initialized SBMLDocument instance.public boolean processEndElement(java.lang.String elementName, java.lang.String prefix, boolean isNested, java.lang.Object contextObject)
ReadingParser
processEndElement
in interface ReadingParser
elementName
- the localName of the XML element.prefix
- the prefix of the XML element.isNested
- boolean value to know if the XML element is a nested element.contextObject
- the object to set or modify depending on the identity of the current
element. This object
represents the context of the XML element in the SBMLDocument.true
to remove the contextObject from the stack, if
false
is returned the contextObject will stay on top
of the stackpublic void processNamespace(java.lang.String elementName, java.lang.String uri, java.lang.String prefix, java.lang.String localName, boolean hasAttributes, boolean isLastNamespace, java.lang.Object contextObject)
ReadingParser
For example, if the contextObject is an instance of SBMLDocument, the namespaces will be stored in the SBMLNamespaces HashMap of this SBMLDocument.
processNamespace
in interface ReadingParser
elementName
- the localName of the XML element.uri
- the URI of the namespaceprefix
- the prefix of the namespace.localName
- the localName of the namespace.hasAttributes
- boolean value to know if there are attributes after the namespace
declarations.isLastNamespace
- boolean value to know if this namespace is the last namespace of
this element.contextObject
- the object to set or modify depending on the identity of the current
element. This object
represents the context of the XML element in the SBMLDocument.public java.lang.Object processStartElement(java.lang.String elementName, java.lang.String uri, java.lang.String prefix, boolean hasAttributes, boolean hasNamespaces, java.lang.Object contextObject)
ReadingParser
For example, if the contextObject is an instance of Event
and the
elementName is 'trigger', this method will create a new Trigger
instance
and will set the trigger instance of the 'contextObject' to the new
Trigger
. Then the method will return the new Trigger
instance which is the
new environment.
processStartElement
in interface ReadingParser
elementName
- the localName of the XML element to processprefix
- the prefix of the XML element to processhasAttributes
- boolean value to know if this XML element has attributes.hasNamespaces
- boolean value to know if this XML element contains namespace
declarations.contextObject
- the object to set or modify depending on the identity of the current
XML element. This object
represents the context of the XML element in the SBMLDocument.private void processMathElement(java.lang.Object contextObject)
MathContainer
to add one to the number of math element encountered.contextObject
- a MathContainer
instancepublic void setIndent(int indent)
indent
- the indent to setpublic void setIndenting(boolean indenting)
indenting
- the indenting to setpublic void setOmitXMLDeclaration(boolean omitXMLDeclaration)
omitXMLDeclaration
- the omitXMLDeclaration to setpublic java.util.List<java.lang.String> getNamespaces()
ReadingParser
List
of all the namespaces that this parser is handling.getNamespaces
in interface ReadingParser
List
of all the namespaces that this parser is handling