public class XMLToken extends java.lang.Object
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 libSBML XML parser interface can read an XML file or data stream and
convert the contents into tokens. The tokens represent items in the XML
stream, either XML elements (start or end tags) or text that appears as
content inside an element. The XMLToken
class is libSBML's low-level
representation of these entities.
Each XMLToken
has the following information associated with it:
<mytag>
, the name is
'mytag'
), but this name may be qualified with a namespace
(e.g., it may appear as <someNamespace:mytag>
in the
input). An XMLToken
stores the name of a token, along with any namespace
qualification present, through the use of an XMLTriple
object. This
object stores the bare name of the element, its XML namespace prefix (if
any), and the XML namespace with which that prefix is associated.
XMLNamespaces
object. An XMLToken
possesses a
field for storing an XMLNamespaces
object.
XMLAttributes
object stored in an
XMLToken
object. (Note: only elements can have attributes&mdashtext
blocks cannot have them in XML.)
The XMLToken
class serves as base class for XMLNode
. XML lends itself to
a tree-structured representation, and in libSBML, the nodes in an XML
document tree are XMLNode
objects. Most higher-level libSBML classes and
methods that offer XML-level functionality (such as the methods on SBase
for interacting with annotations) work with XMLNode
objects rather than
XMLToken
objects directly.
XMLNode
,
XMLTriple
,
XMLAttributes
,
XMLNamespaces
Constructor and Description |
---|
XMLToken()
Creates a new empty
XMLToken object. |
XMLToken(java.lang.String chars)
Creates a text object.
|
XMLToken(java.lang.String chars,
long line)
Creates a text object.
|
XMLToken(java.lang.String chars,
long line,
long column)
Creates a text object.
|
XMLToken(XMLToken orig)
Copy constructor creates a copy of this
XMLToken object. |
XMLToken(XMLTriple triple)
Creates an XML end element.
|
XMLToken(XMLTriple triple,
long line)
Creates an XML end element.
|
XMLToken(XMLTriple triple,
long line,
long column)
Creates an XML end element.
|
XMLToken(XMLTriple triple,
XMLAttributes attributes)
Creates an XML start element with attributes.
|
XMLToken(XMLTriple triple,
XMLAttributes attributes,
long line)
Creates an XML start element with attributes.
|
XMLToken(XMLTriple triple,
XMLAttributes attributes,
long line,
long column)
Creates an XML start element with attributes.
|
XMLToken(XMLTriple triple,
XMLAttributes attributes,
XMLNamespaces namespaces)
Creates an XML start element with attributes and namespace declarations.
|
XMLToken(XMLTriple triple,
XMLAttributes attributes,
XMLNamespaces namespaces,
long line)
Creates an XML start element with attributes and namespace declarations.
|
XMLToken(XMLTriple triple,
XMLAttributes attributes,
XMLNamespaces namespaces,
long line,
long column)
Creates an XML start element with attributes and namespace declarations.
|
Modifier and Type | Method and Description |
---|---|
int |
addAttr(java.lang.String name,
java.lang.String value)
Adds an attribute to the XML element represented by this token.
|
int |
addAttr(java.lang.String name,
java.lang.String value,
java.lang.String namespaceURI)
Adds an attribute to the XML element represented by this token.
|
int |
addAttr(java.lang.String name,
java.lang.String value,
java.lang.String namespaceURI,
java.lang.String prefix)
Adds an attribute to the XML element represented by this token.
|
int |
addAttr(XMLTriple triple,
java.lang.String value)
Adds an attribute to the XML element represented by this token.
|
int |
addNamespace(java.lang.String uri)
Appends an XML namespace declaration to this token.
|
int |
addNamespace(java.lang.String uri,
java.lang.String prefix)
Appends an XML namespace declaration to this token.
|
int |
append(java.lang.String chars)
Appends characters to the text content of token.
|
int |
clearAttributes()
Removes all attributes of this
XMLToken object. |
int |
clearNamespaces()
Removes all XML namespace declarations from this token.
|
XMLToken |
cloneObject()
Creates and returns a deep copy of this
XMLToken object. |
void |
delete()
Explicitly deletes the underlying native object.
|
boolean |
equals(java.lang.Object sb)
Equality comparison method for XMLToken.
|
XMLAttributes |
getAttributes()
Returns the attributes of the XML element represented by this token.
|
int |
getAttributesLength()
Returns the number of attributes on this
XMLToken object. |
int |
getAttrIndex(java.lang.String name)
Returns the index of the attribute with the given name and namespace
URI.
|
int |
getAttrIndex(java.lang.String name,
java.lang.String uri)
Returns the index of the attribute with the given name and namespace
URI.
|
int |
getAttrIndex(XMLTriple triple)
Returns the index of the attribute defined by the given
XMLTriple
object. |
java.lang.String |
getAttrName(int index)
Returns the name of the nth attribute in this token's list of
attributes.
|
java.lang.String |
getAttrPrefix(int index)
Returns the prefix of the nth attribute in this token's list of
attributes.
|
java.lang.String |
getAttrPrefixedName(int index)
Returns the prefixed name of the nth attribute in this token's
list of attributes.
|
java.lang.String |
getAttrURI(int index)
Returns the XML namespace URI of the nth attribute in this
token's list of attributes.
|
java.lang.String |
getAttrValue(int index)
Returns the value of the nth attribute in this token's list of
attributes.
|
java.lang.String |
getAttrValue(java.lang.String name)
Returns the value of the attribute with a given name and XML namespace URI.
|
java.lang.String |
getAttrValue(java.lang.String name,
java.lang.String uri)
Returns the value of the attribute with a given name and XML namespace URI.
|
java.lang.String |
getAttrValue(XMLTriple triple)
Returns the value of the attribute specified by a given
XMLTriple object. |
java.lang.String |
getCharacters()
Returns the character text of token.
|
long |
getColumn()
Returns the column number at which this token occurs in the input.
|
long |
getLine()
Returns the line number at which this token occurs in the input.
|
java.lang.String |
getName()
Returns the (unqualified) name of token.
|
int |
getNamespaceIndex(java.lang.String uri)
Returns the index of an XML namespace declaration based on its URI.
|
int |
getNamespaceIndexByPrefix(java.lang.String prefix)
Returns the index of an XML namespace declaration based on its prefix.
|
java.lang.String |
getNamespacePrefix(int index)
Returns the prefix of the nth XML namespace declaration.
|
java.lang.String |
getNamespacePrefix(java.lang.String uri)
Returns the prefix associated with a given XML namespace URI on this
token.
|
XMLNamespaces |
getNamespaces()
Returns the XML namespaces declared for this token.
|
int |
getNamespacesLength()
Returns the number of XML namespaces declared on this token.
|
java.lang.String |
getNamespaceURI()
Returns the URI of an XML namespace with a given prefix.
|
java.lang.String |
getNamespaceURI(int index)
Returns the URI of the nth XML namespace declared on this token.
|
java.lang.String |
getNamespaceURI(java.lang.String prefix)
Returns the URI of an XML namespace with a given prefix.
|
java.lang.String |
getPrefix()
Returns the XML namespace prefix of token.
|
java.lang.String |
getURI()
Returns the XML namespace URI of token.
|
boolean |
hasAttr(int index)
Returns
true if an attribute with the given index exists. |
boolean |
hasAttr(java.lang.String name)
Returns
true if an attribute with a given name and namespace URI
exists. |
boolean |
hasAttr(java.lang.String name,
java.lang.String uri)
Returns
true if an attribute with a given name and namespace URI
exists. |
boolean |
hasAttr(XMLTriple triple)
Returns
true if an attribute defined by a given XMLTriple object
exists. |
int |
hashCode()
Returns a hashcode for this XMLToken object.
|
boolean |
hasNamespaceNS(java.lang.String uri,
java.lang.String prefix)
Returns
true if this token has an XML namespace with a given prefix
and URI combination. |
boolean |
hasNamespacePrefix(java.lang.String prefix)
Returns
true if this token has an XML namespace with a given prefix. |
boolean |
hasNamespaceURI(java.lang.String uri)
Returns
true if this token has an XML namespace with a given URI. |
boolean |
isAttributesEmpty()
Returns
true if this token has no attributes. |
boolean |
isElement()
Returns
true if this token represents an XML element. |
boolean |
isEnd()
Returns
true if this token represents an XML end element. |
boolean |
isEndFor(XMLToken element)
Returns
true if this token represents an XML end element for a
particular start element. |
boolean |
isEOF()
Returns
true if this token is an end of file marker. |
boolean |
isNamespacesEmpty()
Returns
true if there are no namespaces declared on this token. |
boolean |
isStart()
Returns
true if this token represents an XML start element. |
boolean |
isText()
Returns
true if this token represents an XML text element. |
int |
removeAttr(int n)
Removes the nth attribute from the XML element represented by
this token.
|
int |
removeAttr(java.lang.String name)
Removes an attribute from the XML element represented by this token.
|
int |
removeAttr(java.lang.String name,
java.lang.String uri)
Removes an attribute from the XML element represented by this token.
|
int |
removeAttr(XMLTriple triple)
Removes an attribute from the XML element represented by this token.
|
int |
removeNamespace(int index)
Removes the nth XML namespace declaration.
|
int |
removeNamespace(java.lang.String prefix)
Removes an XML namespace declaration having a given prefix.
|
int |
setAttributes(XMLAttributes attributes)
Sets the attributes on the XML element represented by this token.
|
int |
setEnd()
Declares that this token represents an XML element end tag.
|
int |
setEOF()
Declares that this token is an end-of-file/input marker.
|
int |
setNamespaces(XMLNamespaces namespaces)
Sets the XML namespaces on this XML element.
|
int |
setTriple(XMLTriple triple)
Sets the name, namespace prefix and namespace URI of this token.
|
java.lang.String |
toString()
Prints a string representation of the underlying token stream.
|
int |
unsetEnd()
Declares that this token no longer represents an XML start/end element.
|
public XMLToken() throws XMLConstructorException
XMLToken
object.XMLConstructorException
public XMLToken(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line, long column) throws XMLConstructorException
triple
- an XMLTriple
object describing the start tag.
attributes
- XMLAttributes
, the attributes to set on the element to
be created.
namespaces
- XMLNamespaces
, the namespaces to set on the element to
be created.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
XMLConstructorException
public XMLToken(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line) throws XMLConstructorException
triple
- an XMLTriple
object describing the start tag.
attributes
- XMLAttributes
, the attributes to set on the element to
be created.
namespaces
- XMLNamespaces
, the namespaces to set on the element to
be created.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
XMLConstructorException
public XMLToken(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces) throws XMLConstructorException
triple
- an XMLTriple
object describing the start tag.
attributes
- XMLAttributes
, the attributes to set on the element to
be created.
namespaces
- XMLNamespaces
, the namespaces to set on the element to
be created.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
XMLConstructorException
public XMLToken(XMLTriple triple, XMLAttributes attributes, long line, long column) throws XMLConstructorException
triple
- an XMLTriple
object describing the start tag.
attributes
- XMLAttributes
, the attributes to set on the element to
be created.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
The XML namespace component of this XMLToken
object will be left empty.
See the other variants of the XMLToken
constructors for versions that
take namespace arguments.
XMLConstructorException
public XMLToken(XMLTriple triple, XMLAttributes attributes, long line) throws XMLConstructorException
triple
- an XMLTriple
object describing the start tag.
attributes
- XMLAttributes
, the attributes to set on the element to
be created.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
The XML namespace component of this XMLToken
object will be left empty.
See the other variants of the XMLToken
constructors for versions that
take namespace arguments.
XMLConstructorException
public XMLToken(XMLTriple triple, XMLAttributes attributes) throws XMLConstructorException
triple
- an XMLTriple
object describing the start tag.
attributes
- XMLAttributes
, the attributes to set on the element to
be created.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
The XML namespace component of this XMLToken
object will be left empty.
See the other variants of the XMLToken
constructors for versions that
take namespace arguments.
XMLConstructorException
public XMLToken(XMLTriple triple, long line, long column) throws XMLConstructorException
triple
- an XMLTriple
object describing the end tag.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
XMLConstructorException
public XMLToken(XMLTriple triple, long line) throws XMLConstructorException
triple
- an XMLTriple
object describing the end tag.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
XMLConstructorException
public XMLToken(XMLTriple triple) throws XMLConstructorException
triple
- an XMLTriple
object describing the end tag.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
XMLConstructorException
public XMLToken(java.lang.String chars, long line, long column) throws XMLConstructorException
chars
- a string, the text to be added to the XMLToken
object.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
XMLConstructorException
public XMLToken(java.lang.String chars, long line) throws XMLConstructorException
chars
- a string, the text to be added to the XMLToken
object.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
XMLConstructorException
public XMLToken(java.lang.String chars) throws XMLConstructorException
chars
- a string, the text to be added to the XMLToken
object.
line
- a long integer, the line number to associate with the
token (default = 0).
column
- a long integer, the column number to associate with the
token (default = 0).
XMLConstructorException
public XMLToken(XMLToken orig) throws XMLConstructorException
XMLToken
object.
orig
- the XMLToken
object to copy.XMLConstructorException
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 XMLToken.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 XMLToken.delete()
themselves.
public boolean equals(java.lang.Object sb)
Because the Java methods for libSBML are actually wrappers around code
implemented in C++ and C, certain operations will not behave as
expected. Equality comparison is one such case. An instance of a
libSBML object class is actually a proxy object
wrapping the real underlying C/C++ object. The normal ==
equality operator in Java will only compare the Java proxy objects,
not the underlying native object. The result is almost never what you
want in practical situations. Unfortunately, Java does not provide a
way to override ==
.
The alternative that must be followed is to use the
equals()
method. The equals
method on this
class overrides the default java.lang.Object one, and performs an
intelligent comparison of instances of objects of this class. The
result is an assessment of whether two libSBML Java objects are truly
the same underlying native-code objects.
The use of this method in practice is the same as the use of any other
Java equals
method. For example,
a.equals(
b)
returns
true
if a and b are references to the
same underlying object.
equals
 in class java.lang.Object
