public class XMLInputStream extends java.lang.Object
Constructor and Description |
---|
XMLInputStream(java.lang.String content)
Creates a new
XMLInputStream . |
XMLInputStream(java.lang.String content,
boolean isFile)
Creates a new
XMLInputStream . |
XMLInputStream(java.lang.String content,
boolean isFile,
java.lang.String library)
Creates a new
XMLInputStream . |
XMLInputStream(java.lang.String content,
boolean isFile,
java.lang.String library,
XMLErrorLog errorLog)
Creates a new
XMLInputStream . |
Modifier and Type | Method and Description |
---|---|
void |
delete()
Explicitly deletes the underlying native object.
|
long |
determineNumberChildren()
Analyses the tokens in the stream and returns the number of
child tokens of the given element.
|
long |
determineNumberChildren(java.lang.String elementName)
Analyses the tokens in the stream and returns the number of
child tokens of the given element.
|
long |
determineNumSpecificChildren(java.lang.String childName,
java.lang.String container)
Analyses the tokens in the stream and returns the number of
child tokens of the specified type within the given element.
|
java.lang.String |
getEncoding()
Returns the encoding of the XML stream.
|
XMLErrorLog |
getErrorLog()
Returns an
XMLErrorLog which can be used to log XML parse errors and
other validation errors (and messages). |
SBMLNamespaces |
getSBMLNamespaces()
Returns the
SBMLNamespaces object attached to this XMLInputStream
if it has been set, null otherwise. |
java.lang.String |
getVersion()
Returns the version of the XML stream.
|
boolean |
isEOF()
Returns true if end of file (stream) has been reached, false
otherwise.
|
boolean |
isError()
Returns true if a fatal error occurred while reading from this stream.
|
boolean |
isGood()
Returns true if the stream is in a good state (i.e.
|
XMLToken |
next()
Consumes the next
XMLToken and return it. |
XMLToken |
peek()
Returns the next
XMLToken without consuming it. |
int |
setErrorLog(XMLErrorLog log)
Sets the
XMLErrorLog this stream will use to log errors. |
void |
setSBMLNamespaces(SBMLNamespaces sbmlns)
Sets the
SBMLNamespaces object to allow this stream to reference
the available SBML namespaces being read. |
void |
skipPastEnd(XMLToken element)
Consume zero or more XMLTokens up to and including the corresponding
end XML element or EOF.
|
void |
skipText()
Consume zero or more XMLTokens up to but not including the next XML
element or EOF.
|
java.lang.String |
toString()
Prints a string representation of the underlying token stream, for
debugging purposes.
|
public XMLInputStream(java.lang.String content)
XMLInputStream
.
content
the source of the stream.
isFile
boolean flag to indicate whether content
is a file name.
If true
, content
is assumed to be the file from which the XML
content is to be read. If false
, content
is taken to be a
string that is the content to be read.
library
the name of the parser library to use.
errorLog
the XMLErrorLog
object to use.
public XMLInputStream(java.lang.String content, boolean isFile)
XMLInputStream
.
content
the source of the stream.
isFile
boolean flag to indicate whether content
is a file name.
If true
, content
is assumed to be the file from which the XML
content is to be read. If false
, content
is taken to be a
string that is the content to be read.
library
the name of the parser library to use.
errorLog
the XMLErrorLog
object to use.
public XMLInputStream(java.lang.String content, boolean isFile, java.lang.String library)
XMLInputStream
.
content
the source of the stream.
isFile
boolean flag to indicate whether content
is a file name.
If true
, content
is assumed to be the file from which the XML
content is to be read. If false
, content
is taken to be a
string that is the content to be read.
library
the name of the parser library to use.
errorLog
the XMLErrorLog
object to use.
public XMLInputStream(java.lang.String content, boolean isFile, java.lang.String library, XMLErrorLog errorLog)
XMLInputStream
.
content
the source of the stream.
isFile
boolean flag to indicate whether content
is a file name.
If true
, content
is assumed to be the file from which the XML
content is to be read. If false
, content
is taken to be a
string that is the content to be read.
library
the name of the parser library to use.
errorLog
the XMLErrorLog
object to use.
public void delete()
In general, application software will not need to call this method directly. The Java language binding for libSBML is implemented as a language wrapper that provides a Java interface to libSBML's underlying C++/C code. Some of the Java methods return objects that are linked to objects created not by Java code, but by C++ code. The Java objects wrapped around them will be deleted when the garbage collector invokes the corresponding C++ finalize()
methods for the objects. The finalize()
methods in turn call the XMLInputStream.delete()
method on the libSBML object.
This method is exposed in case calling programs want to ensure that the underlying object is freed immediately, and not at some arbitrary time determined by the Java garbage collector. In normal usage, callers do not need to invoke XMLInputStream.delete()
themselves.
public long determineNumberChildren()
elementName
- a string representing the name of the element
for which the number of children are to be determined.
This function allows information from the input stream to be determined without the need to actually read and consume the tokens in the stream. This functionality is particularly utilized when reading MathML.
The function will return the number of child elements of the element represented by the elementName supplied, i.e. the number of child elements encountered before the closing tag for the elementname supplied. If the elementName has not been supplied then the function assumes that it is reading an apply element followed by a function element.
public long determineNumberChildren(java.lang.String elementName)
elementName
- a string representing the name of the element
for which the number of children are to be determined.
This function allows information from the input stream to be determined without the need to actually read and consume the tokens in the stream. This functionality is particularly utilized when reading MathML.
The function will return the number of child elements of the element represented by the elementName supplied, i.e. the number of child elements encountered before the closing tag for the elementname supplied. If the elementName has not been supplied then the function assumes that it is reading an apply element followed by a function element.
public long determineNumSpecificChildren(java.lang.String childName, java.lang.String container)
childName
- a string representing the name of the child
element whose number is to be determined.container
- a string representing the name of the element
for which the number of children are to be determined.
This function allows information from the input stream to be determined without the need to actually read and consume the tokens in the stream. This functionality is particularly utilized when reading MathML.
The function will return the number of child elements of the element represented by the childName supplied within the element specified by the container, i.e. the number of child elements encountered before the closing tag for the container supplied.
public java.lang.String getEncoding()
public XMLErrorLog getErrorLog()
XMLErrorLog
which can be used to log XML parse errors and
other validation errors (and messages).
XMLErrorLog
which can be used to log XML parse errors and
other validation errors (and messages).public SBMLNamespaces getSBMLNamespaces()
SBMLNamespaces
object attached to this XMLInputStream
if it has been set, null otherwise.
SBMLNamespaces
object or null if none has been set.public java.lang.String getVersion()
public boolean isEOF()
public boolean isError()
public boolean isGood()
public XMLToken next()
XMLToken
and return it.
XMLToken
or EOF (XMLToken.isEOF() == true).public XMLToken peek()
XMLToken
without consuming it. A subsequent call to
either peek() or next() will return the same token.
XMLToken
or EOF (XMLToken.isEOF() == true).public int setErrorLog(XMLErrorLog log)
XMLErrorLog
this stream will use to log errors.
public void setSBMLNamespaces(SBMLNamespaces sbmlns)
SBMLNamespaces
object to allow this stream to reference
the available SBML namespaces being read.public void skipPastEnd(XMLToken element)
public void skipText()
public java.lang.String toString()
toString
 in class java.lang.Object