org.sbml.jsbml.xml.stax
public class SBMLWriter extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private char |
indentChar
The symbol for indentation.
|
private short |
indentCount
The number of indentation symbols.
|
private java.util.HashMap<java.lang.String,WritingParser> |
instantiatedSBMLParsers
contains the WritingParser instances of this class.
|
private java.util.List<java.lang.String> |
issuedWarnings
Remember already issued warnings to avoid having multiple lines, saying
the same thing (Warning: Skipping detailed parsing of name space 'XYZ'.
|
(package private) org.apache.log4j.Logger |
logger |
private java.util.HashMap<java.lang.String,java.lang.Class<? extends WritingParser>> |
packageParsers
contains all the relationships name space URI <=> WritingParser class.
|
Constructor and Description |
---|
SBMLWriter()
|
SBMLWriter(char indentChar,
short indentCount)
Creates a new
SBMLWriter with the given configuration for the
indentChar and indentCount , i.e., the symbol to be used
to indent elements in the XML representation of SBML data objects and the
number of these symbols to be concatenated at the beginning of each new
line for a new element. |
Modifier and Type | Method and Description |
---|---|
private void |
addWritingParser(java.util.List<WritingParser> sbmlParsers,
WritingParser sbmlParser,
java.lang.String namespace)
Adds a
WritingParser to the given list of WritingParser |
private java.lang.String |
createIndentationString(int indent)
This method creates the necessary number of white spaces at the beginning
of an entry in the SBML file.
|
static char |
getDefaultIndentChar() |
static short |
getDefaultIndentCount() |
char |
getIndentationChar()
Gives the symbol that is used to indent the SBML output for a better
structure and to improve human-readability.
|
short |
getIndentationCount()
Gives the number of indent symbols that are inserted in a line to better structure the SBML output.
|
private java.util.List<WritingParser> |
getWritingParsers(java.lang.Object object,
java.lang.String namespace)
Gets all the writing parsers necessary to write the given object.
|
java.lang.Class<? extends WritingParser> |
getWritingParsers(java.lang.String namespace) |
void |
initializePackageParserNamespaces()
Initializes the packageParser
HasMap of this class. |
private java.util.Map<java.lang.String,WritingParser> |
initializePackageParsers()
Creates the ReadingParser instances and stores them in a HashMap.
|
static void |
main(java.lang.String[] args)
Tests this class
|
void |
setIndentationChar(char indentSymbol)
Allows you to set another blank character for indentation.
|
void |
setIndentationCount(int indentCount) |
void |
setIndentationCount(short indentCount) |
void |
write(SBMLDocument document,
java.io.File file) |
void |
write(SBMLDocument document,
java.io.File file,
java.lang.String programName,
java.lang.String programVersion) |
void |
write(SBMLDocument sbmlDocument,
java.io.OutputStream stream)
Writes the SBMLDocument in a SBML file.
|
void |
write(SBMLDocument sbmlDocument,
java.io.OutputStream stream,
java.lang.String programName,
java.lang.String programVersion) |
void |
write(SBMLDocument sbmlDocument,
java.lang.String fileName)
Writes the XML representation of an
SBMLDocument in a SBML file. |
void |
write(SBMLDocument sbmlDocument,
java.lang.String fileName,
java.lang.String programName,
java.lang.String programVersion) |
java.lang.String |
writeAnnotation(SBase sbase) |
private void |
writeAnnotation(SBase sbase,
SMOutputContainer element,
javax.xml.stream.XMLStreamWriter writer,
int indent,
boolean xmlFragment)
Writes the annotation of this sbase component.
|
private void |
writeCVTerms(java.util.List<CVTerm> listOfCVTerms,
java.util.Map<java.lang.String,java.lang.String> rdfNamespaces,
javax.xml.stream.XMLStreamWriter writer,
int indent)
Writes the listOfCVTerms.
|
private void |
writeHistory(History history,
java.util.Map<java.lang.String,java.lang.String> rdfNamespaces,
javax.xml.stream.XMLStreamWriter writer,
int indent)
Writes the history represented by this History instance.
|
private void |
writeMathML(MathContainer m,
SMOutputElement element,
javax.xml.stream.XMLStreamWriter writer,
int indent)
Writes the MathML expression for the math element of this sbase
component.
|
private void |
writeMessage(Constraint sbase,
SMOutputElement element,
javax.xml.stream.XMLStreamWriter writer,
java.lang.String sbmlNamespace,
int indent)
Writes the message of this Constraint.
|
private void |
writeNotes(SBase sbase,
SMOutputElement element,
javax.xml.stream.XMLStreamWriter writer,
java.lang.String sbmlNamespace,
int indent)
Writes the notes of this sbase component.
|
private void |
writeRDFAnnotation(Annotation annotation,
SMOutputElement annotationElement,
javax.xml.stream.XMLStreamWriter writer,
int indent)
Writes the RDF annotation contained in 'annotation'.
|
private void |
writeSBMLElements(SBMLObjectForXML parentXmlObject,
SMOutputElement smOutputParentElement,
javax.xml.stream.XMLStreamWriter streamWriter,
java.lang.Object objectToWrite,
int indent)
Writes the SBML elements.
|
java.lang.String |
writeSBMLToString(SBMLDocument doc)
Writes the given SBML document to an in-memory string.
|
java.lang.String |
writeSBMLToString(SBMLDocument d,
java.lang.String programName,
java.lang.String programVersion) |
private void |
writeW3CDate(javax.xml.stream.XMLStreamWriter writer,
int indent,
java.lang.String dateISO,
java.lang.String dcterm,
java.lang.String dctermPrefix,
java.lang.String rdfPrefix) |
private char indentChar
private short indentCount
private java.util.HashMap<java.lang.String,WritingParser> instantiatedSBMLParsers
private transient java.util.List<java.lang.String> issuedWarnings
org.apache.log4j.Logger logger
private java.util.HashMap<java.lang.String,java.lang.Class<? extends WritingParser>> packageParsers
public SBMLWriter()
public SBMLWriter(char indentChar, short indentCount)
SBMLWriter
with the given configuration for the
indentChar
and indentCount
, i.e., the symbol to be used
to indent elements in the XML representation of SBML data objects and the
number of these symbols to be concatenated at the beginning of each new
line for a new element.indentChar
- indentCount
- public static char getDefaultIndentChar()
public static short getDefaultIndentCount()
public static void main(java.lang.String[] args) throws SBMLException
args
- SBMLException
private void addWritingParser(java.util.List<WritingParser> sbmlParsers, WritingParser sbmlParser, java.lang.String namespace)
WritingParser
to the given list of WritingParser
sbmlParsers
- sbmlParser
- namespace
- private java.lang.String createIndentationString(int indent)
indent
- public char getIndentationChar()
public short getIndentationCount()
private java.util.List<WritingParser> getWritingParsers(java.lang.Object object, java.lang.String namespace)
object
- namespace
- public java.lang.Class<? extends WritingParser> getWritingParsers(java.lang.String namespace)
namespace
- public void initializePackageParserNamespaces()
HasMap
of this class.private java.util.Map<java.lang.String,WritingParser> initializePackageParsers()
public void setIndentationChar(char indentSymbol)
'\t'
and ' '
.the
- character to be used for indentation
the indentSymbol to setpublic void setIndentationCount(int indentCount)
indentCount
- setIndentationCount(short)
public void setIndentationCount(short indentCount)
indentCount
- the indentCount to setpublic void write(SBMLDocument document, java.io.File file) throws javax.xml.stream.XMLStreamException, SBMLException, java.io.IOException
document
- file
- SBMLException
javax.xml.stream.XMLStreamException
java.io.IOException
- if it is not possible to write to the given file, e.g., due
to an invalid file name or missing permissions.public void write(SBMLDocument document, java.io.File file, java.lang.String programName, java.lang.String programVersion) throws javax.xml.stream.XMLStreamException, SBMLException, java.io.IOException
document
- file
- programName
- programVersion
- javax.xml.stream.XMLStreamException
SBMLException
java.io.IOException
- if it is not possible to write to the given file, e.g., due
to an invalid file name or missing permissions.public void write(SBMLDocument sbmlDocument, java.io.OutputStream stream) throws javax.xml.stream.XMLStreamException, SBMLException
sbmlDocument
- : the SBMLDocument to writestream
- : a stream where to write the content of the model to.javax.xml.stream.XMLStreamException
SBMLException
java.io.IOException
public void write(SBMLDocument sbmlDocument, java.io.OutputStream stream, java.lang.String programName, java.lang.String programVersion) throws javax.xml.stream.XMLStreamException, SBMLException
sbmlDocument
- stream
- programName
- can be nullprogramVersion
- can be nulljavax.xml.stream.XMLStreamException
SBMLException
public void write(SBMLDocument sbmlDocument, java.lang.String fileName) throws javax.xml.stream.XMLStreamException, java.io.FileNotFoundException, SBMLException
SBMLDocument
in a SBML file.sbmlDocument
- : the SBMLDocument to writefileName
- : the name of the file where to write the SBMLDocument
javax.xml.stream.XMLStreamException
- if any error occur while creating the XML document.java.io.FileNotFoundException
- if the file name is invalidSBMLException
public void write(SBMLDocument sbmlDocument, java.lang.String fileName, java.lang.String programName, java.lang.String programVersion) throws javax.xml.stream.XMLStreamException, java.io.FileNotFoundException, SBMLException
sbmlDocument
- fileName
- programName
- programVersion
- javax.xml.stream.XMLStreamException
java.io.FileNotFoundException
SBMLException
public java.lang.String writeAnnotation(SBase sbase)
sbase
- private void writeAnnotation(SBase sbase, SMOutputContainer element, javax.xml.stream.XMLStreamWriter writer, int indent, boolean xmlFragment) throws javax.xml.stream.XMLStreamException, SBMLException
sbase
- : the sbase componentelement
- : the matching SMOutputElementwriter
- : the XMLStreamWriter2sbmlNamespace
- : the SBML namespace.indent
- the number of indent white spaces of this annotation.javax.xml.stream.XMLStreamException
SBMLException
org.xml.sax.SAXException
private void writeCVTerms(java.util.List<CVTerm> listOfCVTerms, java.util.Map<java.lang.String,java.lang.String> rdfNamespaces, javax.xml.stream.XMLStreamWriter writer, int indent) throws javax.xml.stream.XMLStreamException
listOfCVTerms
- : the list of CVTerms to writerdfNamespaces
- : the RDF name spaces and prefixeswriter
- : the XMLStreamWriter2indent
- javax.xml.stream.XMLStreamException
private void writeHistory(History history, java.util.Map<java.lang.String,java.lang.String> rdfNamespaces, javax.xml.stream.XMLStreamWriter writer, int indent) throws javax.xml.stream.XMLStreamException
history
- : the history to writerdfNamespaces
- : contains the RDF namespaces and their prefixes.writer
- : the XMLStreamWriter2indent
- javax.xml.stream.XMLStreamException
private void writeMathML(MathContainer m, SMOutputElement element, javax.xml.stream.XMLStreamWriter writer, int indent) throws javax.xml.stream.XMLStreamException
m
- : the sbase componentelement
- : the matching SMOutputElementwriter
- : the XMLStreamWriterindent
- javax.xml.stream.XMLStreamException
private void writeMessage(Constraint sbase, SMOutputElement element, javax.xml.stream.XMLStreamWriter writer, java.lang.String sbmlNamespace, int indent) throws javax.xml.stream.XMLStreamException
sbase
- : the Constraint componentelement
- : the matching SMOUtputElementwriter
- : the XMLStreamWriter2sbmlNamespace
- : the SBML namespacejavax.xml.stream.XMLStreamException
private void writeNotes(SBase sbase, SMOutputElement element, javax.xml.stream.XMLStreamWriter writer, java.lang.String sbmlNamespace, int indent) throws javax.xml.stream.XMLStreamException
sbase
- : the SBase componentelement
- : the matching SMOUtputElementwriter
- : the XMLStreamWriter2sbmlNamespace
- : the SBML namespaceindent
- javax.xml.stream.XMLStreamException
private void writeRDFAnnotation(Annotation annotation, SMOutputElement annotationElement, javax.xml.stream.XMLStreamWriter writer, int indent) throws javax.xml.stream.XMLStreamException
annotation
- : the annotation to writeannotationElement
- : the matching SMOutputElementwriter
- : the XMLStreamWriter.indent
- javax.xml.stream.XMLStreamException
private void writeSBMLElements(SBMLObjectForXML parentXmlObject, SMOutputElement smOutputParentElement, javax.xml.stream.XMLStreamWriter streamWriter, java.lang.Object objectToWrite, int indent) throws javax.xml.stream.XMLStreamException, SBMLException
parentXmlObject
- : contains the XML information of the parentElement.smOutputParentElement
- : SMOutputElement of the parentElement.streamWriter
- objectToWrite
- : the Object to write.notesParser
- : the WritingParser to parse the notes.MathMLparser
- : the WritingParser to parse the MathML expressions.indent
- The number of white spaces to indent this element.javax.xml.stream.XMLStreamException
SBMLException
org.xml.sax.SAXException
public java.lang.String writeSBMLToString(SBMLDocument doc) throws javax.xml.stream.XMLStreamException, SBMLException
doc
- the SBMLdocument
SBMLdocument
as a
String.javax.xml.stream.XMLStreamException
- if any error occur while creating the XML document.SBMLException
public java.lang.String writeSBMLToString(SBMLDocument d, java.lang.String programName, java.lang.String programVersion) throws javax.xml.stream.XMLStreamException, SBMLException
d
- programName
- programVersion
- javax.xml.stream.XMLStreamException
SBMLException
private void writeW3CDate(javax.xml.stream.XMLStreamWriter writer, int indent, java.lang.String dateISO, java.lang.String dcterm, java.lang.String dctermPrefix, java.lang.String rdfPrefix) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException