001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.10 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * A list of attributes on an XML element. 013 <p> 014 * <p style='color: #777; font-style: italic'> 015This class of objects is defined by libSBML only and has no direct 016equivalent in terms of SBML components. This class is not prescribed by 017the SBML specifications, although it is used to implement features 018defined in SBML. 019</p> 020 021 <p> 022 * In libSBML's XML interface layer, attributes on an element are stored as a 023 * list of values kept in an {@link XMLAttributes} object. {@link XMLAttributes} has methods 024 * for adding and removing individual attributes as well as performing other 025 * actions on the list of attributes. Classes in libSBML that represent nodes 026 * in an XML document (i.e., {@link XMLNode} and its parent class, {@link XMLToken}) use 027 * {@link XMLAttributes} objects to manage attributes on XML elements. 028 <p> 029 * Attributes on an XML element can be written in one of two forms: 030 * <ul> 031 * <li> <code>name='value'</code> 032 * <li> <code>prefix:name='value'</code> 033 * 034 * </ul> <p> 035 * An attribute in XML must always have a value, and the value must always be 036 * a quoted string; i.e., it is always <code>name='value'</code> and not 037 * <code>name=value</code>. An empty value is represented simply as an 038 * empty string; i.e., <code>name=''</code>. 039 <p> 040 * In cases when a <code>prefix</code> is provided with an attribute name, 041 * general XML validity rules require that the prefix is an XML namespace 042 * prefix that has been declared somewhere else (possibly as an another 043 * attribute on the same element). However, the {@link XMLAttributes} class does 044 * <em>not</em> test for the proper existence or declaration of XML 045 * namespaces—callers must arrange to do this themselves in some other 046 * way. This class only provides facilities for tracking and manipulating 047 * attributes and their prefix/URI/name/value components. 048 <p> 049 * <p> 050 * @note Note that although {@link XMLAttributes} provides operations that can 051 * manipulate attributes based on a numerical index, XML attributes are in 052 * fact unordered when they appear in files and data streams. The 053 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 054 * the convenience of callers. (For example, it permits callers to loop 055 * across all attributes more easily.) Users should keep in mind that the 056 * order in which attributes are stored in {@link XMLAttributes} objects has no real 057 * impact on the order in which the attributes are read or written from an 058 * XML file or data stream. 059 <p> 060 * @see XMLTriple 061 * @see XMLNode 062 * @see XMLToken 063 */ 064 065public class XMLAttributes { 066 private long swigCPtr; 067 protected boolean swigCMemOwn; 068 069 protected XMLAttributes(long cPtr, boolean cMemoryOwn) 070 { 071 swigCMemOwn = cMemoryOwn; 072 swigCPtr = cPtr; 073 } 074 075 protected static long getCPtr(XMLAttributes obj) 076 { 077 return (obj == null) ? 0 : obj.swigCPtr; 078 } 079 080 protected static long getCPtrAndDisown (XMLAttributes obj) 081 { 082 long ptr = 0; 083 084 if (obj != null) 085 { 086 ptr = obj.swigCPtr; 087 obj.swigCMemOwn = false; 088 } 089 090 return ptr; 091 } 092 093 protected void finalize() { 094 delete(); 095 } 096 097 public synchronized void delete() { 098 if (swigCPtr != 0) { 099 if (swigCMemOwn) { 100 swigCMemOwn = false; 101 libsbmlJNI.delete_XMLAttributes(swigCPtr); 102 } 103 swigCPtr = 0; 104 } 105 } 106 107 /** 108 * Equality comparison method for XMLAttributes. 109 * <p> 110 * Because the Java methods for libSBML are actually wrappers around code 111 * implemented in C++ and C, certain operations will not behave as 112 * expected. Equality comparison is one such case. An instance of a 113 * libSBML object class is actually a <em>proxy object</em> 114 * wrapping the real underlying C/C++ object. The normal <code>==</code> 115 * equality operator in Java will <em>only compare the Java proxy objects</em>, 116 * not the underlying native object. The result is almost never what you 117 * want in practical situations. Unfortunately, Java does not provide a 118 * way to override <code>==</code>. 119 * <p> 120 * The alternative that must be followed is to use the 121 * <code>equals()</code> method. The <code>equals</code> method on this 122 * class overrides the default java.lang.Object one, and performs an 123 * intelligent comparison of instances of objects of this class. The 124 * result is an assessment of whether two libSBML Java objects are truly 125 * the same underlying native-code objects. 126 * <p> 127 * The use of this method in practice is the same as the use of any other 128 * Java <code>equals</code> method. For example, 129 * <em>a</em><code>.equals(</code><em>b</em><code>)</code> returns 130 * <code>true</code> if <em>a</em> and <em>b</em> are references to the 131 * same underlying object. 132 * 133 * @param sb a reference to an object to which the current object 134 * instance will be compared 135 * 136 * @return <code>true</code> if <code>sb</code> refers to the same underlying 137 * native object as this one, <code>false</code> otherwise 138 */ 139 public boolean equals(Object sb) 140 { 141 if ( this == sb ) 142 { 143 return true; 144 } 145 return swigCPtr == getCPtr((XMLAttributes)(sb)); 146 } 147 148 /** 149 * Returns a hashcode for this XMLAttributes object. 150 * 151 * @return a hash code usable by Java methods that need them. 152 */ 153 public int hashCode() 154 { 155 return (int)(swigCPtr^(swigCPtr>>>32)); 156 } 157 158 159/** 160 * Creates a new, empty {@link XMLAttributes} object. 161 */ public 162 XMLAttributes() throws org.sbml.libsbml.XMLConstructorException { 163 this(libsbmlJNI.new_XMLAttributes__SWIG_0(), true); 164 } 165 166 167/** 168 * Copy constructor; creates a copy of this {@link XMLAttributes} object. 169 <p> 170 * <code>orig</code> the {@link XMLAttributes} object to copy. 171 */ public 172 XMLAttributes(XMLAttributes orig) throws org.sbml.libsbml.XMLConstructorException { 173 this(libsbmlJNI.new_XMLAttributes__SWIG_1(XMLAttributes.getCPtr(orig), orig), true); 174 } 175 176 177/** 178 * Creates and returns a deep copy of this {@link XMLAttributes} object. 179 <p> 180 * @return the (deep) copy of this {@link XMLAttributes} object. 181 */ public 182 XMLAttributes cloneObject() { 183 long cPtr = libsbmlJNI.XMLAttributes_cloneObject(swigCPtr, this); 184 return (cPtr == 0) ? null : new XMLAttributes(cPtr, true); 185 } 186 187 188/** 189 * Adds an attribute to this list of attributes. 190 <p> 191 * <p> 192 * Some explanations are in order about the behavior of {@link XMLAttributes} with 193 * respect to namespace prefixes and namespace URIs. {@link XMLAttributes} does 194 * <em>not</em> verify the consistency of different uses of an XML namespace and the 195 * prefix used to refer to it in a given context. It cannot, because the 196 * prefix used for a given XML namespace in an XML document may intentionally 197 * be different on different elements in the document. Consequently, callers 198 * need to manage their own prefix-to-namespace mappings, and need to ensure 199 * that the desired prefix is used in any given context. 200 <p> 201 * When called with attribute names, prefixes and namespace URIs, 202 * {@link XMLAttributes} pays attention to the namespace URIs and not the prefixes: a 203 * match is established by a combination of attribute name and namespace URI, 204 * and if on different occasions a different prefix is used for the same 205 * name/namespace combination, the prefix associated with the namespace on 206 * that attribute is overwritten. 207 <p> 208 * Some examples will hopefully clarify this. Here are the results of a 209 * sequence of calls to the {@link XMLAttributes} <code>add</code> methods with 210 * different argument combinations. First, we create the object and add 211 * one attribute: 212 <p> 213 * <pre class='fragment'>{.cpp} 214{@link XMLAttributes} att = new {@link XMLAttributes}(); 215att->add('myattribute', '1', 'myuri'); 216</pre> 217 * The above adds an attribute named <code>myattribute</code> in the namespace 218 * <code>myuri</code>, and with the attribute value <code>1</code>. No 219 * namespace prefix is associated with the attribute (but the attribute is 220 * recorded to exist in the namespace <code>myuri</code>). If 221 * this attribute object were written out in XML, it would look like the 222 * following (and note that, since no namespace prefix was assigned, none 223 * is written out): 224 * <center><pre> 225myattribute='1' 226 * </pre></center> 227 <p> 228 * Continuing with this series of examples, suppose we invoke the 229 * <code>add</code> method again as follows: 230 <p> 231 * <pre class='fragment'>{.cpp} 232att->add('myattribute', '2'); 233</pre> 234 * The above adds a <em>new</em> attribute <em>also</em> named <code>myattribute</code>, 235 * but in a different XML namespace: it is placed in the namespace with no 236 * URI, which is to say, the default XML namespace. Both attributes coexist 237 * on this {@link XMLAttributes} object; both can be independently retrieved. 238 <p> 239 * <pre class='fragment'>{.cpp} 240att->add('myattribute', '3'); 241</pre> 242 * The code above now replaces the value of the attribute 243 * <code>myattribute</code> that resides in the default namespace. The 244 * attribute in the namespace <code>myuri</code> remains untouched. 245 <p> 246 * <pre class='fragment'>{.cpp} 247att->add('myattribute', '4', 'myuri'); 248</pre> 249 * The code above replaces the value of the attribute 250 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 251 * The attribute in the default namespace remains untouched. 252 <p> 253 * <pre class='fragment'>{.cpp} 254att->add('myattribute', '5', 'myuri', 'foo'); 255</pre> 256 * The code above replaces the value of the attribute 257 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 258 * It also now assigns a namespace prefix, <code>foo</code>, to the attribute. 259 * The attribute <code>myattribute</code> in the default namespace remains 260 * untouched. If this {@link XMLAttributes} object were written out in XML, it would 261 * look like the following: 262 * <center><pre> 263myattribute='3' 264foo:myattribute='5' 265 * </pre></center> 266 * Pressing on, now suppose we call the <code>add</code> method as follows: 267 <p> 268 * <pre class='fragment'>{.cpp} 269att->add('myattribute', '6', 'myuri', 'bar'); 270</pre> 271 * The code above replaces the value of the attribute 272 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 273 * It also assigns a different prefix to the attribute. The namespace of 274 * the attribute remains <code>myuri</code>. 275 <p> 276 * <pre class='fragment'>{.cpp} 277att->add('myattribute', '7', '', 'foo'); 278</pre> 279<p> 280 * The code above replaces the value of the attribute 281 * <code>myattribute</code> that resides in the default namespace. It also 282 * now assigns a namespace prefix, <code>foo</code>, to that attribute. If 283 * this {@link XMLAttributes} object were written out in XML, it would look like the 284 * following: 285 * <center><pre> 286bar:myattribute='6' 287foo:myattribute='7' 288 * </pre></center> 289 <p> 290 * @param name a string, the unprefixed name of the attribute. 291 * @param value a string, the value of the attribute. 292 * @param namespaceURI a string, the namespace URI of the attribute. 293 * @param prefix a string, a prefix for the XML namespace. 294 <p> 295 * <p> 296 * @return integer value indicating success/failure of the 297 * function. The possible values 298 * returned by this function are: 299 * <ul> 300 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 301 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 302 * – this value is returned if any of the arguments are <code>null.</code> To 303 * set an empty <code>prefix</code> and/or <code>name</code> value, use an empty string rather 304 * than <code>null.</code> 305 * 306 * </ul> <p> 307 * <p> 308 * @note If an attribute with the same name and XML namespace URI already 309 * exists in the list of attributes held by this {@link XMLAttributes} object, then 310 * the previous value of that attribute will be replaced with the new value 311 * provided to this method. 312 <p> 313 * 314</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 315The native C++ implementation of this method defines a default argument 316value. In the documentation generated for different libSBML language 317bindings, you may or may not see corresponding arguments in the method 318declarations. For example, in Java and C#, a default argument is handled by 319declaring two separate methods, with one of them having the argument and 320the other one lacking the argument. However, the libSBML documentation will 321be <em>identical</em> for both methods. Consequently, if you are reading 322this and do not see an argument even though one is described, please look 323for descriptions of other variants of this method near where this one 324appears in the documentation. 325</dd></dl> 326 327 <p> 328 * @see #add(XMLTriple triple, String value) 329 * @see #getIndex(String name, String uri) 330 * @see #getIndex(XMLTriple triple) 331 * @see #hasAttribute(String name, String uri) 332 * @see #hasAttribute(XMLTriple triple) 333 */ public 334 int add(String name, String value, String namespaceURI, String prefix) { 335 return libsbmlJNI.XMLAttributes_add__SWIG_0(swigCPtr, this, name, value, namespaceURI, prefix); 336 } 337 338 339/** 340 * Adds an attribute to this list of attributes. 341 <p> 342 * <p> 343 * Some explanations are in order about the behavior of {@link XMLAttributes} with 344 * respect to namespace prefixes and namespace URIs. {@link XMLAttributes} does 345 * <em>not</em> verify the consistency of different uses of an XML namespace and the 346 * prefix used to refer to it in a given context. It cannot, because the 347 * prefix used for a given XML namespace in an XML document may intentionally 348 * be different on different elements in the document. Consequently, callers 349 * need to manage their own prefix-to-namespace mappings, and need to ensure 350 * that the desired prefix is used in any given context. 351 <p> 352 * When called with attribute names, prefixes and namespace URIs, 353 * {@link XMLAttributes} pays attention to the namespace URIs and not the prefixes: a 354 * match is established by a combination of attribute name and namespace URI, 355 * and if on different occasions a different prefix is used for the same 356 * name/namespace combination, the prefix associated with the namespace on 357 * that attribute is overwritten. 358 <p> 359 * Some examples will hopefully clarify this. Here are the results of a 360 * sequence of calls to the {@link XMLAttributes} <code>add</code> methods with 361 * different argument combinations. First, we create the object and add 362 * one attribute: 363 <p> 364 * <pre class='fragment'>{.cpp} 365{@link XMLAttributes} att = new {@link XMLAttributes}(); 366att->add('myattribute', '1', 'myuri'); 367</pre> 368 * The above adds an attribute named <code>myattribute</code> in the namespace 369 * <code>myuri</code>, and with the attribute value <code>1</code>. No 370 * namespace prefix is associated with the attribute (but the attribute is 371 * recorded to exist in the namespace <code>myuri</code>). If 372 * this attribute object were written out in XML, it would look like the 373 * following (and note that, since no namespace prefix was assigned, none 374 * is written out): 375 * <center><pre> 376myattribute='1' 377 * </pre></center> 378 <p> 379 * Continuing with this series of examples, suppose we invoke the 380 * <code>add</code> method again as follows: 381 <p> 382 * <pre class='fragment'>{.cpp} 383att->add('myattribute', '2'); 384</pre> 385 * The above adds a <em>new</em> attribute <em>also</em> named <code>myattribute</code>, 386 * but in a different XML namespace: it is placed in the namespace with no 387 * URI, which is to say, the default XML namespace. Both attributes coexist 388 * on this {@link XMLAttributes} object; both can be independently retrieved. 389 <p> 390 * <pre class='fragment'>{.cpp} 391att->add('myattribute', '3'); 392</pre> 393 * The code above now replaces the value of the attribute 394 * <code>myattribute</code> that resides in the default namespace. The 395 * attribute in the namespace <code>myuri</code> remains untouched. 396 <p> 397 * <pre class='fragment'>{.cpp} 398att->add('myattribute', '4', 'myuri'); 399</pre> 400 * The code above replaces the value of the attribute 401 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 402 * The attribute in the default namespace remains untouched. 403 <p> 404 * <pre class='fragment'>{.cpp} 405att->add('myattribute', '5', 'myuri', 'foo'); 406</pre> 407 * The code above replaces the value of the attribute 408 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 409 * It also now assigns a namespace prefix, <code>foo</code>, to the attribute. 410 * The attribute <code>myattribute</code> in the default namespace remains 411 * untouched. If this {@link XMLAttributes} object were written out in XML, it would 412 * look like the following: 413 * <center><pre> 414myattribute='3' 415foo:myattribute='5' 416 * </pre></center> 417 * Pressing on, now suppose we call the <code>add</code> method as follows: 418 <p> 419 * <pre class='fragment'>{.cpp} 420att->add('myattribute', '6', 'myuri', 'bar'); 421</pre> 422 * The code above replaces the value of the attribute 423 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 424 * It also assigns a different prefix to the attribute. The namespace of 425 * the attribute remains <code>myuri</code>. 426 <p> 427 * <pre class='fragment'>{.cpp} 428att->add('myattribute', '7', '', 'foo'); 429</pre> 430<p> 431 * The code above replaces the value of the attribute 432 * <code>myattribute</code> that resides in the default namespace. It also 433 * now assigns a namespace prefix, <code>foo</code>, to that attribute. If 434 * this {@link XMLAttributes} object were written out in XML, it would look like the 435 * following: 436 * <center><pre> 437bar:myattribute='6' 438foo:myattribute='7' 439 * </pre></center> 440 <p> 441 * @param name a string, the unprefixed name of the attribute. 442 * @param value a string, the value of the attribute. 443 * @param namespaceURI a string, the namespace URI of the attribute. 444 * @param prefix a string, a prefix for the XML namespace. 445 <p> 446 * <p> 447 * @return integer value indicating success/failure of the 448 * function. The possible values 449 * returned by this function are: 450 * <ul> 451 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 452 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 453 * – this value is returned if any of the arguments are <code>null.</code> To 454 * set an empty <code>prefix</code> and/or <code>name</code> value, use an empty string rather 455 * than <code>null.</code> 456 * 457 * </ul> <p> 458 * <p> 459 * @note If an attribute with the same name and XML namespace URI already 460 * exists in the list of attributes held by this {@link XMLAttributes} object, then 461 * the previous value of that attribute will be replaced with the new value 462 * provided to this method. 463 <p> 464 * 465</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 466The native C++ implementation of this method defines a default argument 467value. In the documentation generated for different libSBML language 468bindings, you may or may not see corresponding arguments in the method 469declarations. For example, in Java and C#, a default argument is handled by 470declaring two separate methods, with one of them having the argument and 471the other one lacking the argument. However, the libSBML documentation will 472be <em>identical</em> for both methods. Consequently, if you are reading 473this and do not see an argument even though one is described, please look 474for descriptions of other variants of this method near where this one 475appears in the documentation. 476</dd></dl> 477 478 <p> 479 * @see #add(XMLTriple triple, String value) 480 * @see #getIndex(String name, String uri) 481 * @see #getIndex(XMLTriple triple) 482 * @see #hasAttribute(String name, String uri) 483 * @see #hasAttribute(XMLTriple triple) 484 */ public 485 int add(String name, String value, String namespaceURI) { 486 return libsbmlJNI.XMLAttributes_add__SWIG_1(swigCPtr, this, name, value, namespaceURI); 487 } 488 489 490/** 491 * Adds an attribute to this list of attributes. 492 <p> 493 * <p> 494 * Some explanations are in order about the behavior of {@link XMLAttributes} with 495 * respect to namespace prefixes and namespace URIs. {@link XMLAttributes} does 496 * <em>not</em> verify the consistency of different uses of an XML namespace and the 497 * prefix used to refer to it in a given context. It cannot, because the 498 * prefix used for a given XML namespace in an XML document may intentionally 499 * be different on different elements in the document. Consequently, callers 500 * need to manage their own prefix-to-namespace mappings, and need to ensure 501 * that the desired prefix is used in any given context. 502 <p> 503 * When called with attribute names, prefixes and namespace URIs, 504 * {@link XMLAttributes} pays attention to the namespace URIs and not the prefixes: a 505 * match is established by a combination of attribute name and namespace URI, 506 * and if on different occasions a different prefix is used for the same 507 * name/namespace combination, the prefix associated with the namespace on 508 * that attribute is overwritten. 509 <p> 510 * Some examples will hopefully clarify this. Here are the results of a 511 * sequence of calls to the {@link XMLAttributes} <code>add</code> methods with 512 * different argument combinations. First, we create the object and add 513 * one attribute: 514 <p> 515 * <pre class='fragment'>{.cpp} 516{@link XMLAttributes} att = new {@link XMLAttributes}(); 517att->add('myattribute', '1', 'myuri'); 518</pre> 519 * The above adds an attribute named <code>myattribute</code> in the namespace 520 * <code>myuri</code>, and with the attribute value <code>1</code>. No 521 * namespace prefix is associated with the attribute (but the attribute is 522 * recorded to exist in the namespace <code>myuri</code>). If 523 * this attribute object were written out in XML, it would look like the 524 * following (and note that, since no namespace prefix was assigned, none 525 * is written out): 526 * <center><pre> 527myattribute='1' 528 * </pre></center> 529 <p> 530 * Continuing with this series of examples, suppose we invoke the 531 * <code>add</code> method again as follows: 532 <p> 533 * <pre class='fragment'>{.cpp} 534att->add('myattribute', '2'); 535</pre> 536 * The above adds a <em>new</em> attribute <em>also</em> named <code>myattribute</code>, 537 * but in a different XML namespace: it is placed in the namespace with no 538 * URI, which is to say, the default XML namespace. Both attributes coexist 539 * on this {@link XMLAttributes} object; both can be independently retrieved. 540 <p> 541 * <pre class='fragment'>{.cpp} 542att->add('myattribute', '3'); 543</pre> 544 * The code above now replaces the value of the attribute 545 * <code>myattribute</code> that resides in the default namespace. The 546 * attribute in the namespace <code>myuri</code> remains untouched. 547 <p> 548 * <pre class='fragment'>{.cpp} 549att->add('myattribute', '4', 'myuri'); 550</pre> 551 * The code above replaces the value of the attribute 552 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 553 * The attribute in the default namespace remains untouched. 554 <p> 555 * <pre class='fragment'>{.cpp} 556att->add('myattribute', '5', 'myuri', 'foo'); 557</pre> 558 * The code above replaces the value of the attribute 559 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 560 * It also now assigns a namespace prefix, <code>foo</code>, to the attribute. 561 * The attribute <code>myattribute</code> in the default namespace remains 562 * untouched. If this {@link XMLAttributes} object were written out in XML, it would 563 * look like the following: 564 * <center><pre> 565myattribute='3' 566foo:myattribute='5' 567 * </pre></center> 568 * Pressing on, now suppose we call the <code>add</code> method as follows: 569 <p> 570 * <pre class='fragment'>{.cpp} 571att->add('myattribute', '6', 'myuri', 'bar'); 572</pre> 573 * The code above replaces the value of the attribute 574 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 575 * It also assigns a different prefix to the attribute. The namespace of 576 * the attribute remains <code>myuri</code>. 577 <p> 578 * <pre class='fragment'>{.cpp} 579att->add('myattribute', '7', '', 'foo'); 580</pre> 581<p> 582 * The code above replaces the value of the attribute 583 * <code>myattribute</code> that resides in the default namespace. It also 584 * now assigns a namespace prefix, <code>foo</code>, to that attribute. If 585 * this {@link XMLAttributes} object were written out in XML, it would look like the 586 * following: 587 * <center><pre> 588bar:myattribute='6' 589foo:myattribute='7' 590 * </pre></center> 591 <p> 592 * @param name a string, the unprefixed name of the attribute. 593 * @param value a string, the value of the attribute. 594 * @param namespaceURI a string, the namespace URI of the attribute. 595 * @param prefix a string, a prefix for the XML namespace. 596 <p> 597 * <p> 598 * @return integer value indicating success/failure of the 599 * function. The possible values 600 * returned by this function are: 601 * <ul> 602 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 603 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 604 * – this value is returned if any of the arguments are <code>null.</code> To 605 * set an empty <code>prefix</code> and/or <code>name</code> value, use an empty string rather 606 * than <code>null.</code> 607 * 608 * </ul> <p> 609 * <p> 610 * @note If an attribute with the same name and XML namespace URI already 611 * exists in the list of attributes held by this {@link XMLAttributes} object, then 612 * the previous value of that attribute will be replaced with the new value 613 * provided to this method. 614 <p> 615 * 616</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 617The native C++ implementation of this method defines a default argument 618value. In the documentation generated for different libSBML language 619bindings, you may or may not see corresponding arguments in the method 620declarations. For example, in Java and C#, a default argument is handled by 621declaring two separate methods, with one of them having the argument and 622the other one lacking the argument. However, the libSBML documentation will 623be <em>identical</em> for both methods. Consequently, if you are reading 624this and do not see an argument even though one is described, please look 625for descriptions of other variants of this method near where this one 626appears in the documentation. 627</dd></dl> 628 629 <p> 630 * @see #add(XMLTriple triple, String value) 631 * @see #getIndex(String name, String uri) 632 * @see #getIndex(XMLTriple triple) 633 * @see #hasAttribute(String name, String uri) 634 * @see #hasAttribute(XMLTriple triple) 635 */ public 636 int add(String name, String value) { 637 return libsbmlJNI.XMLAttributes_add__SWIG_2(swigCPtr, this, name, value); 638 } 639 640 641/** 642 * Adds an attribute to this list of attributes. 643 <p> 644 * <p> 645 * Some explanations are in order about the behavior of {@link XMLAttributes} with 646 * respect to namespace prefixes and namespace URIs. {@link XMLAttributes} does 647 * <em>not</em> verify the consistency of different uses of an XML namespace and the 648 * prefix used to refer to it in a given context. It cannot, because the 649 * prefix used for a given XML namespace in an XML document may intentionally 650 * be different on different elements in the document. Consequently, callers 651 * need to manage their own prefix-to-namespace mappings, and need to ensure 652 * that the desired prefix is used in any given context. 653 <p> 654 * When called with attribute names, prefixes and namespace URIs, 655 * {@link XMLAttributes} pays attention to the namespace URIs and not the prefixes: a 656 * match is established by a combination of attribute name and namespace URI, 657 * and if on different occasions a different prefix is used for the same 658 * name/namespace combination, the prefix associated with the namespace on 659 * that attribute is overwritten. 660 <p> 661 * Some examples will hopefully clarify this. Here are the results of a 662 * sequence of calls to the {@link XMLAttributes} <code>add</code> methods with 663 * different argument combinations. First, we create the object and add 664 * one attribute: 665 <p> 666 * <pre class='fragment'>{.cpp} 667{@link XMLAttributes} att = new {@link XMLAttributes}(); 668att->add('myattribute', '1', 'myuri'); 669</pre> 670 * The above adds an attribute named <code>myattribute</code> in the namespace 671 * <code>myuri</code>, and with the attribute value <code>1</code>. No 672 * namespace prefix is associated with the attribute (but the attribute is 673 * recorded to exist in the namespace <code>myuri</code>). If 674 * this attribute object were written out in XML, it would look like the 675 * following (and note that, since no namespace prefix was assigned, none 676 * is written out): 677 * <center><pre> 678myattribute='1' 679 * </pre></center> 680 <p> 681 * Continuing with this series of examples, suppose we invoke the 682 * <code>add</code> method again as follows: 683 <p> 684 * <pre class='fragment'>{.cpp} 685att->add('myattribute', '2'); 686</pre> 687 * The above adds a <em>new</em> attribute <em>also</em> named <code>myattribute</code>, 688 * but in a different XML namespace: it is placed in the namespace with no 689 * URI, which is to say, the default XML namespace. Both attributes coexist 690 * on this {@link XMLAttributes} object; both can be independently retrieved. 691 <p> 692 * <pre class='fragment'>{.cpp} 693att->add('myattribute', '3'); 694</pre> 695 * The code above now replaces the value of the attribute 696 * <code>myattribute</code> that resides in the default namespace. The 697 * attribute in the namespace <code>myuri</code> remains untouched. 698 <p> 699 * <pre class='fragment'>{.cpp} 700att->add('myattribute', '4', 'myuri'); 701</pre> 702 * The code above replaces the value of the attribute 703 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 704 * The attribute in the default namespace remains untouched. 705 <p> 706 * <pre class='fragment'>{.cpp} 707att->add('myattribute', '5', 'myuri', 'foo'); 708</pre> 709 * The code above replaces the value of the attribute 710 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 711 * It also now assigns a namespace prefix, <code>foo</code>, to the attribute. 712 * The attribute <code>myattribute</code> in the default namespace remains 713 * untouched. If this {@link XMLAttributes} object were written out in XML, it would 714 * look like the following: 715 * <center><pre> 716myattribute='3' 717foo:myattribute='5' 718 * </pre></center> 719 * Pressing on, now suppose we call the <code>add</code> method as follows: 720 <p> 721 * <pre class='fragment'>{.cpp} 722att->add('myattribute', '6', 'myuri', 'bar'); 723</pre> 724 * The code above replaces the value of the attribute 725 * <code>myattribute</code> that resides in the <code>myuri</code> namespace. 726 * It also assigns a different prefix to the attribute. The namespace of 727 * the attribute remains <code>myuri</code>. 728 <p> 729 * <pre class='fragment'>{.cpp} 730att->add('myattribute', '7', '', 'foo'); 731</pre> 732<p> 733 * The code above replaces the value of the attribute 734 * <code>myattribute</code> that resides in the default namespace. It also 735 * now assigns a namespace prefix, <code>foo</code>, to that attribute. If 736 * this {@link XMLAttributes} object were written out in XML, it would look like the 737 * following: 738 * <center><pre> 739bar:myattribute='6' 740foo:myattribute='7' 741 * </pre></center> 742 <p> 743 * @param triple an {@link XMLTriple} object describing the attribute to be added. 744 * @param value a string, the value of the attribute. 745 <p> 746 * <p> 747 * @return integer value indicating success/failure of the 748 * function. The possible values 749 * returned by this function are: 750 * <ul> 751 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 752 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 753 * – this value is returned if any of the arguments are <code>null.</code> To 754 * set an empty value for the attribute, use an empty string rather than 755 * <code>null.</code> 756 * 757 * </ul> <p> 758 * <p> 759 * @note If an attribute with the same name and XML namespace URI already 760 * exists in the list of attributes held by this {@link XMLAttributes} object, then 761 * the previous value of that attribute will be replaced with the new value 762 * provided to this method. 763 <p> 764 * @see #add(String name, String value, String namespaceURI, String prefix) 765 * @see #getIndex(String name, String uri) 766 * @see #getIndex(XMLTriple triple) 767 * @see #hasAttribute(String name, String uri) 768 * @see #hasAttribute(XMLTriple triple) 769 */ public 770 int add(XMLTriple triple, String value) { 771 return libsbmlJNI.XMLAttributes_add__SWIG_3(swigCPtr, this, XMLTriple.getCPtr(triple), triple, value); 772 } 773 774 775/** * @internal */ public 776 int removeResource(int n) { 777 return libsbmlJNI.XMLAttributes_removeResource(swigCPtr, this, n); 778 } 779 780 781/** 782 * Removes the <em>n</em>th attribute from this list of attributes. 783 <p> 784 * @param n an integer the index of the resource to be deleted 785 <p> 786 * <p> 787 * @return integer value indicating success/failure of the 788 * function. The possible values 789 * returned by this function are: 790 * <ul> 791 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 792 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} 793 * 794 * </ul> <p> 795 * The value {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} is returned if there is no attribute at the 796 * given index <code>n</code>. 797 <p> 798 * <p> 799 * @note Note that although {@link XMLAttributes} provides operations that can 800 * manipulate attributes based on a numerical index, XML attributes are in 801 * fact unordered when they appear in files and data streams. The 802 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 803 * the convenience of callers. (For example, it permits callers to loop 804 * across all attributes more easily.) Users should keep in mind that the 805 * order in which attributes are stored in {@link XMLAttributes} objects has no real 806 * impact on the order in which the attributes are read or written from an 807 * XML file or data stream. 808 <p> 809 * @see #getLength() 810 * @see #remove(XMLTriple triple) 811 * @see #remove(String name, String uri) 812 */ public 813 int remove(int n) { 814 return libsbmlJNI.XMLAttributes_remove__SWIG_0(swigCPtr, this, n); 815 } 816 817 818/** 819 * Removes a named attribute from this list of attributes. 820 <p> 821 * @param name a string, the unprefixed name of the attribute to be 822 * removed. 823 <p> 824 * @param uri a string, the namespace URI of the attribute to be removed. 825 <p> 826 * <p> 827 * @return integer value indicating success/failure of the 828 * function. The possible values 829 * returned by this function are: 830 * <ul> 831 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 832 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} 833 * 834 * </ul> <p> 835 * The value {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} is returned if there is no attribute with the 836 * given <code>name</code> (and <code>uri</code> if specified). 837 <p> 838 * @see #remove(int n) 839 * @see #remove(XMLTriple triple) 840 */ public 841 int remove(String name, String uri) { 842 return libsbmlJNI.XMLAttributes_remove__SWIG_1(swigCPtr, this, name, uri); 843 } 844 845 846/** 847 * Removes a named attribute from this list of attributes. 848 <p> 849 * @param name a string, the unprefixed name of the attribute to be 850 * removed. 851 <p> 852 * @param uri a string, the namespace URI of the attribute to be removed. 853 <p> 854 * <p> 855 * @return integer value indicating success/failure of the 856 * function. The possible values 857 * returned by this function are: 858 * <ul> 859 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 860 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} 861 * 862 * </ul> <p> 863 * The value {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} is returned if there is no attribute with the 864 * given <code>name</code> (and <code>uri</code> if specified). 865 <p> 866 * @see #remove(int n) 867 * @see #remove(XMLTriple triple) 868 */ public 869 int remove(String name) { 870 return libsbmlJNI.XMLAttributes_remove__SWIG_2(swigCPtr, this, name); 871 } 872 873 874/** 875 * Removes a specific attribute from this list of attributes. 876 <p> 877 * @param triple an {@link XMLTriple} describing the attribute to be removed. 878 <p> 879 * <p> 880 * @return integer value indicating success/failure of the 881 * function. The possible values 882 * returned by this function are: 883 * <ul> 884 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 885 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} 886 * 887 * </ul> <p> 888 * The value {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} is returned if there is no attribute matching 889 * the properties of the given <code>triple</code>. 890 <p> 891 * @see #remove(int n) 892 * @see #remove(String name, String uri) 893 */ public 894 int remove(XMLTriple triple) { 895 return libsbmlJNI.XMLAttributes_remove__SWIG_3(swigCPtr, this, XMLTriple.getCPtr(triple), triple); 896 } 897 898 899/** 900 * Removes all attributes in this {@link XMLAttributes} object. 901 <p> 902 * <p> 903 * @return integer value indicating success/failure of the 904 * function. The possible values 905 * returned by this function are: 906 * <ul> 907 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 908 * 909 * </ul> <p> 910 * @see #remove(int n) 911 * @see #remove(XMLTriple triple) 912 * @see #remove(String name, String uri) 913 */ public 914 int clear() { 915 return libsbmlJNI.XMLAttributes_clear(swigCPtr, this); 916 } 917 918 919/** 920 * Returns the index of an attribute having a given name. 921 <p> 922 * @note This method does not check XML namespaces. Thus, if there are 923 * multiple attributes with the same local <code>name</code> but different 924 * namespaces, this method will return the first one found. Callers should 925 * use the more specific methods 926 * {@link XMLAttributes#getIndex(String name, String uri)} 927 * or {@link XMLAttributes#getIndex(XMLTriple triple)} 928 * to find attributes in particular namespaces. 929 <p> 930 * @param name a string, the name of the attribute whose index is begin 931 * sought. 932 <p> 933 * @return the index of an attribute with the given local name, or 934 * <code>-1</code> if no such attribute is present. 935 <p> 936 * @see #hasAttribute(String name, String uri) 937 * @see #hasAttribute(XMLTriple triple) 938 */ public 939 int getIndex(String name) { 940 return libsbmlJNI.XMLAttributes_getIndex__SWIG_0(swigCPtr, this, name); 941 } 942 943 944/** 945 * Returns the index of the attribute having a given name and XML namespace 946 * URI. 947 <p> 948 * @param name a string, the name of the attribute being sought. 949 * @param uri a string, the namespace URI of the attribute being sought. 950 <p> 951 * @return the index of an attribute with the given local name and 952 * namespace URI, or <code>-1</code> if no such attribute is present. 953 <p> 954 * @see #hasAttribute(String name, String uri) 955 * @see #hasAttribute(XMLTriple triple) 956 */ public 957 int getIndex(String name, String uri) { 958 return libsbmlJNI.XMLAttributes_getIndex__SWIG_1(swigCPtr, this, name, uri); 959 } 960 961 962/** 963 * Returns the index of the attribute defined by the given {@link XMLTriple} object. 964 <p> 965 * @param triple an {@link XMLTriple} describing the attribute being sought. 966 <p> 967 * @return the index of an attribute described by the given {@link XMLTriple} 968 * object, or <code>-1</code> if no such attribute is present. 969 <p> 970 * @see #hasAttribute(String name, String uri) 971 * @see #hasAttribute(XMLTriple triple) 972 */ public 973 int getIndex(XMLTriple triple) { 974 return libsbmlJNI.XMLAttributes_getIndex__SWIG_2(swigCPtr, this, XMLTriple.getCPtr(triple), triple); 975 } 976 977 978/** 979 * Returns the number of attributes in this list of attributes. 980 <p> 981 * @return the number of attributes contained in this {@link XMLAttributes} object. 982 */ public 983 int getLength() { 984 return libsbmlJNI.XMLAttributes_getLength(swigCPtr, this); 985 } 986 987 988/** 989 * Returns the number of attributes in this list of attributes. 990 <p> 991 * This function is merely an alias of {@link XMLAttributes#getLength()} 992 * introduced for consistency with other libXML classes. 993 <p> 994 * @return the number of attributes contained in this {@link XMLAttributes} object. 995 */ public 996 int getNumAttributes() { 997 return libsbmlJNI.XMLAttributes_getNumAttributes(swigCPtr, this); 998 } 999 1000 1001/** 1002 * Returns the name of the <em>n</em>th attribute in this list of 1003 * attributes. 1004 <p> 1005 * @param index an integer, the position of the attribute whose name 1006 * is being sought. 1007 <p> 1008 * @return the local name of the <em>n</em>th attribute. 1009 <p> 1010 * <p> 1011 * @note If <code>index</code> is out of range, this method will return an empty 1012 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1013 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1014 * index)} to test for the existence of an attribute at a given 1015 * position. 1016 <p> 1017 * <p> 1018 * @note Note that although {@link XMLAttributes} provides operations that can 1019 * manipulate attributes based on a numerical index, XML attributes are in 1020 * fact unordered when they appear in files and data streams. The 1021 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1022 * the convenience of callers. (For example, it permits callers to loop 1023 * across all attributes more easily.) Users should keep in mind that the 1024 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1025 * impact on the order in which the attributes are read or written from an 1026 * XML file or data stream. 1027 <p> 1028 * @see #getLength() 1029 * @see #hasAttribute(int index) 1030 */ public 1031 String getName(int index) { 1032 return libsbmlJNI.XMLAttributes_getName(swigCPtr, this, index); 1033 } 1034 1035 1036/** 1037 * Returns the namespace prefix of the <em>n</em>th attribute in this 1038 * attribute set. 1039 <p> 1040 * @param index an integer, the position of the attribute whose namespace 1041 * prefix is being sought. 1042 <p> 1043 * @return the XML namespace prefix of the <em>n</em>th attribute. 1044 <p> 1045 * <p> 1046 * @note If <code>index</code> is out of range, this method will return an empty 1047 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1048 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1049 * index)} to test for the existence of an attribute at a given 1050 * position. 1051 <p> 1052 * <p> 1053 * @note Note that although {@link XMLAttributes} provides operations that can 1054 * manipulate attributes based on a numerical index, XML attributes are in 1055 * fact unordered when they appear in files and data streams. The 1056 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1057 * the convenience of callers. (For example, it permits callers to loop 1058 * across all attributes more easily.) Users should keep in mind that the 1059 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1060 * impact on the order in which the attributes are read or written from an 1061 * XML file or data stream. 1062 <p> 1063 * @see #getLength() 1064 * @see #hasAttribute(int index) 1065 */ public 1066 String getPrefix(int index) { 1067 return libsbmlJNI.XMLAttributes_getPrefix(swigCPtr, this, index); 1068 } 1069 1070 1071/** 1072 * Returns the prefix name of the <em>n</em>th attribute in this attribute 1073 * set. 1074 <p> 1075 * @param index an integer, the position of the attribute whose prefixed 1076 * name is being sought. 1077 <p> 1078 * @return the prefixed name of the <em>n</em>th attribute. 1079 <p> 1080 * <p> 1081 * @note If <code>index</code> is out of range, this method will return an empty 1082 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1083 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1084 * index)} to test for the existence of an attribute at a given 1085 * position. 1086 <p> 1087 * <p> 1088 * @note Note that although {@link XMLAttributes} provides operations that can 1089 * manipulate attributes based on a numerical index, XML attributes are in 1090 * fact unordered when they appear in files and data streams. The 1091 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1092 * the convenience of callers. (For example, it permits callers to loop 1093 * across all attributes more easily.) Users should keep in mind that the 1094 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1095 * impact on the order in which the attributes are read or written from an 1096 * XML file or data stream. 1097 <p> 1098 * @see #getLength() 1099 * @see #hasAttribute(int index) 1100 */ public 1101 String getPrefixedName(int index) { 1102 return libsbmlJNI.XMLAttributes_getPrefixedName(swigCPtr, this, index); 1103 } 1104 1105 1106/** 1107 * Returns the XML namespace URI of the <em>n</em>th attribute in this 1108 * attribute set. 1109 <p> 1110 * @param index an integer, the position of the attribute whose namespace 1111 * URI is being sought. 1112 <p> 1113 * @return the XML namespace URI of the <em>n</em>th attribute. 1114 <p> 1115 * <p> 1116 * @note If <code>index</code> is out of range, this method will return an empty 1117 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1118 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1119 * index)} to test for the existence of an attribute at a given 1120 * position. 1121 <p> 1122 * <p> 1123 * @note Note that although {@link XMLAttributes} provides operations that can 1124 * manipulate attributes based on a numerical index, XML attributes are in 1125 * fact unordered when they appear in files and data streams. The 1126 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1127 * the convenience of callers. (For example, it permits callers to loop 1128 * across all attributes more easily.) Users should keep in mind that the 1129 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1130 * impact on the order in which the attributes are read or written from an 1131 * XML file or data stream. 1132 <p> 1133 * @see #getLength() 1134 * @see #hasAttribute(int index) 1135 */ public 1136 String getURI(int index) { 1137 return libsbmlJNI.XMLAttributes_getURI(swigCPtr, this, index); 1138 } 1139 1140 1141/** 1142 * Returns the value of the <em>n</em>th attribute in this list of attributes. 1143 <p> 1144 * @param index an integer, the position of the attribute whose value is 1145 * being sought. 1146 <p> 1147 * @return the XML value of the <em>n</em>th attribute. 1148 <p> 1149 * <p> 1150 * @note If <code>index</code> is out of range, this method will return an empty 1151 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1152 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1153 * index)} to test for the existence of an attribute at a given 1154 * position. 1155 <p> 1156 * <p> 1157 * @note Note that although {@link XMLAttributes} provides operations that can 1158 * manipulate attributes based on a numerical index, XML attributes are in 1159 * fact unordered when they appear in files and data streams. The 1160 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1161 * the convenience of callers. (For example, it permits callers to loop 1162 * across all attributes more easily.) Users should keep in mind that the 1163 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1164 * impact on the order in which the attributes are read or written from an 1165 * XML file or data stream. 1166 <p> 1167 * @see #getLength() 1168 * @see #hasAttribute(int index) 1169 */ public 1170 String getValue(int index) { 1171 return libsbmlJNI.XMLAttributes_getValue__SWIG_0(swigCPtr, this, index); 1172 } 1173 1174 1175/** 1176 * Returns a named attribute's value. 1177 <p> 1178 * @param name a string, the unprefixed name of the attribute whose value 1179 * is being sought. 1180 <p> 1181 * @return The attribute value as a string. 1182 <p> 1183 * @note If an attribute with the given local <code>name</code> does not exist in 1184 * this {@link XMLAttributes} object, this method will return an empty string. 1185 * Callers can use 1186 * {@link XMLAttributes#hasAttribute(String name, String uri)} 1187 * to test for an attribute's existence. This method also does not check 1188 * the XML namespace of the named attribute. Thus, if there are multiple 1189 * attributes with the same local <code>name</code> but different namespaces, this 1190 * method will return the value of the first such attribute found. Callers 1191 * should use the more specific methods 1192 * {@link XMLAttributes#getIndex(String name, String uri)} 1193 * or {@link XMLAttributes#getIndex(XMLTriple triple)} to find 1194 * attributes in particular namespaces. 1195 <p> 1196 * @see #hasAttribute(String name, String uri) 1197 * @see #hasAttribute(XMLTriple triple) 1198 */ public 1199 String getValue(String name) { 1200 return libsbmlJNI.XMLAttributes_getValue__SWIG_1(swigCPtr, this, name); 1201 } 1202 1203 1204/** 1205 * Returns a named attribute's value. 1206 <p> 1207 * @param name a string, the name of the attribute whose value is being sought. 1208 * @param uri a string, the XML namespace URI of the attribute. 1209 <p> 1210 * @return The attribute value as a string. 1211 <p> 1212 * @note If an attribute with the given <code>name</code> and namespace <code>uri</code> does 1213 * not exist in this {@link XMLAttributes} object, this method will return an empty 1214 * string. Callers can use 1215 * {@link XMLAttributes#hasAttribute(String name, String uri)} 1216 * to test for an attribute's existence. 1217 <p> 1218 * @see #hasAttribute(String name, String uri) 1219 * @see #hasAttribute(XMLTriple triple) 1220 */ public 1221 String getValue(String name, String uri) { 1222 return libsbmlJNI.XMLAttributes_getValue__SWIG_2(swigCPtr, this, name, uri); 1223 } 1224 1225 1226/** 1227 * Return the value of an attribute described by a given {@link XMLTriple} object. 1228 <p> 1229 * @param triple an {@link XMLTriple} describing the attribute whose value is being 1230 * sought. 1231 <p> 1232 * @return The attribute value as a string. 1233 <p> 1234 * @note If an attribute with the properties given by <code>triple</code> does not 1235 * exist in this {@link XMLAttributes} object, this method will return an empty 1236 * string. Callers can use 1237 * {@link XMLAttributes#hasAttribute(String name, String uri)} 1238 * to test for an attribute's existence. 1239 <p> 1240 * @see #hasAttribute(String name, String uri) 1241 * @see #hasAttribute(XMLTriple triple) 1242 */ public 1243 String getValue(XMLTriple triple) { 1244 return libsbmlJNI.XMLAttributes_getValue__SWIG_3(swigCPtr, this, XMLTriple.getCPtr(triple), triple); 1245 } 1246 1247 1248/** 1249 * Returns <code>true</code> if an attribute exists at a given index. 1250 <p> 1251 * @param index an integer, the position of the attribute to be tested. 1252 <p> 1253 * @return <code>true</code> if an attribute with the given index exists in this 1254 * {@link XMLAttributes} object, <code>false</code> otherwise. 1255 <p> 1256 * <p> 1257 * @note Note that although {@link XMLAttributes} provides operations that can 1258 * manipulate attributes based on a numerical index, XML attributes are in 1259 * fact unordered when they appear in files and data streams. The 1260 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1261 * the convenience of callers. (For example, it permits callers to loop 1262 * across all attributes more easily.) Users should keep in mind that the 1263 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1264 * impact on the order in which the attributes are read or written from an 1265 * XML file or data stream. 1266 */ public 1267 boolean hasAttribute(int index) { 1268 return libsbmlJNI.XMLAttributes_hasAttribute__SWIG_0(swigCPtr, this, index); 1269 } 1270 1271 1272/** 1273 * Returns <code>true</code> if an attribute with a given name and namespace URI 1274 * exists. 1275 <p> 1276 * @param name a string, the unprefixed name of the attribute. 1277 * @param uri a string, the XML namespace URI of the attribute. 1278 <p> 1279 * @return <code>true</code> if an attribute with the given local name and XML 1280 * namespace URI exists in this {@link XMLAttributes} object, <code>false</code> otherwise. 1281 <p> 1282 * @see #add(String name, String value, String namespaceURI, String prefix) 1283 * @see #add(XMLTriple triple, String value) 1284 */ public 1285 boolean hasAttribute(String name, String uri) { 1286 return libsbmlJNI.XMLAttributes_hasAttribute__SWIG_1(swigCPtr, this, name, uri); 1287 } 1288 1289 1290/** 1291 * Returns <code>true</code> if an attribute with a given name and namespace URI 1292 * exists. 1293 <p> 1294 * @param name a string, the unprefixed name of the attribute. 1295 * @param uri a string, the XML namespace URI of the attribute. 1296 <p> 1297 * @return <code>true</code> if an attribute with the given local name and XML 1298 * namespace URI exists in this {@link XMLAttributes} object, <code>false</code> otherwise. 1299 <p> 1300 * @see #add(String name, String value, String namespaceURI, String prefix) 1301 * @see #add(XMLTriple triple, String value) 1302 */ public 1303 boolean hasAttribute(String name) { 1304 return libsbmlJNI.XMLAttributes_hasAttribute__SWIG_2(swigCPtr, this, name); 1305 } 1306 1307 1308/** 1309 * Returns <code>true</code> if an attribute with the given properties exists. 1310 <p> 1311 * @param triple an {@link XMLTriple} describing the attribute to be tested. 1312 <p> 1313 * @return <code>true</code> if an attribute with the given XML triple exists in this 1314 * {@link XMLAttributes} object, <code>false</code> otherwise. 1315 <p> 1316 * @see #add(String name, String value, String namespaceURI, String prefix) 1317 * @see #add(XMLTriple triple, String value) 1318 */ public 1319 boolean hasAttribute(XMLTriple triple) { 1320 return libsbmlJNI.XMLAttributes_hasAttribute__SWIG_3(swigCPtr, this, XMLTriple.getCPtr(triple), triple); 1321 } 1322 1323 1324/** 1325 * Returns <code>true</code> if this list of attributes is empty. 1326 <p> 1327 * @return <code>true</code> if this {@link XMLAttributes} object is empty, <code>false</code> 1328 * otherwise. 1329 */ public 1330 boolean isEmpty() { 1331 return libsbmlJNI.XMLAttributes_isEmpty(swigCPtr, this); 1332 } 1333 1334}