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. This particular 905 * function only does one thing irrespective of user input or 906 * object state, and thus will only return a single value: 907 * <ul> 908 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 909 * 910 * </ul> <p> 911 * @see #remove(int n) 912 * @see #remove(XMLTriple triple) 913 * @see #remove(String name, String uri) 914 */ public 915 int clear() { 916 return libsbmlJNI.XMLAttributes_clear(swigCPtr, this); 917 } 918 919 920/** 921 * Returns the index of an attribute having a given name. 922 <p> 923 * @note This method does not check XML namespaces. Thus, if there are 924 * multiple attributes with the same local <code>name</code> but different 925 * namespaces, this method will return the first one found. Callers should 926 * use the more specific methods 927 * {@link XMLAttributes#getIndex(String name, String uri)} 928 * or {@link XMLAttributes#getIndex(XMLTriple triple)} 929 * to find attributes in particular namespaces. 930 <p> 931 * @param name a string, the name of the attribute whose index is begin 932 * sought. 933 <p> 934 * @return the index of an attribute with the given local name, or 935 * <code>-1</code> if no such attribute is present. 936 <p> 937 * @see #hasAttribute(String name, String uri) 938 * @see #hasAttribute(XMLTriple triple) 939 */ public 940 int getIndex(String name) { 941 return libsbmlJNI.XMLAttributes_getIndex__SWIG_0(swigCPtr, this, name); 942 } 943 944 945/** 946 * Returns the index of the attribute having a given name and XML namespace 947 * URI. 948 <p> 949 * @param name a string, the name of the attribute being sought. 950 * @param uri a string, the namespace URI of the attribute being sought. 951 <p> 952 * @return the index of an attribute with the given local name and 953 * namespace URI, or <code>-1</code> if no such attribute is present. 954 <p> 955 * @see #hasAttribute(String name, String uri) 956 * @see #hasAttribute(XMLTriple triple) 957 */ public 958 int getIndex(String name, String uri) { 959 return libsbmlJNI.XMLAttributes_getIndex__SWIG_1(swigCPtr, this, name, uri); 960 } 961 962 963/** 964 * Returns the index of the attribute defined by the given {@link XMLTriple} object. 965 <p> 966 * @param triple an {@link XMLTriple} describing the attribute being sought. 967 <p> 968 * @return the index of an attribute described by the given {@link XMLTriple} 969 * object, or <code>-1</code> if no such attribute is present. 970 <p> 971 * @see #hasAttribute(String name, String uri) 972 * @see #hasAttribute(XMLTriple triple) 973 */ public 974 int getIndex(XMLTriple triple) { 975 return libsbmlJNI.XMLAttributes_getIndex__SWIG_2(swigCPtr, this, XMLTriple.getCPtr(triple), triple); 976 } 977 978 979/** 980 * Returns the number of attributes in this list of attributes. 981 <p> 982 * @return the number of attributes contained in this {@link XMLAttributes} object. 983 */ public 984 int getLength() { 985 return libsbmlJNI.XMLAttributes_getLength(swigCPtr, this); 986 } 987 988 989/** 990 * Returns the number of attributes in this list of attributes. 991 <p> 992 * This function is merely an alias of {@link XMLAttributes#getLength()} 993 * introduced for consistency with other libXML classes. 994 <p> 995 * @return the number of attributes contained in this {@link XMLAttributes} object. 996 */ public 997 int getNumAttributes() { 998 return libsbmlJNI.XMLAttributes_getNumAttributes(swigCPtr, this); 999 } 1000 1001 1002/** 1003 * Returns the name of the <em>n</em>th attribute in this list of 1004 * attributes. 1005 <p> 1006 * @param index an integer, the position of the attribute whose name 1007 * is being sought. 1008 <p> 1009 * @return the local name of the <em>n</em>th attribute. 1010 <p> 1011 * <p> 1012 * @note If <code>index</code> is out of range, this method will return an empty 1013 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1014 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1015 * index)} to test for the existence of an attribute at a given 1016 * position. 1017 <p> 1018 * <p> 1019 * @note Note that although {@link XMLAttributes} provides operations that can 1020 * manipulate attributes based on a numerical index, XML attributes are in 1021 * fact unordered when they appear in files and data streams. The 1022 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1023 * the convenience of callers. (For example, it permits callers to loop 1024 * across all attributes more easily.) Users should keep in mind that the 1025 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1026 * impact on the order in which the attributes are read or written from an 1027 * XML file or data stream. 1028 <p> 1029 * @see #getLength() 1030 * @see #hasAttribute(int index) 1031 */ public 1032 String getName(int index) { 1033 return libsbmlJNI.XMLAttributes_getName(swigCPtr, this, index); 1034 } 1035 1036 1037/** 1038 * Returns the namespace prefix of the <em>n</em>th attribute in this 1039 * attribute set. 1040 <p> 1041 * @param index an integer, the position of the attribute whose namespace 1042 * prefix is being sought. 1043 <p> 1044 * @return the XML namespace prefix of the <em>n</em>th attribute. 1045 <p> 1046 * <p> 1047 * @note If <code>index</code> is out of range, this method will return an empty 1048 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1049 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1050 * index)} to test for the existence of an attribute at a given 1051 * position. 1052 <p> 1053 * <p> 1054 * @note Note that although {@link XMLAttributes} provides operations that can 1055 * manipulate attributes based on a numerical index, XML attributes are in 1056 * fact unordered when they appear in files and data streams. The 1057 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1058 * the convenience of callers. (For example, it permits callers to loop 1059 * across all attributes more easily.) Users should keep in mind that the 1060 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1061 * impact on the order in which the attributes are read or written from an 1062 * XML file or data stream. 1063 <p> 1064 * @see #getLength() 1065 * @see #hasAttribute(int index) 1066 */ public 1067 String getPrefix(int index) { 1068 return libsbmlJNI.XMLAttributes_getPrefix(swigCPtr, this, index); 1069 } 1070 1071 1072/** 1073 * Returns the prefix name of the <em>n</em>th attribute in this attribute 1074 * set. 1075 <p> 1076 * @param index an integer, the position of the attribute whose prefixed 1077 * name is being sought. 1078 <p> 1079 * @return the prefixed name of the <em>n</em>th attribute. 1080 <p> 1081 * <p> 1082 * @note If <code>index</code> is out of range, this method will return an empty 1083 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1084 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1085 * index)} to test for the existence of an attribute at a given 1086 * position. 1087 <p> 1088 * <p> 1089 * @note Note that although {@link XMLAttributes} provides operations that can 1090 * manipulate attributes based on a numerical index, XML attributes are in 1091 * fact unordered when they appear in files and data streams. The 1092 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1093 * the convenience of callers. (For example, it permits callers to loop 1094 * across all attributes more easily.) Users should keep in mind that the 1095 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1096 * impact on the order in which the attributes are read or written from an 1097 * XML file or data stream. 1098 <p> 1099 * @see #getLength() 1100 * @see #hasAttribute(int index) 1101 */ public 1102 String getPrefixedName(int index) { 1103 return libsbmlJNI.XMLAttributes_getPrefixedName(swigCPtr, this, index); 1104 } 1105 1106 1107/** 1108 * Returns the XML namespace URI of the <em>n</em>th attribute in this 1109 * attribute set. 1110 <p> 1111 * @param index an integer, the position of the attribute whose namespace 1112 * URI is being sought. 1113 <p> 1114 * @return the XML namespace URI of the <em>n</em>th attribute. 1115 <p> 1116 * <p> 1117 * @note If <code>index</code> is out of range, this method will return an empty 1118 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1119 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1120 * index)} to test for the existence of an attribute at a given 1121 * position. 1122 <p> 1123 * <p> 1124 * @note Note that although {@link XMLAttributes} provides operations that can 1125 * manipulate attributes based on a numerical index, XML attributes are in 1126 * fact unordered when they appear in files and data streams. The 1127 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1128 * the convenience of callers. (For example, it permits callers to loop 1129 * across all attributes more easily.) Users should keep in mind that the 1130 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1131 * impact on the order in which the attributes are read or written from an 1132 * XML file or data stream. 1133 <p> 1134 * @see #getLength() 1135 * @see #hasAttribute(int index) 1136 */ public 1137 String getURI(int index) { 1138 return libsbmlJNI.XMLAttributes_getURI(swigCPtr, this, index); 1139 } 1140 1141 1142/** 1143 * Returns the value of the <em>n</em>th attribute in this list of attributes. 1144 <p> 1145 * @param index an integer, the position of the attribute whose value is 1146 * being sought. 1147 <p> 1148 * @return the XML value of the <em>n</em>th attribute. 1149 <p> 1150 * <p> 1151 * @note If <code>index</code> is out of range, this method will return an empty 1152 * string. Callers should use {@link XMLAttributes#getLength()} to check the number 1153 * of attributes contained in this object or {@link XMLAttributes#hasAttribute(int 1154 * index)} to test for the existence of an attribute at a given 1155 * position. 1156 <p> 1157 * <p> 1158 * @note Note that although {@link XMLAttributes} provides operations that can 1159 * manipulate attributes based on a numerical index, XML attributes are in 1160 * fact unordered when they appear in files and data streams. The 1161 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1162 * the convenience of callers. (For example, it permits callers to loop 1163 * across all attributes more easily.) Users should keep in mind that the 1164 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1165 * impact on the order in which the attributes are read or written from an 1166 * XML file or data stream. 1167 <p> 1168 * @see #getLength() 1169 * @see #hasAttribute(int index) 1170 */ public 1171 String getValue(int index) { 1172 return libsbmlJNI.XMLAttributes_getValue__SWIG_0(swigCPtr, this, index); 1173 } 1174 1175 1176/** 1177 * Returns a named attribute's value. 1178 <p> 1179 * @param name a string, the unprefixed name of the attribute whose value 1180 * is being sought. 1181 <p> 1182 * @return The attribute value as a string. 1183 <p> 1184 * @note If an attribute with the given local <code>name</code> does not exist in 1185 * this {@link XMLAttributes} object, this method will return an empty string. 1186 * Callers can use 1187 * {@link XMLAttributes#hasAttribute(String name, String uri)} 1188 * to test for an attribute's existence. This method also does not check 1189 * the XML namespace of the named attribute. Thus, if there are multiple 1190 * attributes with the same local <code>name</code> but different namespaces, this 1191 * method will return the value of the first such attribute found. Callers 1192 * should use the more specific methods 1193 * {@link XMLAttributes#getIndex(String name, String uri)} 1194 * or {@link XMLAttributes#getIndex(XMLTriple triple)} to find 1195 * attributes in particular namespaces. 1196 <p> 1197 * @see #hasAttribute(String name, String uri) 1198 * @see #hasAttribute(XMLTriple triple) 1199 */ public 1200 String getValue(String name) { 1201 return libsbmlJNI.XMLAttributes_getValue__SWIG_1(swigCPtr, this, name); 1202 } 1203 1204 1205/** 1206 * Returns a named attribute's value. 1207 <p> 1208 * @param name a string, the name of the attribute whose value is being sought. 1209 * @param uri a string, the XML namespace URI of the attribute. 1210 <p> 1211 * @return The attribute value as a string. 1212 <p> 1213 * @note If an attribute with the given <code>name</code> and namespace <code>uri</code> does 1214 * not exist in this {@link XMLAttributes} object, this method will return an empty 1215 * string. Callers can use 1216 * {@link XMLAttributes#hasAttribute(String name, String uri)} 1217 * to test for an attribute's existence. 1218 <p> 1219 * @see #hasAttribute(String name, String uri) 1220 * @see #hasAttribute(XMLTriple triple) 1221 */ public 1222 String getValue(String name, String uri) { 1223 return libsbmlJNI.XMLAttributes_getValue__SWIG_2(swigCPtr, this, name, uri); 1224 } 1225 1226 1227/** 1228 * Return the value of an attribute described by a given {@link XMLTriple} object. 1229 <p> 1230 * @param triple an {@link XMLTriple} describing the attribute whose value is being 1231 * sought. 1232 <p> 1233 * @return The attribute value as a string. 1234 <p> 1235 * @note If an attribute with the properties given by <code>triple</code> does not 1236 * exist in this {@link XMLAttributes} object, this method will return an empty 1237 * string. Callers can use 1238 * {@link XMLAttributes#hasAttribute(String name, String uri)} 1239 * to test for an attribute's existence. 1240 <p> 1241 * @see #hasAttribute(String name, String uri) 1242 * @see #hasAttribute(XMLTriple triple) 1243 */ public 1244 String getValue(XMLTriple triple) { 1245 return libsbmlJNI.XMLAttributes_getValue__SWIG_3(swigCPtr, this, XMLTriple.getCPtr(triple), triple); 1246 } 1247 1248 1249/** 1250 * Returns <code>true</code> if an attribute exists at a given index. 1251 <p> 1252 * @param index an integer, the position of the attribute to be tested. 1253 <p> 1254 * @return <code>true</code> if an attribute with the given index exists in this 1255 * {@link XMLAttributes} object, <code>false</code> otherwise. 1256 <p> 1257 * <p> 1258 * @note Note that although {@link XMLAttributes} provides operations that can 1259 * manipulate attributes based on a numerical index, XML attributes are in 1260 * fact unordered when they appear in files and data streams. The 1261 * {@link XMLAttributes} class provides some list-like facilities, but it is only for 1262 * the convenience of callers. (For example, it permits callers to loop 1263 * across all attributes more easily.) Users should keep in mind that the 1264 * order in which attributes are stored in {@link XMLAttributes} objects has no real 1265 * impact on the order in which the attributes are read or written from an 1266 * XML file or data stream. 1267 */ public 1268 boolean hasAttribute(int index) { 1269 return libsbmlJNI.XMLAttributes_hasAttribute__SWIG_0(swigCPtr, this, index); 1270 } 1271 1272 1273/** 1274 * Returns <code>true</code> if an attribute with a given name and namespace URI 1275 * exists. 1276 <p> 1277 * @param name a string, the unprefixed name of the attribute. 1278 * @param uri a string, the XML namespace URI of the attribute. 1279 <p> 1280 * @return <code>true</code> if an attribute with the given local name and XML 1281 * namespace URI exists in this {@link XMLAttributes} object, <code>false</code> otherwise. 1282 <p> 1283 * @see #add(String name, String value, String namespaceURI, String prefix) 1284 * @see #add(XMLTriple triple, String value) 1285 */ public 1286 boolean hasAttribute(String name, String uri) { 1287 return libsbmlJNI.XMLAttributes_hasAttribute__SWIG_1(swigCPtr, this, name, uri); 1288 } 1289 1290 1291/** 1292 * Returns <code>true</code> if an attribute with a given name and namespace URI 1293 * exists. 1294 <p> 1295 * @param name a string, the unprefixed name of the attribute. 1296 * @param uri a string, the XML namespace URI of the attribute. 1297 <p> 1298 * @return <code>true</code> if an attribute with the given local name and XML 1299 * namespace URI exists in this {@link XMLAttributes} object, <code>false</code> otherwise. 1300 <p> 1301 * @see #add(String name, String value, String namespaceURI, String prefix) 1302 * @see #add(XMLTriple triple, String value) 1303 */ public 1304 boolean hasAttribute(String name) { 1305 return libsbmlJNI.XMLAttributes_hasAttribute__SWIG_2(swigCPtr, this, name); 1306 } 1307 1308 1309/** 1310 * Returns <code>true</code> if an attribute with the given properties exists. 1311 <p> 1312 * @param triple an {@link XMLTriple} describing the attribute to be tested. 1313 <p> 1314 * @return <code>true</code> if an attribute with the given XML triple exists in this 1315 * {@link XMLAttributes} object, <code>false</code> otherwise. 1316 <p> 1317 * @see #add(String name, String value, String namespaceURI, String prefix) 1318 * @see #add(XMLTriple triple, String value) 1319 */ public 1320 boolean hasAttribute(XMLTriple triple) { 1321 return libsbmlJNI.XMLAttributes_hasAttribute__SWIG_3(swigCPtr, this, XMLTriple.getCPtr(triple), triple); 1322 } 1323 1324 1325/** 1326 * Returns <code>true</code> if this list of attributes is empty. 1327 <p> 1328 * @return <code>true</code> if this {@link XMLAttributes} object is empty, <code>false</code> 1329 * otherwise. 1330 */ public 1331 boolean isEmpty() { 1332 return libsbmlJNI.XMLAttributes_isEmpty(swigCPtr, this); 1333 } 1334 1335}