001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.12 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 <code>-1</code> 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 * @param ignoreAttributeValues whetehr to ignore attribute values when 705 * doing the comparison. 706 <p> 707 * @return boolean indicating whether this {@link XMLNode} represents the same XML 708 * tree as another. 709 */ public 710 boolean xmlEquals(XMLNode other, boolean ignoreURI, boolean ignoreAttributeValues) { 711 return libsbmlJNI.XMLNode_xmlEquals__SWIG_0(swigCPtr, this, XMLNode.getCPtr(other), other, ignoreURI, ignoreAttributeValues); 712 } 713 714 715/** 716 * Compare this {@link XMLNode} against another {@link XMLNode} returning true if both 717 * nodes represent the same XML tree, or false otherwise. 718 <p> 719 * @param other another {@link XMLNode} to compare against. 720 <p> 721 * @param ignoreURI whether to ignore the namespace URI when doing the 722 * comparison. 723 <p> 724 * @param ignoreAttributeValues whetehr to ignore attribute values when 725 * doing the comparison. 726 <p> 727 * @return boolean indicating whether this {@link XMLNode} represents the same XML 728 * tree as another. 729 */ public 730 boolean xmlEquals(XMLNode other, boolean ignoreURI) { 731 return libsbmlJNI.XMLNode_xmlEquals__SWIG_1(swigCPtr, this, XMLNode.getCPtr(other), other, ignoreURI); 732 } 733 734 735/** 736 * Compare this {@link XMLNode} against another {@link XMLNode} returning true if both 737 * nodes represent the same XML tree, or false otherwise. 738 <p> 739 * @param other another {@link XMLNode} to compare against. 740 <p> 741 * @param ignoreURI whether to ignore the namespace URI when doing the 742 * comparison. 743 <p> 744 * @param ignoreAttributeValues whetehr to ignore attribute values when 745 * doing the comparison. 746 <p> 747 * @return boolean indicating whether this {@link XMLNode} represents the same XML 748 * tree as another. 749 */ public 750 boolean xmlEquals(XMLNode other) { 751 return libsbmlJNI.XMLNode_xmlEquals__SWIG_2(swigCPtr, this, XMLNode.getCPtr(other), other); 752 } 753 754 755/** 756 * Returns the number of children for this {@link XMLNode}. 757 <p> 758 * @return the number of children for this {@link XMLNode}. 759 */ public 760 long getNumChildren() { 761 return libsbmlJNI.XMLNode_getNumChildren(swigCPtr, this); 762 } 763 764 765/** * @internal */ public 766 void writeToStream(XMLOutputStream stream) { 767 libsbmlJNI.XMLNode_writeToStream(swigCPtr, this, XMLOutputStream.getCPtr(stream), stream); 768 } 769 770 771/** 772 * Returns a string representation of this {@link XMLNode}. 773 <p> 774 * @return a string derived from this {@link XMLNode}. 775 */ public 776 String toXMLString() { 777 return libsbmlJNI.XMLNode_toXMLString(swigCPtr, this); 778 } 779 780 781/** 782 * Returns a string representation of a given {@link XMLNode}. 783 <p> 784 * @param node the {@link XMLNode} to be represented as a string. 785 <p> 786 * @return a string-form representation of <code>node</code>. 787 */ public 788 static String convertXMLNodeToString(XMLNode node) { 789 return libsbmlJNI.XMLNode_convertXMLNodeToString(XMLNode.getCPtr(node), node); 790 } 791 792 793/** 794 * Returns an {@link XMLNode} which is derived from a string containing XML 795 * content. 796 <p> 797 * The XML namespace must be defined using argument <code>xmlns</code> if the 798 * corresponding XML namespace attribute is not part of the string of the 799 * first argument. 800 <p> 801 * @param xmlstr string to be converted to a XML node. 802 * @param xmlns {@link XMLNamespaces} the namespaces to set (default value is <code>null</code>). 803 <p> 804 * @note The caller owns the returned {@link XMLNode} and is reponsible for 805 * deleting it. The returned {@link XMLNode} object is a dummy root (container) 806 * {@link XMLNode} if the top-level element in the given XML string is NOT 807 * <code><html></code>, <code><body></code>, 808 * <code><annotation></code>, or <code><notes></code>. In 809 * the dummy root node, each top-level element in the given XML string is 810 * contained as a child {@link XMLNode}. {@link XMLToken#isEOF()} can be used to 811 * identify if the returned {@link XMLNode} object is a dummy node. 812 <p> 813 * @return a {@link XMLNode} which is converted from string <code>xmlstr</code>. If the 814 * conversion failed, this method returns <code>null.</code> 815 <p> 816 * 817</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 818The native C++ implementation of this method defines a default argument 819value. In the documentation generated for different libSBML language 820bindings, you may or may not see corresponding arguments in the method 821declarations. For example, in Java and C#, a default argument is handled by 822declaring two separate methods, with one of them having the argument and 823the other one lacking the argument. However, the libSBML documentation will 824be <em>identical</em> for both methods. Consequently, if you are reading 825this and do not see an argument even though one is described, please look 826for descriptions of other variants of this method near where this one 827appears in the documentation. 828</dd></dl> 829 830 */ public 831 static XMLNode convertStringToXMLNode(String xmlstr, XMLNamespaces xmlns) { 832 long cPtr = libsbmlJNI.XMLNode_convertStringToXMLNode__SWIG_0(xmlstr, XMLNamespaces.getCPtr(xmlns), xmlns); 833 return (cPtr == 0) ? null : new XMLNode(cPtr, true); 834 } 835 836 837/** 838 * Returns an {@link XMLNode} which is derived from a string containing XML 839 * content. 840 <p> 841 * The XML namespace must be defined using argument <code>xmlns</code> if the 842 * corresponding XML namespace attribute is not part of the string of the 843 * first argument. 844 <p> 845 * @param xmlstr string to be converted to a XML node. 846 * @param xmlns {@link XMLNamespaces} the namespaces to set (default value is <code>null</code>). 847 <p> 848 * @note The caller owns the returned {@link XMLNode} and is reponsible for 849 * deleting it. The returned {@link XMLNode} object is a dummy root (container) 850 * {@link XMLNode} if the top-level element in the given XML string is NOT 851 * <code><html></code>, <code><body></code>, 852 * <code><annotation></code>, or <code><notes></code>. In 853 * the dummy root node, each top-level element in the given XML string is 854 * contained as a child {@link XMLNode}. {@link XMLToken#isEOF()} can be used to 855 * identify if the returned {@link XMLNode} object is a dummy node. 856 <p> 857 * @return a {@link XMLNode} which is converted from string <code>xmlstr</code>. If the 858 * conversion failed, this method returns <code>null.</code> 859 <p> 860 * 861</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd> 862The native C++ implementation of this method defines a default argument 863value. In the documentation generated for different libSBML language 864bindings, you may or may not see corresponding arguments in the method 865declarations. For example, in Java and C#, a default argument is handled by 866declaring two separate methods, with one of them having the argument and 867the other one lacking the argument. However, the libSBML documentation will 868be <em>identical</em> for both methods. Consequently, if you are reading 869this and do not see an argument even though one is described, please look 870for descriptions of other variants of this method near where this one 871appears in the documentation. 872</dd></dl> 873 874 */ public 875 static XMLNode convertStringToXMLNode(String xmlstr) { 876 long cPtr = libsbmlJNI.XMLNode_convertStringToXMLNode__SWIG_1(xmlstr); 877 return (cPtr == 0) ? null : new XMLNode(cPtr, true); 878 } 879 880}