001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.7 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 node in libSBML's XML document tree. 013 <p> 014 * LibSBML implements an XML abstraction layer. This layer presents a 015 * uniform XML interface to calling programs regardless of which underlying 016 * XML parser libSBML has actually been configured to use. The basic data 017 * object in the XML abstraction is a <em>node</em>, represented by {@link XMLNode}. 018 <p> 019 * An {@link XMLNode} can contain any number of children. Each child is another 020 * {@link XMLNode}, thereby forming a tree. The methods {@link XMLNode#getNumChildren()} 021 * and {@link XMLNode#getChild(long)} can be used to access the tree 022 * structure starting from a given node. 023 <p> 024 * Each {@link XMLNode} is subclassed from {@link XMLToken}, and thus has the same methods 025 * available as {@link XMLToken}. These methods include {@link XMLToken#getNamespaces()}, 026 * {@link XMLToken#getPrefix()}, {@link XMLToken#getName()}, {@link XMLToken#getURI()}, and 027 * {@link XMLToken#getAttributes()}. 028 <p> 029 * <h2>Conversion between an XML string and an {@link XMLNode}</h2> 030 <p> 031 * LibSBML provides the following utility functions for converting an XML 032 * string (e.g., <code><annotation>...</annotation></code>) 033 * to/from an {@link XMLNode} object. 034 <p> 035 * <ul> 036 * <li> {@link XMLNode#toXMLString()} returns a string representation of the {@link XMLNode} 037 * object. 038 <p> 039 * <li> {@link XMLNode#convertXMLNodeToString(XMLNode)} (static 040 * function) returns a string representation of the given {@link XMLNode} object. 041 <p> 042 * <li> {@link XMLNode#convertStringToXMLNode(String)} (static 043 * function) returns an {@link XMLNode} object converted from the given XML string. 044 * 045 * </ul> <p> 046 * The returned {@link XMLNode} object by {@link XMLNode#convertStringToXMLNode(String)} is a dummy root (container) {@link XMLNode} if the given XML string 047 * has two or more top-level elements (e.g., 048 * "<code><p>...</p><p>...</p></code>"). In 049 * the dummy root node, each top-level element in the given XML string is 050 * contained as a child {@link XMLNode}. {@link XMLToken#isEOF()} can be used to identify 051 * if the returned {@link XMLNode} object is a dummy node or not. Here is an 052 * example: 053<p> 054<pre class='fragment'> 055// Checks if the returned {@link XMLNode} object is a dummy root node: 056 057String str = '...'; 058{@link XMLNode} xn = {@link XMLNode}.convertStringToXMLNode(str); 059if ( xn == null ) 060{ 061 // returned value is null (error) 062 ... 063} 064else if ( xn.isEOF() ) 065{ 066 // Root node is a dummy node. 067 for ( int i = 0; i < xn.getNumChildren(); i++ ) 068 { 069 // access to each child node of the dummy node. 070 {@link XMLNode} xnChild = xn.getChild(i); 071 ... 072 } 073} 074else 075{ 076 // Root node is NOT a dummy node. 077 ... 078} 079</pre> 080*/ 081 082public class XMLNode extends XMLToken { 083 private long swigCPtr; 084 085 protected XMLNode(long cPtr, boolean cMemoryOwn) 086 { 087 super(libsbmlJNI.XMLNode_SWIGUpcast(cPtr), cMemoryOwn); 088 swigCPtr = cPtr; 089 } 090 091 protected static long getCPtr(XMLNode obj) 092 { 093 return (obj == null) ? 0 : obj.swigCPtr; 094 } 095 096 protected static long getCPtrAndDisown (XMLNode obj) 097 { 098 long ptr = 0; 099 100 if (obj != null) 101 { 102 ptr = obj.swigCPtr; 103 obj.swigCMemOwn = false; 104 } 105 106 return ptr; 107 } 108 109 protected void finalize() { 110 delete(); 111 } 112 113 public synchronized void delete() { 114 if (swigCPtr != 0) { 115 if (swigCMemOwn) { 116 swigCMemOwn = false; 117 libsbmlJNI.delete_XMLNode(swigCPtr); 118 } 119 swigCPtr = 0; 120 } 121 super.delete(); 122 } 123 124 /** 125 * Equality comparison method for XMLNode. 126 * <p> 127 * Because the Java methods for libSBML are actually wrappers around code 128 * implemented in C++ and C, certain operations will not behave as 129 * expected. Equality comparison is one such case. An instance of a 130 * libSBML object class is actually a <em>proxy object</em> 131 * wrapping the real underlying C/C++ object. The normal <code>==</code> 132 * equality operator in Java will <em>only compare the Java proxy objects</em>, 133 * not the underlying native object. The result is almost never what you 134 * want in practical situations. Unfortunately, Java does not provide a 135 * way to override <code>==</code>. 136 * <p> 137 * The alternative that must be followed is to use the 138 * <code>equals()</code> method. The <code>equals</code> method on this 139 * class overrides the default java.lang.Object one, and performs an 140 * intelligent comparison of instances of objects of this class. The 141 * result is an assessment of whether two libSBML Java objects are truly 142 * the same underlying native-code objects. 143 * <p> 144 * The use of this method in practice is the same as the use of any other 145 * Java <code>equals</code> method. For example, 146 * <em>a</em><code>.equals(</code><em>b</em><code>)</code> returns 147 * <code>true</code> if <em>a</em> and <em>b</em> are references to the 148 * same underlying object. 149 * 150 * @param sb a reference to an object to which the current object 151 * instance will be compared 152 * 153 * @return <code>true</code> if <code>sb</code> refers to the same underlying 154 * native object as this one, <code>false</code> otherwise 155 */ 156 public boolean equals(Object sb) 157 { 158 if ( this == sb ) 159 { 160 return true; 161 } 162 return swigCPtr == getCPtr((XMLNode)(sb)); 163 } 164 165 /** 166 * Returns a hashcode for this XMLNode object. 167 * 168 * @return a hash code usable by Java methods that need them. 169 */ 170 public int hashCode() 171 { 172 return (int)(swigCPtr^(swigCPtr>>>32)); 173 } 174 175 176/** 177 * Creates a new empty {@link XMLNode} with no children. 178 */ public 179 XMLNode() throws org.sbml.libsbml.XMLConstructorException { 180 this(libsbmlJNI.new_XMLNode__SWIG_0(), true); 181 } 182 183 184/** 185 * Creates a new {@link XMLNode} by copying an {@link XMLToken} object. 186 <p> 187 * @param token {@link XMLToken} to be copied to {@link XMLNode} 188 */ public 189 XMLNode(XMLToken token) throws org.sbml.libsbml.XMLConstructorException { 190 this(libsbmlJNI.new_XMLNode__SWIG_1(XMLToken.getCPtr(token), token), true); 191 } 192 193 194/** 195 * Creates a new start element {@link XMLNode} with the given set of attributes and 196 * namespace declarations. 197 <p> 198 * @param triple {@link XMLTriple}. 199 * @param attributes {@link XMLAttributes}, the attributes to set. 200 * @param namespaces {@link XMLNamespaces}, the namespaces to set. 201 * @param line a long integer, the line number (default = 0). 202 * @param column a long integer, the column number (default = 0). 203 <p> 204 * 205</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 206The native C++ implementation of this method defines a default argument 207value. In the documentation generated for different libSBML language 208bindings, you may or may not see corresponding arguments in the method 209declarations. For example, in Java and C#, a default argument is handled by 210declaring two separate methods, with one of them having the argument and 211the other one lacking the argument. However, the libSBML documentation will 212be <em>identical</em> for both methods. Consequently, if you are reading 213this and do not see an argument even though one is described, please look 214for descriptions of other variants of this method near where this one 215appears in the documentation. 216</dd></dl> 217 218 */ public 219 XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line, long column) throws org.sbml.libsbml.XMLConstructorException { 220 this(libsbmlJNI.new_XMLNode__SWIG_2(XMLTriple.getCPtr(triple), triple, XMLAttributes.getCPtr(attributes), attributes, XMLNamespaces.getCPtr(namespaces), namespaces, line, column), true); 221 } 222 223 224/** 225 * Creates a new start element {@link XMLNode} with the given set of attributes and 226 * namespace declarations. 227 <p> 228 * @param triple {@link XMLTriple}. 229 * @param attributes {@link XMLAttributes}, the attributes to set. 230 * @param namespaces {@link XMLNamespaces}, the namespaces to set. 231 * @param line a long integer, the line number (default = 0). 232 * @param column a long integer, the column number (default = 0). 233 <p> 234 * 235</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 236The native C++ implementation of this method defines a default argument 237value. In the documentation generated for different libSBML language 238bindings, you may or may not see corresponding arguments in the method 239declarations. For example, in Java and C#, a default argument is handled by 240declaring two separate methods, with one of them having the argument and 241the other one lacking the argument. However, the libSBML documentation will 242be <em>identical</em> for both methods. Consequently, if you are reading 243this and do not see an argument even though one is described, please look 244for descriptions of other variants of this method near where this one 245appears in the documentation. 246</dd></dl> 247 248 */ public 249 XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line) throws org.sbml.libsbml.XMLConstructorException { 250 this(libsbmlJNI.new_XMLNode__SWIG_3(XMLTriple.getCPtr(triple), triple, XMLAttributes.getCPtr(attributes), attributes, XMLNamespaces.getCPtr(namespaces), namespaces, line), true); 251 } 252 253 254/** 255 * Creates a new start element {@link XMLNode} with the given set of attributes and 256 * namespace declarations. 257 <p> 258 * @param triple {@link XMLTriple}. 259 * @param attributes {@link XMLAttributes}, the attributes to set. 260 * @param namespaces {@link XMLNamespaces}, the namespaces to set. 261 * @param line a long integer, the line number (default = 0). 262 * @param column a long integer, the column number (default = 0). 263 <p> 264 * 265</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 266The native C++ implementation of this method defines a default argument 267value. In the documentation generated for different libSBML language 268bindings, you may or may not see corresponding arguments in the method 269declarations. For example, in Java and C#, a default argument is handled by 270declaring two separate methods, with one of them having the argument and 271the other one lacking the argument. However, the libSBML documentation will 272be <em>identical</em> for both methods. Consequently, if you are reading 273this and do not see an argument even though one is described, please look 274for descriptions of other variants of this method near where this one 275appears in the documentation. 276</dd></dl> 277 278 */ public 279 XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces) throws org.sbml.libsbml.XMLConstructorException { 280 this(libsbmlJNI.new_XMLNode__SWIG_4(XMLTriple.getCPtr(triple), triple, XMLAttributes.getCPtr(attributes), attributes, XMLNamespaces.getCPtr(namespaces), namespaces), true); 281 } 282 283 284/** 285 * Creates a start element {@link XMLNode} with the given set of attributes. 286 <p> 287 * @param triple {@link XMLTriple}. 288 * @param attributes {@link XMLAttributes}, the attributes to set. 289 * @param line a long integer, the line number (default = 0). 290 * @param column a long integer, the column number (default = 0). 291 <p> 292 * 293</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 294The native C++ implementation of this method defines a default argument 295value. In the documentation generated for different libSBML language 296bindings, you may or may not see corresponding arguments in the method 297declarations. For example, in Java and C#, a default argument is handled by 298declaring two separate methods, with one of them having the argument and 299the other one lacking the argument. However, the libSBML documentation will 300be <em>identical</em> for both methods. Consequently, if you are reading 301this and do not see an argument even though one is described, please look 302for descriptions of other variants of this method near where this one 303appears in the documentation. 304</dd></dl> 305 306 */ public 307 XMLNode(XMLTriple triple, XMLAttributes attributes, long line, long column) throws org.sbml.libsbml.XMLConstructorException { 308 this(libsbmlJNI.new_XMLNode__SWIG_5(XMLTriple.getCPtr(triple), triple, XMLAttributes.getCPtr(attributes), attributes, line, column), true); 309 } 310 311 312/** 313 * Creates a start element {@link XMLNode} with the given set of attributes. 314 <p> 315 * @param triple {@link XMLTriple}. 316 * @param attributes {@link XMLAttributes}, the attributes to set. 317 * @param line a long integer, the line number (default = 0). 318 * @param column a long integer, the column number (default = 0). 319 <p> 320 * 321</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 322The native C++ implementation of this method defines a default argument 323value. In the documentation generated for different libSBML language 324bindings, you may or may not see corresponding arguments in the method 325declarations. For example, in Java and C#, a default argument is handled by 326declaring two separate methods, with one of them having the argument and 327the other one lacking the argument. However, the libSBML documentation will 328be <em>identical</em> for both methods. Consequently, if you are reading 329this and do not see an argument even though one is described, please look 330for descriptions of other variants of this method near where this one 331appears in the documentation. 332</dd></dl> 333 334 */ public 335 XMLNode(XMLTriple triple, XMLAttributes attributes, long line) throws org.sbml.libsbml.XMLConstructorException { 336 this(libsbmlJNI.new_XMLNode__SWIG_6(XMLTriple.getCPtr(triple), triple, XMLAttributes.getCPtr(attributes), attributes, line), true); 337 } 338 339 340/** 341 * Creates a start element {@link XMLNode} with the given set of attributes. 342 <p> 343 * @param triple {@link XMLTriple}. 344 * @param attributes {@link XMLAttributes}, the attributes to set. 345 * @param line a long integer, the line number (default = 0). 346 * @param column a long integer, the column number (default = 0). 347 <p> 348 * 349</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 350The native C++ implementation of this method defines a default argument 351value. In the documentation generated for different libSBML language 352bindings, you may or may not see corresponding arguments in the method 353declarations. For example, in Java and C#, a default argument is handled by 354declaring two separate methods, with one of them having the argument and 355the other one lacking the argument. However, the libSBML documentation will 356be <em>identical</em> for both methods. Consequently, if you are reading 357this and do not see an argument even though one is described, please look 358for descriptions of other variants of this method near where this one 359appears in the documentation. 360</dd></dl> 361 362 */ public 363 XMLNode(XMLTriple triple, XMLAttributes attributes) throws org.sbml.libsbml.XMLConstructorException { 364 this(libsbmlJNI.new_XMLNode__SWIG_7(XMLTriple.getCPtr(triple), triple, XMLAttributes.getCPtr(attributes), attributes), true); 365 } 366 367 368/** 369 * Creates an end element {@link XMLNode}. 370 <p> 371 * @param triple {@link XMLTriple}. 372 * @param line a long integer, the line number (default = 0). 373 * @param column a long integer, the column number (default = 0). 374 <p> 375 * 376</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 377The native C++ implementation of this method defines a default argument 378value. In the documentation generated for different libSBML language 379bindings, you may or may not see corresponding arguments in the method 380declarations. For example, in Java and C#, a default argument is handled by 381declaring two separate methods, with one of them having the argument and 382the other one lacking the argument. However, the libSBML documentation will 383be <em>identical</em> for both methods. Consequently, if you are reading 384this and do not see an argument even though one is described, please look 385for descriptions of other variants of this method near where this one 386appears in the documentation. 387</dd></dl> 388 389 */ public 390 XMLNode(XMLTriple triple, long line, long column) throws org.sbml.libsbml.XMLConstructorException { 391 this(libsbmlJNI.new_XMLNode__SWIG_8(XMLTriple.getCPtr(triple), triple, line, column), true); 392 } 393 394 395/** 396 * Creates an end element {@link XMLNode}. 397 <p> 398 * @param triple {@link XMLTriple}. 399 * @param line a long integer, the line number (default = 0). 400 * @param column a long integer, the column number (default = 0). 401 <p> 402 * 403</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 404The native C++ implementation of this method defines a default argument 405value. In the documentation generated for different libSBML language 406bindings, you may or may not see corresponding arguments in the method 407declarations. For example, in Java and C#, a default argument is handled by 408declaring two separate methods, with one of them having the argument and 409the other one lacking the argument. However, the libSBML documentation will 410be <em>identical</em> for both methods. Consequently, if you are reading 411this and do not see an argument even though one is described, please look 412for descriptions of other variants of this method near where this one 413appears in the documentation. 414</dd></dl> 415 416 */ public 417 XMLNode(XMLTriple triple, long line) throws org.sbml.libsbml.XMLConstructorException { 418 this(libsbmlJNI.new_XMLNode__SWIG_9(XMLTriple.getCPtr(triple), triple, line), true); 419 } 420 421 422/** 423 * Creates an end element {@link XMLNode}. 424 <p> 425 * @param triple {@link XMLTriple}. 426 * @param line a long integer, the line number (default = 0). 427 * @param column a long integer, the column number (default = 0). 428 <p> 429 * 430</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 431The native C++ implementation of this method defines a default argument 432value. In the documentation generated for different libSBML language 433bindings, you may or may not see corresponding arguments in the method 434declarations. For example, in Java and C#, a default argument is handled by 435declaring two separate methods, with one of them having the argument and 436the other one lacking the argument. However, the libSBML documentation will 437be <em>identical</em> for both methods. Consequently, if you are reading 438this and do not see an argument even though one is described, please look 439for descriptions of other variants of this method near where this one 440appears in the documentation. 441</dd></dl> 442 443 */ public 444 XMLNode(XMLTriple triple) throws org.sbml.libsbml.XMLConstructorException { 445 this(libsbmlJNI.new_XMLNode__SWIG_10(XMLTriple.getCPtr(triple), triple), true); 446 } 447 448 449/** 450 * Creates a text {@link XMLNode}. 451 <p> 452 * @param chars a string, the text to be added to the {@link XMLToken} 453 * @param line a long integer, the line number (default = 0). 454 * @param column a long integer, the column number (default = 0). 455 <p> 456 * 457</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 458The native C++ implementation of this method defines a default argument 459value. In the documentation generated for different libSBML language 460bindings, you may or may not see corresponding arguments in the method 461declarations. For example, in Java and C#, a default argument is handled by 462declaring two separate methods, with one of them having the argument and 463the other one lacking the argument. However, the libSBML documentation will 464be <em>identical</em> for both methods. Consequently, if you are reading 465this and do not see an argument even though one is described, please look 466for descriptions of other variants of this method near where this one 467appears in the documentation. 468</dd></dl> 469 470 */ public 471 XMLNode(String chars, long line, long column) throws org.sbml.libsbml.XMLConstructorException { 472 this(libsbmlJNI.new_XMLNode__SWIG_11(chars, line, column), true); 473 } 474 475 476/** 477 * Creates a text {@link XMLNode}. 478 <p> 479 * @param chars a string, the text to be added to the {@link XMLToken} 480 * @param line a long integer, the line number (default = 0). 481 * @param column a long integer, the column number (default = 0). 482 <p> 483 * 484</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 485The native C++ implementation of this method defines a default argument 486value. In the documentation generated for different libSBML language 487bindings, you may or may not see corresponding arguments in the method 488declarations. For example, in Java and C#, a default argument is handled by 489declaring two separate methods, with one of them having the argument and 490the other one lacking the argument. However, the libSBML documentation will 491be <em>identical</em> for both methods. Consequently, if you are reading 492this and do not see an argument even though one is described, please look 493for descriptions of other variants of this method near where this one 494appears in the documentation. 495</dd></dl> 496 497 */ public 498 XMLNode(String chars, long line) throws org.sbml.libsbml.XMLConstructorException { 499 this(libsbmlJNI.new_XMLNode__SWIG_12(chars, line), true); 500 } 501 502 503/** 504 * Creates a text {@link XMLNode}. 505 <p> 506 * @param chars a string, the text to be added to the {@link XMLToken} 507 * @param line a long integer, the line number (default = 0). 508 * @param column a long integer, the column number (default = 0). 509 <p> 510 * 511</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 512The native C++ implementation of this method defines a default argument 513value. In the documentation generated for different libSBML language 514bindings, you may or may not see corresponding arguments in the method 515declarations. For example, in Java and C#, a default argument is handled by 516declaring two separate methods, with one of them having the argument and 517the other one lacking the argument. However, the libSBML documentation will 518be <em>identical</em> for both methods. Consequently, if you are reading 519this and do not see an argument even though one is described, please look 520for descriptions of other variants of this method near where this one 521appears in the documentation. 522</dd></dl> 523 524 */ public 525 XMLNode(String chars) throws org.sbml.libsbml.XMLConstructorException { 526 this(libsbmlJNI.new_XMLNode__SWIG_13(chars), true); 527 } 528 529 530/** * @internal */ public 531 XMLNode(XMLInputStream stream) throws org.sbml.libsbml.XMLConstructorException { 532 this(libsbmlJNI.new_XMLNode__SWIG_14(XMLInputStream.getCPtr(stream), stream), true); 533 } 534 535 536/** 537 * Copy constructor; creates a copy of this {@link XMLNode}. 538 <p> 539 * @param orig the {@link XMLNode} instance to copy. 540 */ public 541 XMLNode(XMLNode orig) throws org.sbml.libsbml.XMLConstructorException { 542 this(libsbmlJNI.new_XMLNode__SWIG_15(XMLNode.getCPtr(orig), orig), true); 543 } 544 545 546/** 547 * Creates and returns a deep copy of this {@link XMLNode} object. 548 <p> 549 * @return the (deep) copy of this {@link XMLNode} object. 550 */ public 551 XMLNode cloneObject() { 552 long cPtr = libsbmlJNI.XMLNode_cloneObject(swigCPtr, this); 553 return (cPtr == 0) ? null : new XMLNode(cPtr, true); 554 } 555 556 557/** 558 * Adds a copy of <code>node</code> as a child of this {@link XMLNode}. 559 <p> 560 * The given <code>node</code> is added at the end of the list of children. 561 <p> 562 * @param node the {@link XMLNode} to be added as child. 563 <p> 564 * <p> 565 * @return integer value indicating success/failure of the 566 * function. The possible values 567 * returned by this function are: 568 * <ul> 569 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 570 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 571 * <li> {@link libsbmlConstants#LIBSBML_INVALID_XML_OPERATION LIBSBML_INVALID_XML_OPERATION} 572 * 573 * </ul> <p> 574 * @note The given node is added at the end of the children list. 575 */ public 576 int addChild(XMLNode node) { 577 return libsbmlJNI.XMLNode_addChild(swigCPtr, this, XMLNode.getCPtr(node), node); 578 } 579 580 581/** 582 * Inserts a copy of the given node as the <code>n</code>th child of this 583 * {@link XMLNode}. 584 <p> 585 * If the given index <code>n</code> is out of range for this {@link XMLNode} instance, 586 * the <code>node</code> is added at the end of the list of children. Even in 587 * that situation, this method does not throw an error. 588 <p> 589 * @param n an integer, the index at which the given node is inserted 590 * @param node an {@link XMLNode} to be inserted as <code>n</code>th child. 591 <p> 592 * @return a reference to the newly-inserted child <code>node</code> 593 */ public 594 XMLNode insertChild(long n, XMLNode node) { 595 return new XMLNode(libsbmlJNI.XMLNode_insertChild(swigCPtr, this, n, XMLNode.getCPtr(node), node), false); 596 } 597 598 599/** 600 * Removes the <code>n</code>th child of this {@link XMLNode} and returns the 601 * removed node. 602 <p> 603 * It is important to keep in mind that a given {@link XMLNode} may have more 604 * than one child. Calling this method erases all existing references to 605 * child nodes <em>after</em> the given position <code>n</code>. If the index <code>n</code> is 606 * greater than the number of child nodes in this {@link XMLNode}, this method 607 * takes no action (and returns <code>null</code>). 608 <p> 609 * @param n an integer, the index of the node to be removed 610 <p> 611 * @return the removed child, or <code>null</code> if <code>n</code> is greater than the number 612 * of children in this node 613 <p> 614 * @note The caller owns the returned node and is responsible for deleting it. 615 */ public 616 XMLNode removeChild(long n) { 617 long cPtr = libsbmlJNI.XMLNode_removeChild(swigCPtr, this, n); 618 return (cPtr == 0) ? null : new XMLNode(cPtr, true); 619 } 620 621 622/** 623 * Removes all children from this node. 624 * <p> 625 * @return integer value indicating success/failure of the 626 * function. The possible values 627 * returned by this function are: 628 * <ul> 629 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 630 * </ul> 631 */ public 632 int removeChildren() { 633 return libsbmlJNI.XMLNode_removeChildren(swigCPtr, this); 634 } 635 636 637/** 638 * Returns the <code>n</code>th child of this {@link XMLNode}. 639 <p> 640 * If the index <code>n</code> is greater than the number of child nodes, 641 * this method returns an empty node. 642 <p> 643 * @param n a long integereger, the index of the node to return 644 <p> 645 * @return the <code>n</code>th child of this {@link XMLNode}. 646 */ public 647 XMLNode getChild(long n) { 648 return new XMLNode(libsbmlJNI.XMLNode_getChild__SWIG_0(swigCPtr, this, n), false); 649 } 650 651 652/** 653 * Returns the first child of this {@link XMLNode} with the corresponding name. 654 <p> 655 * If no child with corrsponding name can be found, 656 * this method returns an empty node. 657 <p> 658 * @param name the name of the node to return 659 <p> 660 * @return the first child of this {@link XMLNode} with given name. 661 */ public 662 XMLNode getChild(String name) { 663 return new XMLNode(libsbmlJNI.XMLNode_getChild__SWIG_2(swigCPtr, this, name), false); 664 } 665 666 667/** 668 * Return the index of the first child of this {@link XMLNode} with the given name. 669 <p> 670 * @param name a string, the name of the child for which the 671 * index is required. 672 <p> 673 * @return the index of the first child of this {@link XMLNode} with the given 674 * name, or -1 if not present. 675 */ public 676 int getIndex(String name) { 677 return libsbmlJNI.XMLNode_getIndex(swigCPtr, this, name); 678 } 679 680 681/** 682 * Return a boolean indicating whether this {@link XMLNode} has a child with the 683 * given name. 684 <p> 685 * @param name a string, the name of the child to be checked. 686 <p> 687 * @return boolean indicating whether this {@link XMLNode} has a child with the 688 * given name. 689 */ public 690 boolean hasChild(String name) { 691 return libsbmlJNI.XMLNode_hasChild(swigCPtr, this, name); 692 } 693 694 695/** 696 * Compare this {@link XMLNode} against another {@link XMLNode} returning true if both 697 * nodes represent the same XML tree, or false otherwise. 698 <p> 699 * @param other another {@link XMLNode} to compare against. 700 <p> 701 * @param ignoreURI whether to ignore the namespace URI when doing the 702 * comparison. 703 <p> 704 * @return boolean indicating whether this {@link XMLNode} represents the same XML 705 * tree as another. 706 */ public 707 boolean xmlEquals(XMLNode other, boolean ignoreURI) { 708 return libsbmlJNI.XMLNode_xmlEquals__SWIG_0(swigCPtr, this, XMLNode.getCPtr(other), other, ignoreURI); 709 } 710 711 712/** 713 * Compare this {@link XMLNode} against another {@link XMLNode} returning true if both 714 * nodes represent the same XML tree, or false otherwise. 715 <p> 716 * @param other another {@link XMLNode} to compare against. 717 <p> 718 * @param ignoreURI whether to ignore the namespace URI when doing the 719 * comparison. 720 <p> 721 * @return boolean indicating whether this {@link XMLNode} represents the same XML 722 * tree as another. 723 */ public 724 boolean xmlEquals(XMLNode other) { 725 return libsbmlJNI.XMLNode_xmlEquals__SWIG_1(swigCPtr, this, XMLNode.getCPtr(other), other); 726 } 727 728 729/** 730 * Returns the number of children for this {@link XMLNode}. 731 <p> 732 * @return the number of children for this {@link XMLNode}. 733 */ public 734 long getNumChildren() { 735 return libsbmlJNI.XMLNode_getNumChildren(swigCPtr, this); 736 } 737 738 739/** 740 * Returns a string representation of this {@link XMLNode}. 741 <p> 742 * @return a string derived from this {@link XMLNode}. 743 */ public 744 String toXMLString() { 745 return libsbmlJNI.XMLNode_toXMLString(swigCPtr, this); 746 } 747 748 749/** 750 * Returns a string representation of a given {@link XMLNode}. 751 <p> 752 * @param node the {@link XMLNode} to be represented as a string 753 <p> 754 * @return a string-form representation of <code>node</code> 755 */ public 756 static String convertXMLNodeToString(XMLNode node) { 757 return libsbmlJNI.XMLNode_convertXMLNodeToString(XMLNode.getCPtr(node), node); 758 } 759 760 761/** 762 * Returns an {@link XMLNode} which is derived from a string containing XML 763 * content. 764 <p> 765 * The XML namespace must be defined using argument <code>xmlns</code> if the 766 * corresponding XML namespace attribute is not part of the string of the 767 * first argument. 768 <p> 769 * @param xmlstr string to be converted to a XML node. 770 * @param xmlns {@link XMLNamespaces} the namespaces to set (default value is <code>null</code>). 771 <p> 772 * @note The caller owns the returned {@link XMLNode} and is reponsible for 773 * deleting it. The returned {@link XMLNode} object is a dummy root (container) 774 * {@link XMLNode} if the top-level element in the given XML string is NOT 775 * <code><html></code>, <code><body></code>, 776 * <code><annotation></code>, or <code><notes></code>. In 777 * the dummy root node, each top-level element in the given XML string is 778 * contained as a child {@link XMLNode}. {@link XMLToken#isEOF()} can be used to 779 * identify if the returned {@link XMLNode} object is a dummy node. 780 <p> 781 * @return a {@link XMLNode} which is converted from string <code>xmlstr</code>. If the 782 * conversion failed, this method returns <code>null.</code> 783 <p> 784 * 785</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 786The native C++ implementation of this method defines a default argument 787value. In the documentation generated for different libSBML language 788bindings, you may or may not see corresponding arguments in the method 789declarations. For example, in Java and C#, a default argument is handled by 790declaring two separate methods, with one of them having the argument and 791the other one lacking the argument. However, the libSBML documentation will 792be <em>identical</em> for both methods. Consequently, if you are reading 793this and do not see an argument even though one is described, please look 794for descriptions of other variants of this method near where this one 795appears in the documentation. 796</dd></dl> 797 798 */ public 799 static XMLNode convertStringToXMLNode(String xmlstr, XMLNamespaces xmlns) { 800 long cPtr = libsbmlJNI.XMLNode_convertStringToXMLNode__SWIG_0(xmlstr, XMLNamespaces.getCPtr(xmlns), xmlns); 801 return (cPtr == 0) ? null : new XMLNode(cPtr, true); 802 } 803 804 805/** 806 * Returns an {@link XMLNode} which is derived from a string containing XML 807 * content. 808 <p> 809 * The XML namespace must be defined using argument <code>xmlns</code> if the 810 * corresponding XML namespace attribute is not part of the string of the 811 * first argument. 812 <p> 813 * @param xmlstr string to be converted to a XML node. 814 * @param xmlns {@link XMLNamespaces} the namespaces to set (default value is <code>null</code>). 815 <p> 816 * @note The caller owns the returned {@link XMLNode} and is reponsible for 817 * deleting it. The returned {@link XMLNode} object is a dummy root (container) 818 * {@link XMLNode} if the top-level element in the given XML string is NOT 819 * <code><html></code>, <code><body></code>, 820 * <code><annotation></code>, or <code><notes></code>. In 821 * the dummy root node, each top-level element in the given XML string is 822 * contained as a child {@link XMLNode}. {@link XMLToken#isEOF()} can be used to 823 * identify if the returned {@link XMLNode} object is a dummy node. 824 <p> 825 * @return a {@link XMLNode} which is converted from string <code>xmlstr</code>. If the 826 * conversion failed, this method returns <code>null.</code> 827 <p> 828 * 829</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 830The native C++ implementation of this method defines a default argument 831value. In the documentation generated for different libSBML language 832bindings, you may or may not see corresponding arguments in the method 833declarations. For example, in Java and C#, a default argument is handled by 834declaring two separate methods, with one of them having the argument and 835the other one lacking the argument. However, the libSBML documentation will 836be <em>identical</em> for both methods. Consequently, if you are reading 837this and do not see an argument even though one is described, please look 838for descriptions of other variants of this method near where this one 839appears in the documentation. 840</dd></dl> 841 842 */ public 843 static XMLNode convertStringToXMLNode(String xmlstr) { 844 long cPtr = libsbmlJNI.XMLNode_convertStringToXMLNode__SWIG_1(xmlstr); 845 return (cPtr == 0) ? null : new XMLNode(cPtr, true); 846 } 847 848}