public class SBMLErrorLog extends XMLErrorLog
This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.
The error log is a list. Each SBMLDocument
maintains its own
SBMLErrorLog
. When a libSBML operation on SBML content results in an
error, or when there is something worth noting about the SBML content,
the issue is reported as an SBMLError
object stored in the SBMLErrorLog
list.
SBMLErrorLog
is derived from XMLErrorLog
, an object class that serves
exactly the same purpose but for the XML parsing layer. XMLErrorLog
provides crucial methods such as
XMLErrorLog.getNumErrors()
for determining how many SBMLError
or XMLError
objects are in the log.
SBMLErrorLog
inherits these methods.
The general approach to working with SBMLErrorLog
in user programs
involves first obtaining a pointer to a log from a libSBML object such
as SBMLDocument
. Callers should then use
XMLErrorLog.getNumErrors()
to inquire how
many objects there are in the list. (The answer may be 0.) If there is
at least one SBMLError
object in the SBMLErrorLog
instance, callers can
then iterate over the list using
SBMLErrorLog.getError(long n)
,
using methods provided by the SBMLError
class to find out the error code
and associated information such as the error severity, the message, and
the line number in the input.
If you wish to simply print the error strings for a human to read, an
easier and more direct way might be to use SBMLDocument.printErrors()
.
SBMLError
,
XMLErrorLog
,
XMLError
Modifier and Type | Method and Description |
---|---|
boolean |
contains(long errorId)
Returns true if
SBMLErrorLog contains an errorId |
void |
delete()
Explicitly deletes the underlying native object.
|
SBMLError |
getError(long n)
Returns the nth
SBMLError object in this log. |
long |
getNumFailsWithSeverity(long severity)
Returns the number of errors that have been logged with the given
severity code.
|
void |
remove(long errorId)
Removes an error having errorId from the
SBMLError list. |
clearLog, equals, getNumErrors, hashCode, printErrors, printErrors, toString
public boolean contains(long errorId)
SBMLErrorLog
contains an errorId
errorId
- the error identifier of the error to be found.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 SBMLErrorLog.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 SBMLErrorLog.delete()
themselves.
delete
 in class XMLErrorLog
public SBMLError getError(long n)
SBMLError
object in this log.
Index n
is counted from 0. Callers should first inquire about the
number of items in the log by using the
XMLErrorLog.getNumErrors()
method.
Attempts to use an error index number that exceeds the actual number
of errors in the log will result in a null
being returned.
getError
 in class XMLErrorLog
n
- the index number of the error to retrieve (with 0 being the
first error).
SBMLError
in this log, or null
if n
is
greater than or equal to
XMLErrorLog.getNumErrors()
.
XMLErrorLog.getNumErrors()
public long getNumFailsWithSeverity(long severity)
LibSBML associates severity levels with every SBMLError
object to
provide an indication of how serious the problem is. Severities range
from informational diagnostics to fatal (irrecoverable) errors. Given
an SBMLError
object instance, a caller can interrogate it for its
severity level using methods such as XMLError.getSeverity()
,
XMLError.isFatal()
, and so on. The present method encapsulates
iteration and interrogation of all objects in an SBMLErrorLog
, making
it easy to check for the presence of error objects with specific
severity levels.
severity
- a
value from the set of LIBSBML_SEV_
constants defined by
the interface class libsbmlConstants
XMLErrorLog.getNumErrors()