sb
- a reference to an object to which the current object
instance will be comparedtrue
if sb
refers to the same underlying
native object as this one, false
otherwisepublic int hashCode()
hashCode
 in class java.lang.Object
public XMLToken cloneObject()
XMLToken
object.
XMLToken
object.public XMLAttributes getAttributes()
XMLAttributes
object.public int setAttributes(XMLAttributes attributes)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
attributes
- an XMLAttributes
object to be assigned to this
XMLToken
object, thereby setting the XML attributes associated with this
token.
XMLAttributes
object
on this XMLToken
object with the one given by attributes
.public int addAttr(java.lang.String name, java.lang.String value, java.lang.String namespaceURI, java.lang.String prefix)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
name
- a string, the so-called 'local part' of the attribute name
that is, the attribute name without any namespace qualifier or prefix.
value
- a string, the value assigned to the attribute.
namespaceURI
- a string, the XML namespace URI of the attribute.
prefix
- a string, the prefix for the XML namespace.
Recall that in XML, the complete form of an attribute on an XML element is the following:
prefix:name='value'
name
part is the name of the attribute, the
'value'
part is the value assigned to the attribute (and
it is always a quoted string), and the prefix
part is
an optional XML namespace prefix. Internally in libSBML, this data
is stored in an XMLAttributes
object associated with this XMLToken
.
XMLToken
object, then the previous value will be replaced
with the new value provided to this method.
public int addAttr(java.lang.String name, java.lang.String value, java.lang.String namespaceURI)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
name
- a string, the so-called 'local part' of the attribute name
that is, the attribute name without any namespace qualifier or prefix.
value
- a string, the value assigned to the attribute.
namespaceURI
- a string, the XML namespace URI of the attribute.
prefix
- a string, the prefix for the XML namespace.
Recall that in XML, the complete form of an attribute on an XML element is the following:
prefix:name='value'
name
part is the name of the attribute, the
'value'
part is the value assigned to the attribute (and
it is always a quoted string), and the prefix
part is
an optional XML namespace prefix. Internally in libSBML, this data
is stored in an XMLAttributes
object associated with this XMLToken
.
XMLToken
object, then the previous value will be replaced
with the new value provided to this method.
public int addAttr(java.lang.String name, java.lang.String value)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
name
- a string, the so-called 'local part' of the attribute name
that is, the attribute name without any namespace qualifier or prefix.
value
- a string, the value assigned to the attribute.
namespaceURI
- a string, the XML namespace URI of the attribute.
prefix
- a string, the prefix for the XML namespace.
Recall that in XML, the complete form of an attribute on an XML element is the following:
prefix:name='value'
name
part is the name of the attribute, the
'value'
part is the value assigned to the attribute (and
it is always a quoted string), and the prefix
part is
an optional XML namespace prefix. Internally in libSBML, this data
is stored in an XMLAttributes
object associated with this XMLToken
.
XMLToken
object, then the previous value will be replaced
with the new value provided to this method.
public int addAttr(XMLTriple triple, java.lang.String value)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
triple
- an XMLTriple
object defining the attribute, its value,
and optionally its XML namespace (if any is provided).
value
- a string, the value assigned to the attribute.
XMLToken
object, then the previous value will be replaced
with the new value provided to this method.public int removeAttr(int n)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
n
- an integer the index of the resource to be deleted
The value LIBSBML_INDEX_EXCEEDS_SIZE
is returned if there is no attribute on this
element at the given index n
.
XMLToken.getAttrIndex(XMLTriple triple)
,
XMLToken.getAttrIndex(String name, String uri)
,
XMLToken.getAttributesLength()
public int removeAttr(java.lang.String name, java.lang.String uri)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
name
- a string, the name of the attribute to be removed.uri
- a string, the XML namespace URI of the attribute to be removed.
The value LIBSBML_INDEX_EXCEEDS_SIZE
is returned if there is no attribute on this
element with the given name
(and uri
if specified).
XMLToken.hasAttr(String name, String uri)
public int removeAttr(java.lang.String name)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
name
- a string, the name of the attribute to be removed.uri
- a string, the XML namespace URI of the attribute to be removed.
The value LIBSBML_INDEX_EXCEEDS_SIZE
is returned if there is no attribute on this
element with the given name
(and uri
if specified).
XMLToken.hasAttr(String name, String uri)
public int removeAttr(XMLTriple triple)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
triple
- an XMLTriple
describing the attribute to be removed.
The value LIBSBML_INDEX_EXCEEDS_SIZE
is returned if there is no attribute on this
element matching the properties of the given triple
.
XMLToken.hasAttr(XMLTriple triple)
public int clearAttributes()
XMLToken
object.
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
public int getAttrIndex(java.lang.String name, java.lang.String uri)
name
- a string, the name of the attribute.uri
- a string, the namespace URI of the attribute.
-1
if it is not present on this token.
public int getAttrIndex(java.lang.String name)
name
- a string, the name of the attribute.uri
- a string, the namespace URI of the attribute.
-1
if it is not present on this token.
public int getAttrIndex(XMLTriple triple)
XMLTriple
object.
public int getAttributesLength()
XMLToken
object.
XMLToken.hasAttr(int)
public java.lang.String getAttrName(int index)
index
- an integer, the position of the attribute whose name
is being sought.
n
in the list
of attributes possessed by this XMLToken
object.
XMLToken.hasAttr(int)
,
XMLToken.getAttributesLength()
index
is out of range, this method will return an empty
string. XMLToken.hasAttr(int)
can be used to test for an
attribute's existence explicitly, and XMLToken.getAttributesLength()
can
be used to find out the number of attributes possessed by this token.
public java.lang.String getAttrPrefix(int index)
index
- an integer, the position of the attribute whose prefix is
being sought.
n
in the list of attributes possessed by this XMLToken
object.
XMLToken.hasAttr(int)
,
XMLToken.getAttributesLength()
index
is out of range, this method will return an empty
string. XMLToken.hasAttr(int)
can be used to test for an
attribute's existence explicitly, and XMLToken.getAttributesLength()
can
be used to find out the number of attributes possessed by this token.
public java.lang.String getAttrPrefixedName(int index)
In this context, prefixed name means the name of the attribute
prefixed with the XML namespace prefix assigned to the attribute. This
will be a string of the form prefix:name
.
index
- an integer, the position of the attribute whose prefixed
name is being sought.
n
in the list of attributes possessed by this XMLToken
object.
index
is out of range, this method will return an empty
string. XMLToken.hasAttr(int)
can be used to test for an
attribute's existence explicitly, and XMLToken.getAttributesLength()
can
be used to find out the number of attributes possessed by this token.public java.lang.String getAttrURI(int index)
index
- an integer, the position of the attribute whose namespace
URI is being sought.
n
in the list of attributes possessed by this XMLToken
object.
index
is out of range, this method will return an empty
string. XMLToken.hasAttr(int)
can be used to test for an
attribute's existence explicitly, and XMLToken.getAttributesLength()
can
be used to find out the number of attributes possessed by this token.public java.lang.String getAttrValue(int index)
index
- an integer, the position of the attribute whose value is
required.
n
in the list
of attributes possessed by this XMLToken
object.
index
is out of range, this method will return an empty
string. XMLToken.hasAttr(int)
can be used to test for an
attribute's existence explicitly, and XMLToken.getAttributesLength()
can
be used to find out the number of attributes possessed by this token.public java.lang.String getAttrValue(java.lang.String name, java.lang.String uri)
name
- a string, the name of the attribute whose value is being
sought.
uri
- a string, the XML namespace URI of the attribute.
name
and uri
does not exist
on this token object, this method will return an empty string.
XMLToken.hasAttr(String, String)
can be used to test
explicitly for the presence of an attribute with a given name and
namespace.
public java.lang.String getAttrValue(java.lang.String name)
name
- a string, the name of the attribute whose value is being
sought.
uri
- a string, the XML namespace URI of the attribute.
name
and uri
does not exist
on this token object, this method will return an empty string.
XMLToken.hasAttr(String, String)
can be used to test
explicitly for the presence of an attribute with a given name and
namespace.
public java.lang.String getAttrValue(XMLTriple triple)
XMLTriple
object.
triple
- an XMLTriple
describing the attribute whose value is being
sought.
triple
does not exist on
this token object, this method will return an empty string.
XMLToken.hasAttr(XMLTriple)
can be used to test
explicitly for the existence of an attribute with the properties of
a given triple.public boolean hasAttr(int index)
true
if an attribute with the given index exists.
index
- an integer, the position of the attribute.
true
if this token object possesses an attribute with the
given index, false
otherwise.public boolean hasAttr(java.lang.String name, java.lang.String uri)
true
if an attribute with a given name and namespace URI
exists.
name
- a string, the name of the attribute being sought.
uri
- a string, the XML namespace URI of the attribute being
sought.
true
if an attribute with the given local name and namespace
URI exists in the list of attributes on this token object, false
otherwise.
public boolean hasAttr(java.lang.String name)
true
if an attribute with a given name and namespace URI
exists.
name
- a string, the name of the attribute being sought.
uri
- a string, the XML namespace URI of the attribute being
sought.
true
if an attribute with the given local name and namespace
URI exists in the list of attributes on this token object, false
otherwise.
public boolean hasAttr(XMLTriple triple)
true
if an attribute defined by a given XMLTriple
object
exists.
public boolean isAttributesEmpty()
true
if this token has no attributes.
true
if the list of attributes on XMLToken
object is empty,
false
otherwise.public XMLNamespaces getNamespaces()
public int setNamespaces(XMLNamespaces namespaces)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
namespaces
- the XMLNamespaces
object to be assigned to this XMLToken
object.
XMLNamespaces
object on this
XMLToken
object with the new one given by namespaces
.public int addNamespace(java.lang.String uri, java.lang.String prefix)
The namespace added will be defined by the given XML namespace URI and
an optional prefix. If this XMLToken
object already possesses an XML
namespace declaration with the given prefix
, then the existing XML
namespace URI will be overwritten by the new one given by uri
.
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
uri
- a string, the XML namespace URI for the namespace.
prefix
- a string, the namespace prefix to use.
public int addNamespace(java.lang.String uri)
The namespace added will be defined by the given XML namespace URI and
an optional prefix. If this XMLToken
object already possesses an XML
namespace declaration with the given prefix
, then the existing XML
namespace URI will be overwritten by the new one given by uri
.
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
uri
- a string, the XML namespace URI for the namespace.
prefix
- a string, the namespace prefix to use.
public int removeNamespace(int index)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
index
- an integer, the position of the namespace to be removed.
The position in this context refers to the position of the namespace in
the XMLNamespaces
object stored in this XMLToken
object. Callers can
use one of the getNamespace___()
methods to find the index
number of a given namespace.
XMLToken.getNamespaceIndex(String uri)
,
XMLToken.getNamespaceIndexByPrefix(String prefix)
,
XMLToken.getNamespacesLength()
public int removeNamespace(java.lang.String prefix)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
prefix
- a string, the prefix of the namespace to be removed.
The value LIBSBML_INDEX_EXCEEDS_SIZE
is returned if there is no namespace with the given prefix
on this
element.
XMLToken.getNamespaceIndexByPrefix(String prefix)
public int clearNamespaces()
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
public int getNamespaceIndex(java.lang.String uri)
uri
- a string, the XML namespace URI of the sought-after namespace.
-1
if
no such namespace URI is present on this XMLToken
object.public int getNamespaceIndexByPrefix(java.lang.String prefix)
prefix
- a string, the prefix of the sought-after XML namespace.
-1
if
no such namespace URI is present on this XMLToken
object.public int getNamespacesLength()
XMLNamespaces
object of this XMLToken
object.public java.lang.String getNamespacePrefix(int index)
index
- an integer, position of the required prefix.
XMLNamespaces
(by position).
XMLToken.getNamespacesLength()
index
is out of range, this method will return an empty
string. XMLToken.getNamespacesLength()
can be used to find out how
many namespaces are defined on this XMLToken
object.
public java.lang.String getNamespacePrefix(java.lang.String uri)
public java.lang.String getNamespaceURI(int index)
index
- an integer, the position of the sought-after XML namespace URI.
XMLNamespaces
object in this XMLToken
object.
XMLToken.getNamespacesLength()
index
is out of range, this method will return an empty string.
public java.lang.String getNamespaceURI(java.lang.String prefix)
prefix
- a string, the prefix of the sought-after XML namespace URI.
prefix
stored in
the XMLNamespaces
object of this XMLToken
object, this method will
return an empty string.
public java.lang.String getNamespaceURI()
prefix
- a string, the prefix of the sought-after XML namespace URI.
prefix
stored in
the XMLNamespaces
object of this XMLToken
object, this method will
return an empty string.
public boolean isNamespacesEmpty()
true
if there are no namespaces declared on this token.
true
if the XMLNamespaces
object stored in this XMLToken
token is empty, false
otherwise.public boolean hasNamespaceURI(java.lang.String uri)
true
if this token has an XML namespace with a given URI.
uri
- a string, the URI of the XML namespace.
true
if an XML namespace with the given URI is contained in
the XMLNamespaces
object of this XMLToken
object, false
otherwise.public boolean hasNamespacePrefix(java.lang.String prefix)
true
if this token has an XML namespace with a given prefix.
prefix
- a string, the prefix for the XML namespace.
true
if an XML Namespace with the given URI is contained in the
XMLNamespaces
of this XMLToken
, false
otherwise.public boolean hasNamespaceNS(java.lang.String uri, java.lang.String prefix)
true
if this token has an XML namespace with a given prefix
and URI combination.
uri
- a string, the URI for the namespace.prefix
- a string, the prefix for the namespace.
true
if an XML namespace with the given URI/prefix pair is
contained in the XMLNamespaces
object of this XMLToken
object, false
otherwise.public int setTriple(XMLTriple triple)
This operation only makes sense for XML start elements. This
method will return LIBSBML_INVALID_XML_OPERATION
if this XMLToken
object is not an XML start
element.
public java.lang.String getName()
public java.lang.String getPrefix()
public java.lang.String getURI()
public java.lang.String getCharacters()
XMLToken.isText()
,
XMLToken.isElement()
public int append(java.lang.String chars)
This method only makes sense for XMLToken
objects that contains text.
If this method is called on a token that represents an XML start or end
tag, it will return the code LIBSBML_OPERATION_FAILED
.
chars
- string, characters to append to the text of this token.
XMLToken.isText()
,
XMLToken.isElement()
public long getColumn()
XMLToken
occurred.public long getLine()
XMLToken
occurred.public boolean isElement()
true
if this token represents an XML element.
This generic predicate returns true
if the element is either a start
or end tag, and false
if it's a text object. The related methods
XMLToken:isStart(), XMLToken.isEnd()
and XMLToken.isText()
are more
specific predicates.
true
if this XMLToken
object represents an XML element,
false
otherwise.
XMLToken.isStart()
,
XMLToken.isEnd()
,
XMLToken.isText()
public boolean isEnd()
true
if this token represents an XML end element.
true
if this XMLToken
object represents an XML end element,
false
otherwise.
XMLToken.isStart()
,
XMLToken.isElement()
,
XMLToken.isText()
public boolean isEndFor(XMLToken element)
true
if this token represents an XML end element for a
particular start element.
element
- XMLToken
, the element with which the current object
should be compared to determined whether the current object is a
start element for the given one.
true
if this XMLToken
object represents an XML end tag for
the start tag given by element
, false
otherwise.
XMLToken.isElement()
,
XMLToken.isStart()
,
XMLToken.isEnd()
,
XMLToken.isText()
public boolean isEOF()
true
if this token is an end of file marker.
true
if this XMLToken
object represents the end of the input,
false
otherwise.
XMLToken.setEOF()
public boolean isStart()
true
if this token represents an XML start element.
true
if this XMLToken
is an XML start element, false
otherwise.
XMLToken.isElement()
,
XMLToken.isEnd()
,
XMLToken.isText()
public boolean isText()
true
if this token represents an XML text element.
true
if this XMLToken
is an XML text element, false
otherwise.
XMLToken.isElement()
,
XMLToken.isStart()
,
XMLToken.isEnd()
public int setEnd()
XMLToken.isStart()
,
XMLToken.isEnd()
public int setEOF()
XMLToken.isEOF()
public int unsetEnd()