001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.8 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 * Abstract Syntax Trees for mathematical expressions. 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 * <a target='_blank' 023 * href='http://en.wikipedia.org/wiki/Abstract_syntax_tree'>Abstract Syntax 024 * Trees</a> (ASTs) are a simple kind of data structure used in libSBML for 025 * storing mathematical expressions. LibSBML ASTs provide a canonical, 026 * in-memory representation for all mathematical formulas regardless of their 027 * original format (which might be MathML or might be text strings). 028 <p> 029 * <p> 030 * An AST <em>node</em> in libSBML is a recursive tree structure; each node has a 031 * type, a pointer to a value, and a list of children nodes. Each {@link ASTNode} 032 * node may have none, one, two, or more children depending on its type. 033 * There are node types to represent numbers (with subtypes to distinguish 034 * integer, real, and rational numbers), names (e.g., constants or 035 * variables), simple mathematical operators, logical or relational operators 036 * and functions. The following diagram illustrates an example of how the 037 * mathematical expression <code>'1 + 2'</code> is represented as an AST with 038 * one <em>plus</em> node having two <em>integer</em> children nodes for the numbers 039 * <code>1</code> and <code>2</code>. The figure also shows the 040 * corresponding MathML representation: 041 <p> 042 * <table border="0" class="centered text-table width80 normal-font" style="padding-bottom: 0.5em"> 043<caption class="top-caption">Example AST representation of a mathematical expression.</caption> 044<tr> 045<th width="50px">Infix</th> 046<th>AST</th> 047<th>MathML</th> 048</tr> 049<tr> 050<td valign="middle" align="center"> 051<code>1 + 2</code> 052</td> 053<td valign="middle"> 054 <object type="image/svg+xml" data="simple-ast.svg" class="centered" width="140px"></object> 055</td> 056<td valign="middle"> 057<code><math xmlns="http://www.w3.org/1998/Math/MathML"></code><br> 058<code> <apply></code><br> 059<code> <plus/></code><br> 060<code> <cn type="integer"> 1 </cn></code><br> 061<code> <cn type="integer"> 2 </cn></code><br> 062<code> </apply></code><br> 063<code></math></code> 064</td> 065</tr> 066</table> 067 068 <p> 069 * The following are other noteworthy points about the AST representation 070 * in libSBML: 071<p> 072 * <ul> 073 * <li> A numerical value represented in MathML as a real number with an 074 * exponent is preserved as such in the AST node representation, even if the 075 * number could be stored in a <code>double</code> data type. This is done so that 076 * when an SBML model is read in and then written out again, the amount of 077 * change introduced by libSBML to the SBML during the round-trip activity is 078 * minimized. 079 <p> 080 * <li> Rational numbers are represented in an AST node using separate 081 * numerator and denominator values. These can be retrieved using the 082 * methods {@link ASTNode#getNumerator()} and {@link ASTNode#getDenominator()}. 083 <p> 084 * <li> The children of an {@link ASTNode} are other {@link ASTNode} objects. The list of 085 * children is empty for nodes that are leaf elements, such as numbers. 086 * For nodes that are actually roots of expression subtrees, the list of 087 * children points to the parsed objects that make up the rest of the 088 * expression. 089 * 090 * </ul> <p> 091 * For many applications, the details of ASTs are irrelevant because libSBML 092 * provides text-string based translation functions such as 093 * <a href='libsbml.html#formulaToL3String(org.sbml.libsbml.ASTNode)'><code>libsbml.formulaToL3String(ASTNode)</code></a> and 094 * <a href='libsbml.html#parseL3Formula(java.lang.String)'><code>libsbml.parseL3Formula(String)</code></a>. If you find the complexity 095 * of using the AST representation of expressions too high for your purposes, 096 * perhaps the string-based functions will be more suitable. 097 <p> 098 * <h3><a class='anchor' 099 * name='ASTNodeType_t'>The set of possible ASTNode types</a></h3> 100 <p> 101 * <p> 102 * Every {@link ASTNode} has an associated type code to indicate whether, for 103 * example, it holds a number or stands for an arithmetic operator. 104 <p> 105 * The type is recorded as a value drawn from a 106 * set of static integer constants defined in the class {@link 107 * libsbmlConstants}. Their names begin with the characters <code>AST_.</code> 108 <p> 109 * The list of possible types is quite long, because it covers all the 110 * mathematical functions that are permitted in SBML. The values are shown 111 * in the following table: 112 <p> 113 * <table border="0" class="centered text-table borderless code"> 114<tr><td>AST_CONSTANT_E</td><td> AST_FUNCTION_COT</td><td> AST_LOGICAL_NOT</td></tr> 115<tr><td>AST_CONSTANT_FALSE</td><td> AST_FUNCTION_COTH</td><td> AST_LOGICAL_OR</td></tr> 116<tr><td>AST_CONSTANT_PI</td><td> AST_FUNCTION_CSC</td><td> AST_LOGICAL_XOR</td></tr> 117<tr><td>AST_CONSTANT_TRUE</td><td> AST_FUNCTION_CSCH</td><td> AST_MINUS</td></tr> 118<tr><td>AST_DIVIDE</td><td> AST_FUNCTION_DELAY</td><td> AST_NAME</td></tr> 119<tr><td>AST_FUNCTION</td><td> AST_FUNCTION_EXP</td><td> AST_NAME_AVOGADRO <span class='warning'><em>(Level 3 only)</em></span></td></tr> 120<tr><td>AST_FUNCTION_ABS</td><td> AST_FUNCTION_FACTORIAL</td><td> AST_NAME_TIME</td></tr> 121<tr><td>AST_FUNCTION_ARCCOS</td><td> AST_FUNCTION_FLOOR</td><td> AST_PLUS</td></tr> 122<tr><td>AST_FUNCTION_ARCCOSH</td><td> AST_FUNCTION_LN</td><td> AST_POWER</td></tr> 123<tr><td>AST_FUNCTION_ARCCOT</td><td> AST_FUNCTION_LOG</td><td> AST_RATIONAL</td></tr> 124<tr><td>AST_FUNCTION_ARCCOTH</td><td> AST_FUNCTION_PIECEWISE</td><td> AST_REAL</td></tr> 125<tr><td>AST_FUNCTION_ARCCSC</td><td> AST_FUNCTION_POWER</td><td> AST_REAL_E</td></tr> 126<tr><td>AST_FUNCTION_ARCCSCH</td><td> AST_FUNCTION_ROOT</td><td> AST_RELATIONAL_EQ</td></tr> 127<tr><td>AST_FUNCTION_ARCSEC</td><td> AST_FUNCTION_SEC</td><td> AST_RELATIONAL_GEQ</td></tr> 128<tr><td>AST_FUNCTION_ARCSECH</td><td> AST_FUNCTION_SECH</td><td> AST_RELATIONAL_GT</td></tr> 129<tr><td>AST_FUNCTION_ARCSIN</td><td> AST_FUNCTION_SIN</td><td> AST_RELATIONAL_LEQ</td></tr> 130<tr><td>AST_FUNCTION_ARCSINH</td><td> AST_FUNCTION_SINH</td><td> AST_RELATIONAL_LT</td></tr> 131<tr><td>AST_FUNCTION_ARCTAN</td><td> AST_FUNCTION_TAN</td><td> AST_RELATIONAL_NEQ</td></tr> 132<tr><td>AST_FUNCTION_ARCTANH</td><td> AST_FUNCTION_TANH</td><td> AST_TIMES</td></tr> 133<tr><td>AST_FUNCTION_CEILING</td><td> AST_INTEGER</td><td> AST_UNKNOWN</td></tr> 134<tr><td>AST_FUNCTION_COS</td><td> AST_LAMBDA</td></tr> 135<tr><td>AST_FUNCTION_COSH</td><td> AST_LOGICAL_AND</td></tr> 136</table> 137 138 <p> 139 * The types have the following meanings: 140 <p> 141 * <ul> 142 * <li> If the node is basic mathematical operator (e.g., <code>'+'</code>), then the 143 * node's type will be {@link libsbmlConstants#AST_PLUS AST_PLUS}, 144 * {@link libsbmlConstants#AST_MINUS AST_MINUS}, 145 * {@link libsbmlConstants#AST_TIMES AST_TIMES}, 146 * {@link libsbmlConstants#AST_DIVIDE AST_DIVIDE}, or 147 * {@link libsbmlConstants#AST_POWER AST_POWER}, as appropriate. 148 <p> 149 * <li> If the node is a predefined function or operator from SBML 150 * Level 1 (in the string-based formula syntax used in Level 1) or 151 * SBML Level 2 and 3 (in the subset of MathML used in SBML 152 * Levels 2 and 3), then the node's type 153 * will be either <code style='margin-right: 0'>AST_FUNCTION_</code><span 154 * class='placeholder-nospace'>X</span>, <code style='margin-right: 0'>AST_LOGICAL_</code><span 155 * class='placeholder-nospace'>X</span>, or <code style='margin-right: 0'>AST_RELATIONAL_</code><span 156 * class='placeholder-nospace'>X</span>, as appropriate. (Examples: 157 * {@link libsbmlConstants#AST_FUNCTION_LOG AST_FUNCTION_LOG}, 158 * {@link libsbmlConstants#AST_RELATIONAL_LEQ AST_RELATIONAL_LEQ}.) 159 <p> 160 * <li> If the node refers to a user-defined function, the node's type will 161 * be {@link libsbmlConstants#AST_FUNCTION AST_FUNCTION} (because it holds the 162 * name of the function). 163 <p> 164 * <li> If the node is a lambda expression, its type will be 165 * {@link libsbmlConstants#AST_LAMBDA AST_LAMBDA}. 166 <p> 167 * <li> If the node is a predefined constant (<code>'ExponentialE'</code>, <code>'Pi'</code>, 168 * <code>'True'</code> or <code>'False'</code>), then the node's type will be 169 * {@link libsbmlConstants#AST_CONSTANT_E AST_CONSTANT_E}, 170 * {@link libsbmlConstants#AST_CONSTANT_PI AST_CONSTANT_PI}, 171 * {@link libsbmlConstants#AST_CONSTANT_TRUE AST_CONSTANT_TRUE}, or 172 * {@link libsbmlConstants#AST_CONSTANT_FALSE AST_CONSTANT_FALSE}. 173 <p> 174 * <li> (Levels 2 and 3 only) If the node is the special MathML 175 * csymbol <code>time</code>, the value of the node will be 176 * {@link libsbmlConstants#AST_NAME_TIME AST_NAME_TIME}. (Note, however, that the 177 * MathML csymbol <code>delay</code> is translated into a node of type 178 * {@link libsbmlConstants#AST_FUNCTION_DELAY AST_FUNCTION_DELAY}. The difference is due to 179 * the fact that <code>time</code> is a single variable, whereas <code>delay</code> is actually a 180 * function taking arguments.) 181 <p> 182 * <li> (Level 3 only) If the node is the special MathML csymbol 183 * <code>avogadro</code>, the value of the node will be 184 * {@link libsbmlConstants#AST_NAME_AVOGADRO AST_NAME_AVOGADRO}. 185 <p> 186 * <li> If the node contains a numerical value, its type will be 187 * {@link libsbmlConstants#AST_INTEGER AST_INTEGER}, 188 * {@link libsbmlConstants#AST_REAL AST_REAL}, 189 * {@link libsbmlConstants#AST_REAL_E AST_REAL_E}, or 190 * {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}, as appropriate. 191 * 192 * </ul> 193 <p> 194 * <h3><a class='anchor' name='math-convert'>Converting between ASTs and text 195 * strings</a></h3> 196 <p> 197 * The text-string form of mathematical formulas produced by 198 * <a href='libsbml.html#formulaToString(java.lang.String)'><code>libsbml.formulaToString(String)</code></a> and 199 * <a href='libsbml.html#formulaToL3String(java.lang.String)'><code>libsbml.formulaToL3String(String)</code></a>, and read by 200 * <a href='libsbml.html#parseFormula(org.sbml.libsbml.ASTNode)'><code>libsbml.parseFormula(ASTNode)</code></a> and 201 * <a href='libsbml.html#parseL3Formula(org.sbml.libsbml.ASTNode)'><code>libsbml.parseL3Formula(ASTNode)</code></a>, are in a simple C-inspired 202 * infix notation. A formula in one of these two text-string formats can be 203 * handed to a program that understands SBML mathematical expressions, or 204 * used as part of a translation system. The libSBML distribution comes with 205 * example programs in the <code>'examples'</code> subdirectory that demonstrate such 206 * things as translating infix formulas into MathML and vice-versa. 207 <p> 208 * Please see the documentation for the functions <a href='libsbml.html#parseFormula(org.sbml.libsbml.ASTNode)'><code>libsbml.parseFormula(ASTNode)</code></a> and <a href='libsbml.html#parseL3Formula(org.sbml.libsbml.ASTNode)'><code>libsbml.parseL3Formula(ASTNode)</code></a> for detailed 209 * explanations of the infix syntax they accept. 210 <p> 211 * <h3><a class='anchor' name='math-history'>Historical notes</a></h3> 212 <p> 213 * Readers may wonder why this part of libSBML uses a seemingly less 214 * object-oriented design thanother parts. Originally, much of libSBML was 215 * written in C. All subsequent development was done in C++, but the 216 * complexity of some of the functionality for converting between infix, AST 217 * and MathML, coupled with the desire to maintain stability and backward 218 * compatibility, means that some of the underlying code is still written 219 * in C. This has lead to the exposed API being more C-like. 220<p> 221 * @see <a href='libsbml.html#parseL3Formula(java.lang.String)'><code>libsbml.parseL3Formula(String)</code></a> 222 * @see <a href='libsbml.html#parseL3FormulaWithSettings(java.lang.String, org.sbml.libsbml.L3ParserSettings)'><code>libsbml.parseL3FormulaWithSettings(String, L3ParserSettings)</code></a> 223 * @see <a href='libsbml.html#parseL3FormulaWithModel(java.lang.String, org.sbml.libsbml.Model)'><code>libsbml.parseL3FormulaWithModel(String, Model)</code></a> 224 * @see <a href='libsbml.html#parseFormula(java.lang.String)'><code>libsbml.parseFormula(String)</code></a> 225 * @see <a href='libsbml.html#formulaToL3StringWithSettings(org.sbml.libsbml.ASTNode, org.sbml.libsbml.L3ParserSettings)'><code>libsbml.formulaToL3StringWithSettings(ASTNode, L3ParserSettings)</code></a> 226 * @see <a href='libsbml.html#formulaToL3String(org.sbml.libsbml.ASTNode)'><code>libsbml.formulaToL3String(ASTNode)</code></a> 227 * @see <a href='libsbml.html#formulaToString(org.sbml.libsbml.ASTNode)'><code>libsbml.formulaToString(ASTNode)</code></a> 228 * @see <a href='libsbml.html#getDefaultL3ParserSettings()'><code>libsbml.getDefaultL3ParserSettings()</code></a> 229 */ 230 231public class ASTNode extends ASTBase { 232 private long swigCPtr; 233 234 protected ASTNode(long cPtr, boolean cMemoryOwn) 235 { 236 super(libsbmlJNI.ASTNode_SWIGUpcast(cPtr), cMemoryOwn); 237 swigCPtr = cPtr; 238 } 239 240 protected static long getCPtr(ASTNode obj) 241 { 242 return (obj == null) ? 0 : obj.swigCPtr; 243 } 244 245 protected static long getCPtrAndDisown (ASTNode obj) 246 { 247 long ptr = 0; 248 249 if (obj != null) 250 { 251 ptr = obj.swigCPtr; 252 obj.swigCMemOwn = false; 253 } 254 255 return ptr; 256 } 257 258 protected void finalize() { 259 delete(); 260 } 261 262 public synchronized void delete() { 263 if (swigCPtr != 0) { 264 if (swigCMemOwn) { 265 swigCMemOwn = false; 266 libsbmlJNI.delete_ASTNode(swigCPtr); 267 } 268 swigCPtr = 0; 269 } 270 super.delete(); 271 } 272 273 /** 274 * Equality comparison method for ASTNode. 275 * <p> 276 * Because the Java methods for libSBML are actually wrappers around code 277 * implemented in C++ and C, certain operations will not behave as 278 * expected. Equality comparison is one such case. An instance of a 279 * libSBML object class is actually a <em>proxy object</em> 280 * wrapping the real underlying C/C++ object. The normal <code>==</code> 281 * equality operator in Java will <em>only compare the Java proxy objects</em>, 282 * not the underlying native object. The result is almost never what you 283 * want in practical situations. Unfortunately, Java does not provide a 284 * way to override <code>==</code>. 285 * <p> 286 * The alternative that must be followed is to use the 287 * <code>equals()</code> method. The <code>equals</code> method on this 288 * class overrides the default java.lang.Object one, and performs an 289 * intelligent comparison of instances of objects of this class. The 290 * result is an assessment of whether two libSBML Java objects are truly 291 * the same underlying native-code objects. 292 * <p> 293 * The use of this method in practice is the same as the use of any other 294 * Java <code>equals</code> method. For example, 295 * <em>a</em><code>.equals(</code><em>b</em><code>)</code> returns 296 * <code>true</code> if <em>a</em> and <em>b</em> are references to the 297 * same underlying object. 298 * 299 * @param sb a reference to an object to which the current object 300 * instance will be compared 301 * 302 * @return <code>true</code> if <code>sb</code> refers to the same underlying 303 * native object as this one, <code>false</code> otherwise 304 */ 305 public boolean equals(Object sb) 306 { 307 if ( this == sb ) 308 { 309 return true; 310 } 311 return swigCPtr == getCPtr((ASTNode)(sb)); 312 } 313 314 /** 315 * Returns a hashcode for this ASTNode object. 316 * 317 * @return a hash code usable by Java methods that need them. 318 */ 319 public int hashCode() 320 { 321 return (int)(swigCPtr^(swigCPtr>>>32)); 322 } 323 324 325/** * @internal */ public 326 ASTNode(int type) { 327 this(libsbmlJNI.new_ASTNode__SWIG_0(type), true); 328 } 329 330 331/** * @internal */ public 332 ASTNode() { 333 this(libsbmlJNI.new_ASTNode__SWIG_1(), true); 334 } 335 336 337/** * @internal */ public 338 ASTNode(SBMLNamespaces sbmlns, int type) { 339 this(libsbmlJNI.new_ASTNode__SWIG_2(SBMLNamespaces.getCPtr(sbmlns), sbmlns, type), true); 340 } 341 342 343/** * @internal */ public 344 ASTNode(SBMLNamespaces sbmlns) { 345 this(libsbmlJNI.new_ASTNode__SWIG_3(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 346 } 347 348 349/** 350 * Copy constructor; creates a deep copy of the given {@link ASTNode}. 351 <p> 352 * @param orig the {@link ASTNode} to be copied. 353 */ public 354 ASTNode(ASTNode orig) { 355 this(libsbmlJNI.new_ASTNode__SWIG_4(ASTNode.getCPtr(orig), orig), true); 356 } 357 358 359/** 360 * Frees the name of this {@link ASTNode} and sets it to <code>null.</code> 361 <p> 362 * This operation is only applicable to {@link ASTNode} objects corresponding to 363 * operators, numbers, or {@link libsbmlConstants#AST_UNKNOWN AST_UNKNOWN}. This 364 * method has no effect on other types of nodes. 365 <p> 366 * <p> 367 * @return integer value indicating success/failure of the 368 * function. The possible values 369 * returned by this function are: 370 * <ul> 371 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 372 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 373 * </ul> 374 */ public 375 int freeName() { 376 return libsbmlJNI.ASTNode_freeName(swigCPtr, this); 377 } 378 379 380/** 381 * Converts this {@link ASTNode} to a canonical form. 382 <p> 383 * The rules determining the canonical form conversion are as follows: 384 <p> 385 * <ul> 386 * <li> If the node type is {@link libsbmlConstants#AST_NAME AST_NAME} 387 * and the node name matches <code>'ExponentialE'</code>, <code>'Pi'</code>, <code>'True'</code> or 388 * <code>'False'</code> the node type is converted to the corresponding 389 * <code>AST_CONSTANT_</code><em><span class='placeholder'>X</span></em> type. 390 * <li> If the node type is an {@link libsbmlConstants#AST_FUNCTION AST_FUNCTION} and 391 * the node name matches an SBML (MathML) function name, logical operator name, 392 * or relational operator name, the node is converted to the corresponding 393 * <code>AST_FUNCTION_</code><em><span class='placeholder'>X</span></em> or 394 * <code>AST_LOGICAL_</code><em><span class='placeholder'>X</span></em> type. 395 * 396 * </ul> <p> 397 * SBML Level 1 function names are searched first; thus, for example, 398 * canonicalizing <code>log</code> will result in a node type of 399 * {@link libsbmlConstants#AST_FUNCTION_LN AST_FUNCTION_LN}. (See the SBML 400 * Level 1 Version 2 Specification, Appendix C.) 401 <p> 402 * Sometimes, canonicalization of a node results in a structural conversion 403 * of the node as a result of adding a child. For example, a node with the 404 * SBML Level 1 function name <code>sqr</code> and a single child node (the 405 * argument) will be transformed to a node of type 406 * {@link libsbmlConstants#AST_FUNCTION_POWER AST_FUNCTION_POWER} with two children. The 407 * first child will remain unchanged, but the second child will be an 408 * {@link ASTNode} of type {@link libsbmlConstants#AST_INTEGER AST_INTEGER} and a value of 409 * 2. The function names that result in structural changes are: <code>log10</code>, 410 * <code>sqr</code>, and <code>sqrt.</code> 411 <p> 412 * @return <code>true</code> if this node was successfully converted to 413 * canonical form, <code>false</code> otherwise. 414 */ public 415 boolean canonicalize() { 416 return libsbmlJNI.ASTNode_canonicalize(swigCPtr, this); 417 } 418 419 420/** 421 * Adds the given node as a child of this {@link ASTNode}. 422 <p> 423 * Child nodes are added in-order, from left to right. 424 <p> 425 * @param disownedChild the {@link ASTNode} instance to add 426 <p> 427 * <p> 428 * @return integer value indicating success/failure of the 429 * function. The possible values 430 * returned by this function are: 431 * <ul> 432 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 433 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 434 * 435 * </ul> <p> 436 * <p> 437 * @warning Explicitly adding, removing or replacing children of an 438 * {@link ASTNode} object may change the 439 * structure of the mathematical formula it represents, and may even render 440 * the representation invalid. Callers need to be careful to use this method 441 * in the context of other operations to create complete and correct 442 * formulas. The method 443 * {@link ASTNode#isWellFormedASTNode()} 444 * may also be useful for checking the results of node modifications. 445 <p> 446 * @see #prependChild(ASTNode disownedChild) 447 * @see #replaceChild(long n, ASTNode disownedChild, boolean delreplaced) 448 * @see #insertChild(long n, ASTNode disownedChild) 449 * @see #removeChild(long n) 450 * @see #isWellFormedASTNode() 451 */ public 452 int addChild(ASTNode disownedChild) { 453 return libsbmlJNI.ASTNode_addChild(swigCPtr, this, ASTNode.getCPtrAndDisown(disownedChild), disownedChild); 454 } 455 456 457/** 458 * Adds the given node as a child of this {@link ASTNode}. 459 <p> 460 * This method adds child nodes from right to left. 461 <p> 462 * @param disownedChild the {@link ASTNode} instance to add 463 <p> 464 * <p> 465 * @return integer value indicating success/failure of the 466 * function. The possible values 467 * returned by this function are: 468 * <ul> 469 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 470 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 471 * 472 * </ul> <p> 473 * <p> 474 * @warning Explicitly adding, removing or replacing children of an 475 * {@link ASTNode} object may change the 476 * structure of the mathematical formula it represents, and may even render 477 * the representation invalid. Callers need to be careful to use this method 478 * in the context of other operations to create complete and correct 479 * formulas. The method 480 * {@link ASTNode#isWellFormedASTNode()} 481 * may also be useful for checking the results of node modifications. 482 <p> 483 * @see #addChild(ASTNode disownedChild) 484 * @see #replaceChild(long n, ASTNode disownedChild, boolean delreplaced) 485 * @see #insertChild(long n, ASTNode disownedChild) 486 * @see #removeChild(long n) 487 */ public 488 int prependChild(ASTNode disownedChild) { 489 return libsbmlJNI.ASTNode_prependChild(swigCPtr, this, ASTNode.getCPtrAndDisown(disownedChild), disownedChild); 490 } 491 492 493/** 494 * Removes the nth child of this {@link ASTNode} object. 495 <p> 496 * @param n long the index of the child to remove 497 <p> 498 * <p> 499 * @return integer value indicating success/failure of the 500 * function. The possible values 501 * returned by this function are: 502 * <ul> 503 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 504 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} 505 * 506 * </ul> <p> 507 * <p> 508 * @warning Explicitly adding, removing or replacing children of an 509 * {@link ASTNode} object may change the 510 * structure of the mathematical formula it represents, and may even render 511 * the representation invalid. Callers need to be careful to use this method 512 * in the context of other operations to create complete and correct 513 * formulas. The method 514 * {@link ASTNode#isWellFormedASTNode()} 515 * may also be useful for checking the results of node modifications. 516 <p> 517 * @see #addChild(ASTNode disownedChild) 518 * @see #prependChild(ASTNode disownedChild) 519 * @see #replaceChild(long n, ASTNode disownedChild, boolean delreplaced) 520 * @see #insertChild(long n, ASTNode disownedChild) 521 */ public 522 int removeChild(long n) { 523 return libsbmlJNI.ASTNode_removeChild(swigCPtr, this, n); 524 } 525 526 527/** 528 * Replaces the nth child of this {@link ASTNode} with the given {@link ASTNode}. 529 <p> 530 * @param n long the index of the child to replace 531 * @param disownedChild {@link ASTNode} to replace the nth child 532 * @param delreplaced boolean indicating whether to delete the replaced child. 533 <p> 534 * <p> 535 * @return integer value indicating success/failure of the 536 * function. The possible values 537 * returned by this function are: 538 * <ul> 539 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 540 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} 541 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 542 * 543 * </ul> <p> 544 * <p> 545 * @warning Explicitly adding, removing or replacing children of an 546 * {@link ASTNode} object may change the 547 * structure of the mathematical formula it represents, and may even render 548 * the representation invalid. Callers need to be careful to use this method 549 * in the context of other operations to create complete and correct 550 * formulas. The method 551 * {@link ASTNode#isWellFormedASTNode()} 552 * may also be useful for checking the results of node modifications. 553 <p> 554 * @see #addChild(ASTNode disownedChild) 555 * @see #prependChild(ASTNode disownedChild) 556 * @see #insertChild(long n, ASTNode disownedChild) 557 * @see #removeChild(long n) 558 */ public 559 int replaceChild(long n, ASTNode disownedChild, boolean delreplaced) { 560 return libsbmlJNI.ASTNode_replaceChild__SWIG_0(swigCPtr, this, n, ASTNode.getCPtrAndDisown(disownedChild), disownedChild, delreplaced); 561 } 562 563 564/** 565 * Replaces the nth child of this {@link ASTNode} with the given {@link ASTNode}. 566 <p> 567 * @param n long the index of the child to replace 568 * @param disownedChild {@link ASTNode} to replace the nth child 569 * @param delreplaced boolean indicating whether to delete the replaced child. 570 <p> 571 * <p> 572 * @return integer value indicating success/failure of the 573 * function. The possible values 574 * returned by this function are: 575 * <ul> 576 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 577 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} 578 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 579 * 580 * </ul> <p> 581 * <p> 582 * @warning Explicitly adding, removing or replacing children of an 583 * {@link ASTNode} object may change the 584 * structure of the mathematical formula it represents, and may even render 585 * the representation invalid. Callers need to be careful to use this method 586 * in the context of other operations to create complete and correct 587 * formulas. The method 588 * {@link ASTNode#isWellFormedASTNode()} 589 * may also be useful for checking the results of node modifications. 590 <p> 591 * @see #addChild(ASTNode disownedChild) 592 * @see #prependChild(ASTNode disownedChild) 593 * @see #insertChild(long n, ASTNode disownedChild) 594 * @see #removeChild(long n) 595 */ public 596 int replaceChild(long n, ASTNode disownedChild) { 597 return libsbmlJNI.ASTNode_replaceChild__SWIG_1(swigCPtr, this, n, ASTNode.getCPtrAndDisown(disownedChild), disownedChild); 598 } 599 600 601/** 602 * Inserts the given {@link ASTNode} node at a given point in the current {@link ASTNode}'s 603 * list of children. 604 <p> 605 * @param n long the index of the {@link ASTNode} being added 606 * @param disownedChild {@link ASTNode} to insert as the nth child 607 <p> 608 * <p> 609 * @return integer value indicating success/failure of the 610 * function. The possible values 611 * returned by this function are: 612 * <ul> 613 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 614 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE} 615 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 616 * 617 * </ul> <p> 618 * <p> 619 * @warning Explicitly adding, removing or replacing children of an 620 * {@link ASTNode} object may change the 621 * structure of the mathematical formula it represents, and may even render 622 * the representation invalid. Callers need to be careful to use this method 623 * in the context of other operations to create complete and correct 624 * formulas. The method 625 * {@link ASTNode#isWellFormedASTNode()} 626 * may also be useful for checking the results of node modifications. 627 <p> 628 * @see #addChild(ASTNode disownedChild) 629 * @see #prependChild(ASTNode disownedChild) 630 * @see #replaceChild(long n, ASTNode disownedChild, boolean delreplaced) 631 * @see #removeChild(long n) 632 */ public 633 int insertChild(long n, ASTNode disownedChild) { 634 return libsbmlJNI.ASTNode_insertChild(swigCPtr, this, n, ASTNode.getCPtrAndDisown(disownedChild), disownedChild); 635 } 636 637 638/** 639 * Creates a recursive copy of this node and all its children. 640 <p> 641 * @return a copy of this {@link ASTNode} and all its children. The caller owns 642 * the returned {@link ASTNode} and is responsible for deleting it. 643 */ public 644 ASTBase deepCopy() { 645 long cPtr = libsbmlJNI.ASTNode_deepCopy(swigCPtr, this); 646 return (cPtr == 0) ? null : new ASTNode(cPtr, true); 647 } 648 649 650/** 651 * Returns the child at index n of this node. 652 <p> 653 * @param n the index of the child to get 654 <p> 655 * @return the nth child of this {@link ASTNode} or <code>null</code> if this node has no nth 656 * child (<code>n > </code> 657 * {@link ASTNode#getNumChildren()} 658 * <code>- 1</code>). 659 <p> 660 * @see #getNumChildren() 661 * @see #getLeftChild() 662 * @see #getRightChild() 663 */ public 664 ASTNode getChild(long n) { 665 long cPtr = libsbmlJNI.ASTNode_getChild(swigCPtr, this, n); 666 return (cPtr == 0) ? null : new ASTNode(cPtr, false); 667 } 668 669 670/** 671 * Returns the left child of this node. 672 <p> 673 * @return the left child of this {@link ASTNode}. This is equivalent to calling 674 * {@link ASTNode#getChild(long)} 675 * with an argument of <code>0.</code> 676 <p> 677 * @see #getNumChildren() 678 * @see #getChild(long) 679 * @see #getRightChild() 680 */ public 681 ASTNode getLeftChild() { 682 long cPtr = libsbmlJNI.ASTNode_getLeftChild(swigCPtr, this); 683 return (cPtr == 0) ? null : new ASTNode(cPtr, false); 684 } 685 686 687/** 688 * Returns the right child of this node. 689 <p> 690 * @return the right child of this {@link ASTNode}, or <code>null</code> if this node has no 691 * right child. If 692 * {@link ASTNode#getNumChildren()} 693 * <code>> 1</code>, then this is equivalent to: 694 * <pre class='fragment'> 695getChild( getNumChildren() - 1 ); 696</pre> 697 <p> 698 * @see #getNumChildren() 699 * @see #getLeftChild() 700 * @see #getChild(long) 701 */ public 702 ASTNode getRightChild() { 703 long cPtr = libsbmlJNI.ASTNode_getRightChild(swigCPtr, this); 704 return (cPtr == 0) ? null : new ASTNode(cPtr, false); 705 } 706 707 708/** 709 * Returns the number of children of this node. 710 <p> 711 * @return the number of children of this {@link ASTNode}, or 0 is this node has 712 * no children. 713 */ public 714 long getNumChildren() { 715 return libsbmlJNI.ASTNode_getNumChildren(swigCPtr, this); 716 } 717 718 719/** 720 * Adds the given {@link XMLNode} as a MathML <code><semantics></code> 721 * element to this {@link ASTNode}. 722 <p> 723 * <p> 724 * The <code><semantics></code> element is a MathML 2.0 construct 725 * that can be used to associate additional information with a MathML 726 * construct. The construct can be used to decorate a MathML expressions with 727 * a sequence of one or more <code><annotation></code> or 728 * <code><annotation-xml></code> elements. Each such element contains a 729 * pair of items; the first is a symbol that acts as an attribute or key, and 730 * the second is the value associated with the attribute or key. Please refer 731 * to the MathML 2.0 documentation, particularly the <a target='_blank' 732 * href='http://www.w3.org/TR/2007/WD-MathML3-20071005/chapter5.html#mixing.semantic.annotations'>Section 733 * 5.2, Semantic Annotations</a> for more information about these constructs. 734 <p> 735 * @param disownedAnnotation the annotation to add. 736 <p> 737 * <p> 738 * @return integer value indicating success/failure of the 739 * function. The possible values 740 * returned by this function are: 741 * <ul> 742 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 743 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 744 * 745 * </ul> <p> 746 * <p> 747 * @note Although SBML permits the use of the MathML 748 * <code><semantics></code> annotation construct, the truth is that 749 * this construct has so far (at this time of this writing, which is early 750 * 2014) seen very little use in SBML software. The full implications of 751 * using these annotations are still poorly understood. If you wish to 752 * use this construct, we urge you to discuss possible uses and applications 753 * on the SBML discussion lists, particularly <a target='_blank' 754 * href='http://sbml.org/Forums'>sbml-discuss</a> and/or <a target='_blank' 755 * href='http://sbml.org/Forums'>sbml-interoperability</a>. 756 <p> 757 * @see ASTNode#getNumSemanticsAnnotations() 758 * @see ASTNode#getSemanticsAnnotation(long) 759 */ public 760 int addSemanticsAnnotation(XMLNode disownedAnnotation) { 761 return libsbmlJNI.ASTNode_addSemanticsAnnotation(swigCPtr, this, XMLNode.getCPtrAndDisown(disownedAnnotation), disownedAnnotation); 762 } 763 764 765/** 766 * Returns the number of MathML <code><semantics></code> element 767 * elements on this node. 768 <p> 769 * <p> 770 * The <code><semantics></code> element is a MathML 2.0 construct 771 * that can be used to associate additional information with a MathML 772 * construct. The construct can be used to decorate a MathML expressions with 773 * a sequence of one or more <code><annotation></code> or 774 * <code><annotation-xml></code> elements. Each such element contains a 775 * pair of items; the first is a symbol that acts as an attribute or key, and 776 * the second is the value associated with the attribute or key. Please refer 777 * to the MathML 2.0 documentation, particularly the <a target='_blank' 778 * href='http://www.w3.org/TR/2007/WD-MathML3-20071005/chapter5.html#mixing.semantic.annotations'>Section 779 * 5.2, Semantic Annotations</a> for more information about these constructs. 780 <p> 781 * @return the number of annotations of this {@link ASTNode}. 782 <p> 783 * <p> 784 * @note Although SBML permits the use of the MathML 785 * <code><semantics></code> annotation construct, the truth is that 786 * this construct has so far (at this time of this writing, which is early 787 * 2014) seen very little use in SBML software. The full implications of 788 * using these annotations are still poorly understood. If you wish to 789 * use this construct, we urge you to discuss possible uses and applications 790 * on the SBML discussion lists, particularly <a target='_blank' 791 * href='http://sbml.org/Forums'>sbml-discuss</a> and/or <a target='_blank' 792 * href='http://sbml.org/Forums'>sbml-interoperability</a>. 793 <p> 794 * @see ASTNode#addSemanticsAnnotation(XMLNode) 795 * @see ASTNode#getSemanticsAnnotation(long) 796 */ public 797 long getNumSemanticsAnnotations() { 798 return libsbmlJNI.ASTNode_getNumSemanticsAnnotations(swigCPtr, this); 799 } 800 801 802/** 803 * Returns the nth MathML <code><semantics></code> element on this 804 * {@link ASTNode}. 805 <p> 806 * <p> 807 * The <code><semantics></code> element is a MathML 2.0 construct 808 * that can be used to associate additional information with a MathML 809 * construct. The construct can be used to decorate a MathML expressions with 810 * a sequence of one or more <code><annotation></code> or 811 * <code><annotation-xml></code> elements. Each such element contains a 812 * pair of items; the first is a symbol that acts as an attribute or key, and 813 * the second is the value associated with the attribute or key. Please refer 814 * to the MathML 2.0 documentation, particularly the <a target='_blank' 815 * href='http://www.w3.org/TR/2007/WD-MathML3-20071005/chapter5.html#mixing.semantic.annotations'>Section 816 * 5.2, Semantic Annotations</a> for more information about these constructs. 817 <p> 818 * @param n the index of the annotation to return. Callers should 819 * use {@link ASTNode#getNumSemanticsAnnotations()} to first find out how 820 * many annotations there are. 821 <p> 822 * @return the nth annotation inside this {@link ASTNode}, or <code>null</code> if this node has 823 * no nth annotation (<code>n ></code> 824 * {@link ASTNode#getNumSemanticsAnnotations()} 825 * <code>- 1</code>). 826 <p> 827 * <p> 828 * @note Although SBML permits the use of the MathML 829 * <code><semantics></code> annotation construct, the truth is that 830 * this construct has so far (at this time of this writing, which is early 831 * 2014) seen very little use in SBML software. The full implications of 832 * using these annotations are still poorly understood. If you wish to 833 * use this construct, we urge you to discuss possible uses and applications 834 * on the SBML discussion lists, particularly <a target='_blank' 835 * href='http://sbml.org/Forums'>sbml-discuss</a> and/or <a target='_blank' 836 * href='http://sbml.org/Forums'>sbml-interoperability</a>. 837 <p> 838 * @see ASTNode#addSemanticsAnnotation(XMLNode) 839 * @see ASTNode#getNumSemanticsAnnotations() 840 */ public 841 XMLNode getSemanticsAnnotation(long n) { 842 long cPtr = libsbmlJNI.ASTNode_getSemanticsAnnotation(swigCPtr, this, n); 843 return (cPtr == 0) ? null : new XMLNode(cPtr, false); 844 } 845 846 847/** 848 * Returns the value of this node as a single character. 849 <p> 850 * This function should be called only when {@link ASTNode#getType()} returns 851 * {@link libsbmlConstants#AST_MINUS AST_MINUS}, {@link libsbmlConstants#AST_TIMES AST_TIMES}, {@link libsbmlConstants#AST_DIVIDE AST_DIVIDE} or 852 * {@link libsbmlConstants#AST_POWER AST_POWER}. 853 <p> 854 * @return the value of this {@link ASTNode} as a single character 855 */ public 856 char getCharacter() { 857 return libsbmlJNI.ASTNode_getCharacter(swigCPtr, this); 858 } 859 860 861/** 862 * Returns the MathML <code>id</code> attribute value of this {@link ASTNode}. 863 <p> 864 * @return the MathML id of this {@link ASTNode}. 865 <p> 866 * @see #isSetId() 867 * @see #setId(String id) 868 * @see #unsetId() 869 */ public 870 String getId() { 871 return libsbmlJNI.ASTNode_getId(swigCPtr, this); 872 } 873 874 875/** 876 * Returns the MathML <code>class</code> attribute value of this {@link ASTNode}. 877 <p> 878 * @return the MathML class of this {@link ASTNode}, if any exists. 879 <p> 880 * @see #isSetClass() 881 * @see #setClassName(String id) 882 * @see #unsetClass() 883 */ public 884 String getClassName() { 885 return libsbmlJNI.ASTNode_getClassName(swigCPtr, this); 886 } 887 888 889/** 890 * Returns the MathML <code>style</code> attribute value of this {@link ASTNode}. 891 <p> 892 * @return the MathML style of this {@link ASTNode}, if any exists. 893 <p> 894 * @see #isSetStyle() 895 * @see #setStyle(String id) 896 * @see #unsetStyle() 897 */ public 898 String getStyle() { 899 return libsbmlJNI.ASTNode_getStyle(swigCPtr, this); 900 } 901 902 903/** 904 * Returns the value of this node as an integer. 905 <p> 906 * If this node type is {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}, this 907 * method returns the value of the numerator. 908 <p> 909 * @return the value of this {@link ASTNode} as a (<code>long</code>) integer. 910 <p> 911 * @note This function should be called only when 912 * {@link ASTNode#getType()} returns 913 * {@link libsbmlConstants#AST_INTEGER AST_INTEGER} or 914 * {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}. 915 * It will return <code>0</code> if the node type is <em>not</em> one of these, but since 916 * <code>0</code> may be a valid value for integer, it is important to be sure that 917 * the node type is one of the expected types in order to understand if 918 * <code>0</code> is the actual value. 919 */ public 920 int getInteger() { 921 return libsbmlJNI.ASTNode_getInteger(swigCPtr, this); 922 } 923 924 925/** 926 * Returns the value of this node as a string. 927 <p> 928 * This function may be called on nodes that (1) are not operators, i.e., 929 * nodes for which {@link ASTNode#isOperator()} 930 * returns <code>false</code>, and (2) are not numbers, i.e., 931 * {@link ASTNode#isNumber()} returns <code>false.</code> 932 <p> 933 * @return the value of this {@link ASTNode} as a string, or <code>null</code> if it is 934 * a node that does not have a name equivalent (e.g., if it is a number). 935 */ public 936 String getName() { 937 return libsbmlJNI.ASTNode_getName(swigCPtr, this); 938 } 939 940 941/** 942 * Returns the value of this operator node as a string. 943 <p> 944 * This function may be called on nodes that are operators, i.e., nodes for 945 * which {@link ASTNode#isOperator()} returns 946 * <code>true.</code> 947 <p> 948 * @return the name of this operator {@link ASTNode} as a string (or <code>null</code> if not 949 * an operator). 950 */ public 951 String getOperatorName() { 952 return libsbmlJNI.ASTNode_getOperatorName(swigCPtr, this); 953 } 954 955 956/** 957 * Returns the value of the numerator of this node. 958 <p> 959 * This function should be called only when 960 * {@link ASTNode#getType()} returns 961 * {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL} or 962 * {@link libsbmlConstants#AST_INTEGER AST_INTEGER}. 963 <p> 964 * @return the value of the numerator of this {@link ASTNode}. 965 */ public 966 int getNumerator() { 967 return libsbmlJNI.ASTNode_getNumerator(swigCPtr, this); 968 } 969 970 971/** 972 * Returns the value of the denominator of this node. 973 <p> 974 * @return the value of the denominator of this {@link ASTNode}, or <code>1</code> if 975 * this node has no numerical value. 976 <p> 977 * @note This function should be called only when 978 * {@link ASTNode#getType()} returns 979 * {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}. 980 * It will return <code>1</code> if the node type is another type, but since <code>1</code> may 981 * be a valid value for the denominator of a rational number, it is 982 * important to be sure that the node type is the correct type in order to 983 * correctly interpret the returned value. 984 */ public 985 int getDenominator() { 986 return libsbmlJNI.ASTNode_getDenominator(swigCPtr, this); 987 } 988 989 990/** 991 * Returns the real-numbered value of this node. 992 <p> 993 * This function performs the necessary arithmetic if the node type is 994 * {@link libsbmlConstants#AST_REAL_E AST_REAL_E} (<em>mantissa * 995 * 10<sup> exponent</sup></em>) or 996 * {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL} 997 * (<em>numerator / denominator</em>). 998 <p> 999 * @return the value of this {@link ASTNode} as a real (double), or <code>0</code> 1000 * if this is not a node that holds a number. 1001 <p> 1002 * @note This function should be called only when this {@link ASTNode} has a 1003 * numerical value type. It will return <code>0</code> if the node type is another 1004 * type, but since <code>0</code> may be a valid value, it is important to be sure 1005 * that the node type is the correct type in order to correctly interpret 1006 * the returned value. 1007 */ public 1008 double getReal() { 1009 return libsbmlJNI.ASTNode_getReal(swigCPtr, this); 1010 } 1011 1012 1013/** 1014 * Returns the mantissa value of this node. 1015 <p> 1016 * If {@link ASTNode#getType()} returns 1017 * {@link libsbmlConstants#AST_REAL AST_REAL}, this method is 1018 * identical to {@link ASTNode#getReal()}. 1019 <p> 1020 * @return the value of the mantissa of this {@link ASTNode}, or <code>0</code> if this 1021 * node is not a type that has a real-numbered value. 1022 <p> 1023 * @note This function should be called only when 1024 * {@link ASTNode#getType()} returns 1025 * {@link libsbmlConstants#AST_REAL_E AST_REAL_E}, 1026 * {@link libsbmlConstants#AST_REAL AST_REAL} or 1027 * {@link libsbmlConstants#AST_NAME_AVOGADRO AST_NAME_AVOGADRO}. It 1028 * will return <code>0</code> if the node type is another type, but since <code>0</code> may be 1029 * a valid value, it is important to be sure that the node type is the 1030 * correct type in order to correctly interpret the returned value. 1031 */ public 1032 double getMantissa() { 1033 return libsbmlJNI.ASTNode_getMantissa(swigCPtr, this); 1034 } 1035 1036 1037/** 1038 * Returns the exponent value of this {@link ASTNode}. 1039 <p> 1040 * @return the value of the exponent of this {@link ASTNode}, or <code>0</code> if this 1041 * is not a type of node that has an exponent. 1042 <p> 1043 * @note This function should be called only when 1044 * {@link ASTNode#getType()} 1045 * returns {@link libsbmlConstants#AST_REAL_E AST_REAL_E}. 1046 * It will return <code>0</code> if the node type is another type, but since <code>0</code> may 1047 * be a valid value, it is important to be sure that the node type is the 1048 * correct type in order to correctly interpret the returned value. 1049 */ public 1050 int getExponent() { 1051 return libsbmlJNI.ASTNode_getExponent(swigCPtr, this); 1052 } 1053 1054 1055/** 1056 * Returns the numerical value of this {@link ASTNode}. 1057 <p> 1058 * @return the numerical value of this {@link ASTNode}, or <code>NaN</code> if this 1059 * is not a type of node that has a numerical value. 1060 <p> 1061 * @note This function will return a numerical value (as a double) for 1062 * any ASTNode_t that represents a number, a constant such as 1063 * {@link libsbmlConstants#AST_CONSTANT_PI AST_CONSTANT_PI}, 1064 * {@link libsbmlConstants#AST_CONSTANT_E AST_CONSTANT_E}, or 1065 * {@link libsbmlConstants#AST_NAME_AVOGADRO AST_NAME_AVOGADRO}, or 1066 * <code>1</code> for nodes of type 1067 * {@link libsbmlConstants#AST_CONSTANT_TRUE AST_CONSTANT_TRUE} and <code>0</code> for nodes of type 1068 * {@link libsbmlConstants#AST_CONSTANT_FALSE AST_CONSTANT_FALSE}. It does not evaluate 1069 * the node in any way so, for example, it will not return the value of 1070 * a named ASTNode_t or attempt to evaluate a function. 1071 * This includes a node representing <code>time</code> i.e. nodes 1072 * of type {@link libsbmlConstants#AST_NAME_TIME AST_NAME_TIME}. 1073 */ public 1074 double getValue() { 1075 return libsbmlJNI.ASTNode_getValue(swigCPtr, this); 1076 } 1077 1078 1079/** 1080 * Returns the precedence of this node in the infix math syntax of SBML 1081 * Level 1. 1082 <p> 1083 * For more information about the infix syntax, see the discussion about <a 1084 * href='#math-convert'>text string formulas</a> at the top of the 1085 * documentation for {@link ASTNode}. 1086 <p> 1087 * @return an integer indicating the precedence of this {@link ASTNode} 1088 */ public 1089 int getPrecedence() { 1090 return libsbmlJNI.ASTNode_getPrecedence(swigCPtr, this); 1091 } 1092 1093 1094/** 1095 * Returns the type of this {@link ASTNode}. 1096 <p> 1097 * The value returned is one of the Core AST type codes such as 1098 * {@link libsbmlConstants#AST_LAMBDA AST_LAMBDA}, 1099 * {@link libsbmlConstants#AST_PLUS AST_PLUS}, etc. 1100 <p> 1101 * @return the type of this {@link ASTNode}. 1102 <p> 1103 * @note The introduction of extensibility in SBML Level 3 brings with 1104 * it a need to allow for the possibility of node types that are defined by 1105 * plug-ins implementing SBML Level 3 packages. If a given {@link ASTNode} is 1106 * a construct created by a package rather than libSBML Core, then 1107 * getType() will return 1108 * {@link libsbmlConstants#AST_ORIGINATES_IN_PACKAGE AST_ORIGINATES_IN_PACKAGE}. 1109 * Callers can then obtain the package-specific type by 1110 * calling getExtendedType(). 1111 <p> 1112 * @see #getExtendedType() 1113 */ public 1114 int getType() { 1115 return libsbmlJNI.ASTNode_getType(swigCPtr, this); 1116 } 1117 1118 1119/** 1120 * Returns the extended type of this {@link ASTNode}. 1121 <p> 1122 * The type may be either a core 1123 * integer type code 1124 * or a value of a type code defined by an SBML Level 3 package. 1125 <p> 1126 * @return the type of this {@link ASTNode}. 1127 <p> 1128 * @note When the {@link ASTNode} is of a type from a package, the value returned 1129 * by {@link ASTNode#getType()} will be 1130 * {@link libsbmlConstants#AST_ORIGINATES_IN_PACKAGE AST_ORIGINATES_IN_PACKAGE} 1131 * and getExtendedType() will return a package-specific type 1132 * code. To find out the possible package-specific types (if any), please 1133 * consult the documentation for the particular package. 1134 <p> 1135 * @see #getType() 1136 */ public 1137 int getExtendedType() { 1138 return libsbmlJNI.ASTNode_getExtendedType(swigCPtr, this); 1139 } 1140 1141 1142/** 1143 * Returns the units of this {@link ASTNode}. 1144 <p> 1145 * SBML Level 3 Version 1 introduced the ability to include an 1146attribute <code>sbml:units</code> on MathML <code>cn</code> elements 1147appearing in SBML mathematical formulas. The value of this attribute can 1148be used to indicate the unit of measurement to be associated with the 1149number in the content of the <code>cn</code> element. The value of this 1150attribute must be the identifier of a unit of measurement defined by SBML 1151or the enclosing Model. Here, the <code>sbml</code> portion is an XML 1152namespace prefix that must be associated with the SBML namespace for SBML 1153Level 3. The following example illustrates how this attribute can be 1154used to define a number with value <code>10</code> and unit of measurement 1155<code>second</code>: 1156<pre class="fragment"><math xmlns="http://www.w3.org/1998/Math/MathML" 1157 xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"> 1158 <cn type="integer" sbml:units="second"> 10 </cn> 1159</math> 1160</pre> 1161 1162 <p> 1163 * @return the units of this {@link ASTNode}. 1164 <p> 1165 * @note The <code>sbml:units</code> attribute is only available in SBML 1166 * Level 3. It may not be used in Levels 1–2 of SBML. 1167 <p> 1168 * @see <a href='libsbml.html#parseL3Formula(java.lang.String)'><code>libsbml.parseL3Formula(String)</code></a> 1169 */ public 1170 String getUnits() { 1171 return libsbmlJNI.ASTNode_getUnits(swigCPtr, this); 1172 } 1173 1174 1175/** 1176 * Returns <code>true</code> if this node represents the predefined 1177 * value for Avogadro's constant. 1178 <p> 1179 * SBML Level 3 introduced a predefined MathML <code><csymbol></code> 1180 * for the value of Avogadro's constant. LibSBML stores this internally as 1181 * a node of type {@link libsbmlConstants#AST_NAME_AVOGADRO AST_NAME_AVOGADRO}. 1182 * This method returns <code>true</code> if this node has that type. 1183 <p> 1184 * @return <code>true</code> if this {@link ASTNode} is the special symbol avogadro, 1185 * <code>false</code> otherwise. 1186 <p> 1187 * @see <a href='libsbml.html#parseL3Formula(java.lang.String)'><code>libsbml.parseL3Formula(String)</code></a> 1188 */ public 1189 boolean isAvogadro() { 1190 return libsbmlJNI.ASTNode_isAvogadro(swigCPtr, this); 1191 } 1192 1193 1194/** 1195 * Returns <code>true</code> if this node has a Boolean type. 1196 <p> 1197 * The {@link ASTNode} objects that have Boolean types are the logical operators, 1198 * relational operators, and the constants <code>true</code> or <code>false.</code> 1199 <p> 1200 * @return <code>true</code> if this {@link ASTNode} has a Boolean type, <code>false</code> otherwise. 1201 */ public 1202 boolean isBoolean() { 1203 return libsbmlJNI.ASTNode_isBoolean(swigCPtr, this); 1204 } 1205 1206 1207/** 1208 * Returns <code>true</code> if this node returns a Boolean value. 1209 <p> 1210 * This function looks at the whole {@link ASTNode} rather than just the top level 1211 * of the {@link ASTNode}. Thus, it will consider return values from piecewise 1212 * statements. In addition, if this {@link ASTNode} uses a function call to a 1213 * user-defined function, the return value of the corresponding 1214 * {@link FunctionDefinition} object will be determined. Note that this is only 1215 * possible where the {@link ASTNode} can trace its parent {@link Model}; that is, the 1216 * {@link ASTNode} must represent the <code><math></code> element of some 1217 * SBML object that has already been added to an instance of an 1218 * {@link SBMLDocument}. 1219 <p> 1220 * @param model the {@link Model} to use as context 1221 <p> 1222 * 1223 * @return true if this {@link ASTNode} returns a boolean, <code>false</code> otherwise. 1224 <p> 1225 * @see #isBoolean() 1226 */ public 1227 boolean returnsBoolean(Model model) { 1228 return libsbmlJNI.ASTNode_returnsBoolean__SWIG_0(swigCPtr, this, Model.getCPtr(model), model); 1229 } 1230 1231 1232/** 1233 * Returns <code>true</code> if this node returns a Boolean value. 1234 <p> 1235 * This function looks at the whole {@link ASTNode} rather than just the top level 1236 * of the {@link ASTNode}. Thus, it will consider return values from piecewise 1237 * statements. In addition, if this {@link ASTNode} uses a function call to a 1238 * user-defined function, the return value of the corresponding 1239 * {@link FunctionDefinition} object will be determined. Note that this is only 1240 * possible where the {@link ASTNode} can trace its parent {@link Model}; that is, the 1241 * {@link ASTNode} must represent the <code><math></code> element of some 1242 * SBML object that has already been added to an instance of an 1243 * {@link SBMLDocument}. 1244 <p> 1245 * @param model the {@link Model} to use as context 1246 <p> 1247 * 1248 * @return true if this {@link ASTNode} returns a boolean, <code>false</code> otherwise. 1249 <p> 1250 * @see #isBoolean() 1251 */ public 1252 boolean returnsBoolean() { 1253 return libsbmlJNI.ASTNode_returnsBoolean__SWIG_1(swigCPtr, this); 1254 } 1255 1256 1257/** 1258 * Returns <code>true</code> if this node represents a MathML 1259 * constant. 1260 <p> 1261 * Examples of MathML constants include such things as pi. 1262 <p> 1263 * @return <code>true</code> if this {@link ASTNode} is a MathML constant, <code>false</code> 1264 * otherwise. 1265 <p> 1266 * @note This function will also return <code>true</code> for nodes of type 1267 * {@link libsbmlConstants#AST_NAME_AVOGADRO AST_NAME_AVOGADRO} in SBML Level 3. 1268 */ public 1269 boolean isConstant() { 1270 return libsbmlJNI.ASTNode_isConstant(swigCPtr, this); 1271 } 1272 1273 1274/** 1275 * Returns <code>true</code> if this node represents a function. 1276 <p> 1277 * The three types of functions in SBML are MathML functions (e.g., 1278 * <code>abs()</code>), SBML Level 1 functions (in the SBML 1279 * Level 1 math syntax), and user-defined functions (using 1280 * {@link FunctionDefinition} in SBML Level 2 and 3). 1281 <p> 1282 * @return <code>true</code> if this {@link ASTNode} is a function, <code>false</code> otherwise. 1283 */ public 1284 boolean isFunction() { 1285 return libsbmlJNI.ASTNode_isFunction(swigCPtr, this); 1286 } 1287 1288 1289/** 1290 * Returns <code>true</code> if this node represents the special IEEE 754 1291 * value for infinity. 1292 <p> 1293 * @return <code>true</code> if this {@link ASTNode} is the special IEEE 754 value infinity, 1294 * <code>false</code> otherwise. 1295 */ public 1296 boolean isInfinity() { 1297 return libsbmlJNI.ASTNode_isInfinity(swigCPtr, this); 1298 } 1299 1300 1301/** 1302 * Returns <code>true</code> if this node contains an integer value. 1303 <p> 1304 * @return <code>true</code> if this {@link ASTNode} is of type {@link libsbmlConstants#AST_INTEGER AST_INTEGER}, <code>false</code> otherwise. 1305 */ public 1306 boolean isInteger() { 1307 return libsbmlJNI.ASTNode_isInteger(swigCPtr, this); 1308 } 1309 1310 1311/** 1312 * Returns <code>true</code> if this node is a MathML 1313 * <code><lambda></code>. 1314 <p> 1315 * @return <code>true</code> if this {@link ASTNode} is of type {@link libsbmlConstants#AST_LAMBDA AST_LAMBDA}, <code>false</code> otherwise. 1316 */ public 1317 boolean isLambda() { 1318 return libsbmlJNI.ASTNode_isLambda(swigCPtr, this); 1319 } 1320 1321 1322/** 1323 * Returns <code>true</code> if this node represents a <code>log10</code> function. 1324 <p> 1325 * More precisely, this predicate returns <code>true</code> if the node type is 1326 * {@link libsbmlConstants#AST_FUNCTION_LOG AST_FUNCTION_LOG} with two children, the 1327 * first of which is an {@link libsbmlConstants#AST_INTEGER AST_INTEGER} equal to 1328 * 10. 1329 <p> 1330 * @return <code>true</code> if the given {@link ASTNode} represents a <code>log10</code>() function, 1331 * <code>false</code> otherwise. 1332 <p> 1333 * @see <a href='libsbml.html#parseL3Formula(java.lang.String)'><code>libsbml.parseL3Formula(String)</code></a> 1334 */ public 1335 boolean isLog10() { 1336 return libsbmlJNI.ASTNode_isLog10(swigCPtr, this); 1337 } 1338 1339 1340/** 1341 * Returns <code>true</code> if this node is a MathML logical operator. 1342 <p> 1343 * The possible MathML logical operators are <code>and</code>, <code>or</code>, <code>not</code>, and 1344 * <code>xor.</code> 1345 <p> 1346 * @return <code>true</code> if this {@link ASTNode} is a MathML logical operator, <code>false</code> 1347 * otherwise. 1348 */ public 1349 boolean isLogical() { 1350 return libsbmlJNI.ASTNode_isLogical(swigCPtr, this); 1351 } 1352 1353 1354/** 1355 * Returns <code>true</code> if this node is a user-defined variable name 1356 * or the symbols for time or Avogadro's constant. 1357 <p> 1358 * SBML Levels 2 and 3 provides <code><csymbol></code> 1359 * definitions for 'time' and 'avogadro', which can be used to represent 1360 * simulation time and Avogadro's constant in MathML. Note that this 1361 * method does <em>not</em> return <code>true</code> for the other <code>csymbol</code> 1362 * values defined by SBML, 'delay', because the 'delay' is a function 1363 * and not a constant or variable. 1364 <p> 1365 * @return <code>true</code> if this {@link ASTNode} is a user-defined variable name in SBML 1366 * or the special symbols for time or Avogadro's constant. It returns 1367 * <code>false</code> otherwise. 1368 */ public 1369 boolean isName() { 1370 return libsbmlJNI.ASTNode_isName(swigCPtr, this); 1371 } 1372 1373 1374/** 1375 * Returns <code>true</code> if this node represents the special IEEE 754 1376 * value 'not a number' (NaN). 1377 <p> 1378 * @return <code>true</code> if this {@link ASTNode} is the special IEEE 754 NaN, <code>false</code> 1379 * otherwise. 1380 */ public 1381 boolean isNaN() { 1382 return libsbmlJNI.ASTNode_isNaN(swigCPtr, this); 1383 } 1384 1385 1386/** 1387 * Returns <code>true</code> if this node represents the special IEEE 754 1388 * value 'negative infinity'. 1389 <p> 1390 * @return <code>true</code> if this {@link ASTNode} is the special IEEE 754 value negative 1391 * infinity, <code>false</code> otherwise. 1392 */ public 1393 boolean isNegInfinity() { 1394 return libsbmlJNI.ASTNode_isNegInfinity(swigCPtr, this); 1395 } 1396 1397 1398/** 1399 * Returns <code>true</code> if this node contains a number. 1400 <p> 1401 * @return <code>true</code> if this {@link ASTNode} is a number, <code>false</code> otherwise. 1402 */ public 1403 boolean isNumber() { 1404 return libsbmlJNI.ASTNode_isNumber(swigCPtr, this); 1405 } 1406 1407 1408/** 1409 * Returns <code>true</code> if this node is a mathematical 1410 * operator. 1411 <p> 1412 * The possible mathematical operators in the MathML syntax supported by 1413 * SBML are <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code> 1414 * and <code>^</code> (power). 1415 <p> 1416 * @return <code>true</code> if this {@link ASTNode} is an operator, <code>false</code> otherwise. 1417 */ public 1418 boolean isOperator() { 1419 return libsbmlJNI.ASTNode_isOperator(swigCPtr, this); 1420 } 1421 1422 1423/** 1424 * Returns <code>true</code> if this node is the MathML 1425 * <code><piecewise></code> construct. 1426 <p> 1427 * @return <code>true</code> if this {@link ASTNode} is a MathML <code>piecewise</code> function, 1428 * <code>false</code> otherwise. 1429 */ public 1430 boolean isPiecewise() { 1431 return libsbmlJNI.ASTNode_isPiecewise(swigCPtr, this); 1432 } 1433 1434 1435/** 1436 * Predicate returning <code>true</code> if this node is a MathML 1437 * qualifier. 1438 <p> 1439 * The MathML qualifier node types are <code>bvar</code>, <code>degree</code>, <code>base</code>, 1440 * <code>piece</code>, and <code>otherwise.</code> 1441 <p> 1442 * @return <code>true</code> if this {@link ASTNode} is a MathML qualifier, <code>false</code> 1443 * otherwise. 1444 */ public 1445 boolean isQualifier() { 1446 return libsbmlJNI.ASTNode_isQualifier(swigCPtr, this); 1447 } 1448 1449 1450/** 1451 * Returns <code>true</code> if this node represents a rational number. 1452 <p> 1453 * @return <code>true</code> if this {@link ASTNode} is of type {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}, <code>false</code> otherwise. 1454 */ public 1455 boolean isRational() { 1456 return libsbmlJNI.ASTNode_isRational(swigCPtr, this); 1457 } 1458 1459 1460/** 1461 * Returns <code>true</code> if this node can represent a real number. 1462 <p> 1463 * More precisely, this node must be of one of the following types: 1464 * {@link libsbmlConstants#AST_REAL AST_REAL}, {@link libsbmlConstants#AST_REAL_E AST_REAL_E} or {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}. 1465 <p> 1466 * @return <code>true</code> if the value of this {@link ASTNode} can represented as a real 1467 * number, <code>false</code> otherwise. 1468 */ public 1469 boolean isReal() { 1470 return libsbmlJNI.ASTNode_isReal(swigCPtr, this); 1471 } 1472 1473 1474/** 1475 * Returns <code>true</code> if this node is a MathML 1476 * relational operator. 1477 <p> 1478 * The MathML relational operators are <code>==</code>, <code>>=</code>, 1479 * <code>></code>, <code><</code>, and <code>!=</code>. 1480 <p> 1481 * @return <code>true</code> if this {@link ASTNode} is a MathML relational operator, 1482 * <code>false</code> otherwise. 1483 */ public 1484 boolean isRelational() { 1485 return libsbmlJNI.ASTNode_isRelational(swigCPtr, this); 1486 } 1487 1488 1489/** 1490 * Predicate returning <code>true</code> if this node is a MathML 1491 * semantics node. 1492 <p> 1493 * @return <code>true</code> if this {@link ASTNode} is a MathML semantics node, <code>false</code> 1494 * otherwise. 1495 */ public 1496 boolean isSemantics() { 1497 return libsbmlJNI.ASTNode_isSemantics(swigCPtr, this); 1498 } 1499 1500 1501/** 1502 * Returns <code>true</code> if this node represents a square root 1503 * function. 1504 <p> 1505 * More precisely, the node type must be {@link libsbmlConstants#AST_FUNCTION_ROOT AST_FUNCTION_ROOT} with two children, the first of which is an 1506 * {@link libsbmlConstants#AST_INTEGER AST_INTEGER} node having value equal to 2. 1507 <p> 1508 * @return <code>true</code> if the given {@link ASTNode} represents a <code>sqrt()</code> 1509 * function, <code>false</code> otherwise. 1510 */ public 1511 boolean isSqrt() { 1512 return libsbmlJNI.ASTNode_isSqrt(swigCPtr, this); 1513 } 1514 1515 1516/** 1517 * Returns <code>true</code> if this node is a unary minus operator. 1518 <p> 1519 * A node is defined as a unary minus node if it is of type 1520 * {@link libsbmlConstants#AST_MINUS AST_MINUS} and has exactly one child. 1521 <p> 1522 * For numbers, unary minus nodes can be 'collapsed' by negating the 1523 * number. In fact, <a href='libsbml.html#parseFormula(java.lang.String)'><code>libsbml.parseFormula(String)</code></a> does this during 1524 * its parsing process, and <a href='libsbml.html#parseL3Formula(java.lang.String)'><code>libsbml.parseL3Formula(String)</code></a> has a 1525 * configuration option that allows this behavior to be turned on or off. 1526 * However, unary minus nodes for symbols ({@link libsbmlConstants#AST_NAME AST_NAME}) cannot be 'collapsed', so this predicate function is 1527 * necessary. 1528 <p> 1529 * @return <code>true</code> if this {@link ASTNode} is a unary minus, <code>false</code> 1530 * otherwise. 1531 <p> 1532 * @see <a href='libsbml.html#parseL3Formula(java.lang.String)'><code>libsbml.parseL3Formula(String)</code></a> 1533 */ public 1534 boolean isUMinus() { 1535 return libsbmlJNI.ASTNode_isUMinus(swigCPtr, this); 1536 } 1537 1538 1539/** 1540 * Returns <code>true</code> if this node is a unary plus operator. 1541 <p> 1542 * A node is defined as a unary plus node if it is of type 1543 * {@link libsbmlConstants#AST_PLUS AST_PLUS} and has exactly one child. 1544 <p> 1545 * @return <code>true</code> if this {@link ASTNode} is a unary plus, <code>false</code> otherwise. 1546 */ public 1547 boolean isUPlus() { 1548 return libsbmlJNI.ASTNode_isUPlus(swigCPtr, this); 1549 } 1550 1551 1552/** 1553 * Returns <code>true</code> if this node is of a certain type with a specific number 1554 * of children. 1555 <p> 1556 * Designed for use in cases where it is useful to discover if the node is a 1557 * unary not or unary minus, or a times node with no children, etc. 1558 <p> 1559 * @param type the type of {@link ASTNode} sought. 1560 * @param numchildren the number of child nodes sought. 1561 <p> 1562 * @return <code>true</code> if this {@link ASTNode} is has the specified type and number of 1563 * children, <code>false</code> otherwise. 1564 */ public 1565 int hasTypeAndNumChildren(int type, long numchildren) { 1566 return libsbmlJNI.ASTNode_hasTypeAndNumChildren(swigCPtr, this, type, numchildren); 1567 } 1568 1569 1570/** 1571 * Returns <code>true</code> if this node has an unknown type. 1572 <p> 1573 * 'Unknown' nodes have the type {@link libsbmlConstants#AST_UNKNOWN AST_UNKNOWN}. 1574 * Nodes with unknown types will not appear in an {@link ASTNode} tree returned by 1575 * libSBML based upon valid SBML input; the only situation in which a node 1576 * with type {@link libsbmlConstants#AST_UNKNOWN AST_UNKNOWN} may appear is 1577 * immediately after having create a new, untyped node using the {@link ASTNode} 1578 * constructor. Callers creating nodes should endeavor to set the type to 1579 * a valid node type as soon as possible after creating new nodes. 1580 <p> 1581 * @return <code>true</code> if this {@link ASTNode} is of type {@link libsbmlConstants#AST_UNKNOWN AST_UNKNOWN}, <code>false</code> otherwise. 1582 */ public 1583 boolean isUnknown() { 1584 return libsbmlJNI.ASTNode_isUnknown(swigCPtr, this); 1585 } 1586 1587 1588/** 1589 * Returns <code>true</code> if this node has a value for the MathML 1590 * attribute <code>id.</code> 1591 <p> 1592 * @return true if this {@link ASTNode} has an attribute id, <code>false</code> 1593 * otherwise. 1594 <p> 1595 * @see #isSetClass() 1596 * @see #isSetStyle() 1597 * @see #setId(String id) 1598 * @see #unsetId() 1599 */ public 1600 boolean isSetId() { 1601 return libsbmlJNI.ASTNode_isSetId(swigCPtr, this); 1602 } 1603 1604 1605/** 1606 * Returns <code>true</code> if this node has a value for the MathML 1607 * attribute <code>class.</code> 1608 <p> 1609 * @return true if this {@link ASTNode} has an attribute class, <code>false</code> 1610 * otherwise. 1611 <p> 1612 * @see #isSetId() 1613 * @see #isSetStyle() 1614 * @see #setClassName(String id) 1615 * @see #unsetClass() 1616 */ public 1617 boolean isSetClass() { 1618 return libsbmlJNI.ASTNode_isSetClass(swigCPtr, this); 1619 } 1620 1621 1622/** 1623 * Returns <code>true</code> if this node has a value for the MathML 1624 * attribute <code>style.</code> 1625 <p> 1626 * @return true if this {@link ASTNode} has an attribute style, <code>false</code> 1627 * otherwise. 1628 <p> 1629 * @see #isSetClass() 1630 * @see #isSetId() 1631 * @see #setStyle(String id) 1632 * @see #unsetStyle() 1633 */ public 1634 boolean isSetStyle() { 1635 return libsbmlJNI.ASTNode_isSetStyle(swigCPtr, this); 1636 } 1637 1638 1639/** 1640 * Returns <code>true</code> if this node has the attribute 1641 * <code>sbml:units</code>. 1642 <p> 1643 * SBML Level 3 Version 1 introduced the ability to include an 1644attribute <code>sbml:units</code> on MathML <code>cn</code> elements 1645appearing in SBML mathematical formulas. The value of this attribute can 1646be used to indicate the unit of measurement to be associated with the 1647number in the content of the <code>cn</code> element. The value of this 1648attribute must be the identifier of a unit of measurement defined by SBML 1649or the enclosing Model. Here, the <code>sbml</code> portion is an XML 1650namespace prefix that must be associated with the SBML namespace for SBML 1651Level 3. The following example illustrates how this attribute can be 1652used to define a number with value <code>10</code> and unit of measurement 1653<code>second</code>: 1654<pre class="fragment"><math xmlns="http://www.w3.org/1998/Math/MathML" 1655 xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"> 1656 <cn type="integer" sbml:units="second"> 10 </cn> 1657</math> 1658</pre> 1659 1660 <p> 1661 * @return <code>true</code> if this {@link ASTNode} has units associated with it, <code>false</code> 1662 * otherwise. 1663 <p> 1664 * @note The <code>sbml:units</code> attribute is only available in SBML 1665 * Level 3. It may not be used in Levels 1–2 of SBML. 1666 <p> 1667 * @see #hasUnits() 1668 * @see #setUnits(String units) 1669 */ public 1670 boolean isSetUnits() { 1671 return libsbmlJNI.ASTNode_isSetUnits(swigCPtr, this); 1672 } 1673 1674 1675/** 1676 * Returns <code>true</code> if this node or any of its 1677 * children nodes have the attribute <code>sbml:units</code>. 1678 <p> 1679 * SBML Level 3 Version 1 introduced the ability to include an 1680attribute <code>sbml:units</code> on MathML <code>cn</code> elements 1681appearing in SBML mathematical formulas. The value of this attribute can 1682be used to indicate the unit of measurement to be associated with the 1683number in the content of the <code>cn</code> element. The value of this 1684attribute must be the identifier of a unit of measurement defined by SBML 1685or the enclosing Model. Here, the <code>sbml</code> portion is an XML 1686namespace prefix that must be associated with the SBML namespace for SBML 1687Level 3. The following example illustrates how this attribute can be 1688used to define a number with value <code>10</code> and unit of measurement 1689<code>second</code>: 1690<pre class="fragment"><math xmlns="http://www.w3.org/1998/Math/MathML" 1691 xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"> 1692 <cn type="integer" sbml:units="second"> 10 </cn> 1693</math> 1694</pre> 1695 1696 <p> 1697 * @return <code>true</code> if this {@link ASTNode} or its children has units associated 1698 * with it, <code>false</code> otherwise. 1699 <p> 1700 * @note The <code>sbml:units</code> attribute is only available in SBML 1701 * Level 3. It may not be used in Levels 1–2 of SBML. 1702 <p> 1703 * @see #isSetUnits() 1704 * @see #setUnits(String units) 1705 */ public 1706 boolean hasUnits() { 1707 return libsbmlJNI.ASTNode_hasUnits(swigCPtr, this); 1708 } 1709 1710 1711/** 1712 * Sets the value of this {@link ASTNode} to the given character. If character 1713 * is one of <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code> or <code>^</code>, the node 1714 * type will be set accordingly. For all other characters, the node type 1715 * will be set to {@link libsbmlConstants#AST_UNKNOWN AST_UNKNOWN}. 1716 <p> 1717 * @param value the character value to which the node's value should be 1718 * set. 1719 <p> 1720 * <p> 1721 * @return integer value indicating success/failure of the 1722 * function. The possible values 1723 * returned by this function are: 1724 * <ul> 1725 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1726 * </ul> 1727 */ public 1728 int setCharacter(char value) { 1729 return libsbmlJNI.ASTNode_setCharacter(swigCPtr, this, value); 1730 } 1731 1732 1733/** 1734 * Sets the MathML attribute <code>id</code> of this {@link ASTNode}. 1735 <p> 1736 * @param id <code>string</code> representing the identifier. 1737 <p> 1738 * <p> 1739 * @return integer value indicating success/failure of the 1740 * function. The possible values 1741 * returned by this function are: 1742 * <ul> 1743 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1744 * 1745 * </ul> <p> 1746 * @see #isSetId() 1747 * @see #getId() 1748 * @see #unsetId() 1749 */ public 1750 int setId(String id) { 1751 return libsbmlJNI.ASTNode_setId(swigCPtr, this, id); 1752 } 1753 1754 1755/** 1756 * Sets the MathML attribute <code>class</code> of this {@link ASTNode}. 1757 <p> 1758 * @param className <code>string</code> representing the MathML class for this node. 1759 <p> 1760 * <p> 1761 * @return integer value indicating success/failure of the 1762 * function. The possible values 1763 * returned by this function are: 1764 * <ul> 1765 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1766 * 1767 * </ul> <p> 1768 * @note In the API interfaces for languages other than Java, this method 1769 * is named <code>setClass()</code>, but in Java it is renamed 1770 * <code>setClassName()</code> to avoid a name collision with Java's 1771 * standard object method of the same name. 1772 <p> 1773 * @see #isSetClass() 1774 * @see #getClass() 1775 * @see #unsetClass() 1776 */ public 1777 int setClassName(String className) { 1778 return libsbmlJNI.ASTNode_setClassName(swigCPtr, this, className); 1779 } 1780 1781 1782/** 1783 * Sets the MathML attribute <code>style</code> of this {@link ASTNode}. 1784 <p> 1785 * @param style <code>string</code> representing the identifier. 1786 <p> 1787 * <p> 1788 * @return integer value indicating success/failure of the 1789 * function. The possible values 1790 * returned by this function are: 1791 * <ul> 1792 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1793 * 1794 * </ul> <p> 1795 * @see #isSetStyle() 1796 * @see #getStyle() 1797 * @see #unsetStyle() 1798 */ public 1799 int setStyle(String style) { 1800 return libsbmlJNI.ASTNode_setStyle(swigCPtr, this, style); 1801 } 1802 1803 1804/** 1805 * Sets the value of this {@link ASTNode} to the given name. 1806 <p> 1807 * As a side effect, this {@link ASTNode} object's type will be reset to 1808 * {@link libsbmlConstants#AST_NAME AST_NAME} if (and <em>only if</em>) the 1809 * {@link ASTNode} was previously an operator (i.e., * {@link ASTNode#isOperator()} returns <code>true</code>), number (i.e., {@link ASTNode#isNumber()} returns <code>true</code>), or 1810 * unknown. This allows names to be set for {@link libsbmlConstants#AST_FUNCTION AST_FUNCTION} nodes and the like. 1811 <p> 1812 * @param name the string containing the name to which this node's value 1813 * should be set. 1814 <p> 1815 * <p> 1816 * @return integer value indicating success/failure of the 1817 * function. The possible values 1818 * returned by this function are: 1819 * <ul> 1820 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1821 * </ul> 1822 */ public 1823 int setName(String name) { 1824 return libsbmlJNI.ASTNode_setName(swigCPtr, this, name); 1825 } 1826 1827 1828/** 1829 * Sets the value of this {@link ASTNode} to the given (<code>long</code>) integer 1830 <p> 1831 * As a side effect, this operation sets the node type to 1832 * {@link libsbmlConstants#AST_INTEGER AST_INTEGER}. 1833 <p> 1834 * @param value the integer to which this node's value should be set. 1835 <p> 1836 * <p> 1837 * @return integer value indicating success/failure of the 1838 * function. The possible values 1839 * returned by this function are: 1840 * <ul> 1841 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1842 * </ul> 1843 */ public 1844 int setValue(int value) { 1845 return libsbmlJNI.ASTNode_setValue__SWIG_0(swigCPtr, this, value); 1846 } 1847 1848 1849/** 1850 * Sets the value of this {@link ASTNode} to the given rational. 1851 <p> 1852 * As a side effect, this operation sets the node type to 1853 * {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}. 1854 <p> 1855 * @param numerator the numerator value of the rational. 1856 * @param denominator the denominator value of the rational. 1857 <p> 1858 * <p> 1859 * @return integer value indicating success/failure of the 1860 * function. The possible values 1861 * returned by this function are: 1862 * <ul> 1863 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1864 * </ul> 1865 */ public 1866 int setValue(int numerator, int denominator) { 1867 return libsbmlJNI.ASTNode_setValue__SWIG_1(swigCPtr, this, numerator, denominator); 1868 } 1869 1870 1871/** 1872 * Sets the value of this {@link ASTNode} to the given real (<code>double</code>). 1873 <p> 1874 * As a side effect, this operation sets the node type to 1875 * {@link libsbmlConstants#AST_REAL AST_REAL}. 1876 <p> 1877 * This is functionally equivalent to: 1878 * <pre class='fragment'> 1879setValue(value, 0); 1880</pre> 1881 <p> 1882 * @param value the <code>double</code> format number to which this node's value 1883 * should be set. 1884 <p> 1885 * <p> 1886 * @return integer value indicating success/failure of the 1887 * function. The possible values 1888 * returned by this function are: 1889 * <ul> 1890 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1891 * </ul> 1892 */ public 1893 int setValue(double value) { 1894 return libsbmlJNI.ASTNode_setValue__SWIG_2(swigCPtr, this, value); 1895 } 1896 1897 1898/** 1899 * Sets the value of this {@link ASTNode} to the given real (<code>double</code>) 1900 <p> 1901 * As a side effet, this operation sets the node type to 1902 * {@link libsbmlConstants#AST_REAL_E AST_REAL_E}. 1903 <p> 1904 * @param mantissa the mantissa of this node's real-numbered value. 1905 * @param exponent the exponent of this node's real-numbered value. 1906 <p> 1907 * <p> 1908 * @return integer value indicating success/failure of the 1909 * function. The possible values 1910 * returned by this function are: 1911 * <ul> 1912 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1913 * </ul> 1914 */ public 1915 int setValue(double mantissa, int exponent) { 1916 return libsbmlJNI.ASTNode_setValue__SWIG_3(swigCPtr, this, mantissa, exponent); 1917 } 1918 1919 1920/** 1921 * Sets the type of this {@link ASTNode}. 1922 <p> 1923 * This uses integer type codes, which may come from the set 1924 * of static integer constants whose names begin with the prefix 1925 * <code>AST_</code> defined in the interface class 1926 * <code><a href='libsbmlConstants.html'>libsbmlConstants</a></code> 1927 * or an enumeration of AST types in an SBML 1928 * Level 3 package. 1929 <p> 1930 * @param type the integer representing the type to which this node should 1931 * be set. 1932 <p> 1933 * <p> 1934 * @return integer value indicating success/failure of the 1935 * function. The possible values 1936 * returned by this function are: 1937 * <ul> 1938 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1939 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 1940 * 1941 * </ul> <p> 1942 * @note A side-effect of doing this is that any numerical values 1943 * previously stored in this node are reset to zero. 1944 <p> 1945 * @see #getType() 1946 * @see #setType(int) 1947 */ public 1948 int setType(int type) { 1949 return libsbmlJNI.ASTNode_setType(swigCPtr, this, type); 1950 } 1951 1952 1953/** 1954 * Sets the units of this {@link ASTNode} to units. 1955 <p> 1956 * The units will be set <em>only</em> if this {@link ASTNode} object represents a 1957 * MathML <code><cn></code> element, i.e., represents a number. 1958 * Callers may use 1959 * {@link ASTNode#isNumber()} 1960 * to inquire whether the node is of that type. 1961 <p> 1962 * SBML Level 3 Version 1 introduced the ability to include an 1963attribute <code>sbml:units</code> on MathML <code>cn</code> elements 1964appearing in SBML mathematical formulas. The value of this attribute can 1965be used to indicate the unit of measurement to be associated with the 1966number in the content of the <code>cn</code> element. The value of this 1967attribute must be the identifier of a unit of measurement defined by SBML 1968or the enclosing Model. Here, the <code>sbml</code> portion is an XML 1969namespace prefix that must be associated with the SBML namespace for SBML 1970Level 3. The following example illustrates how this attribute can be 1971used to define a number with value <code>10</code> and unit of measurement 1972<code>second</code>: 1973<pre class="fragment"><math xmlns="http://www.w3.org/1998/Math/MathML" 1974 xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"> 1975 <cn type="integer" sbml:units="second"> 10 </cn> 1976</math> 1977</pre> 1978 1979 <p> 1980 * @param units <code>string</code> representing the unit identifier. 1981 <p> 1982 * <p> 1983 * @return integer value indicating success/failure of the 1984 * function. The possible values 1985 * returned by this function are: 1986 * <ul> 1987 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1988 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 1989 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 1990 * 1991 * </ul> <p> 1992 * @note The <code>sbml:units</code> attribute is only available in SBML 1993 * Level 3. It may not be used in Levels 1–2 of SBML. 1994 <p> 1995 * @see #isSetUnits() 1996 * @see #hasUnits() 1997 */ public 1998 int setUnits(String units) { 1999 return libsbmlJNI.ASTNode_setUnits(swigCPtr, this, units); 2000 } 2001 2002 2003/** 2004 * Swaps the children of this node with the children of another node. 2005 <p> 2006 * @param that the other node whose children should be used to replace 2007 * <em>this</em> node's children. 2008 <p> 2009 * <p> 2010 * @return integer value indicating success/failure of the 2011 * function. The possible values 2012 * returned by this function are: 2013 * <ul> 2014 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 2015 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 2016 * </ul> 2017 */ public 2018 int swapChildren(ASTNode that) { 2019 return libsbmlJNI.ASTNode_swapChildren(swigCPtr, this, ASTNode.getCPtr(that), that); 2020 } 2021 2022 2023/** 2024 * Renames all the SIdRef attributes on this node and its child nodes. 2025 <p> 2026 * @param oldid the old identifier. 2027 * @param newid the new identifier. 2028 */ public 2029 void renameSIdRefs(String oldid, String newid) { 2030 libsbmlJNI.ASTNode_renameSIdRefs(swigCPtr, this, oldid, newid); 2031 } 2032 2033 2034/** 2035 * Renames all the UnitSIdRef attributes on this node and its child nodes. 2036 <p> 2037 * The only place UnitSIDRefs appear in MathML <code><cn></code> 2038 * elements, so the effects of this method are limited to that. 2039 <p> 2040 * @param oldid the old identifier. 2041 * @param newid the new identifier. 2042 */ public 2043 void renameUnitSIdRefs(String oldid, String newid) { 2044 libsbmlJNI.ASTNode_renameUnitSIdRefs(swigCPtr, this, oldid, newid); 2045 } 2046 2047 2048/** * @internal */ public 2049 void replaceIDWithFunction(String id, ASTNode function) { 2050 libsbmlJNI.ASTNode_replaceIDWithFunction(swigCPtr, this, id, ASTNode.getCPtr(function), function); 2051 } 2052 2053 2054/** * @internal */ public 2055 void setIsChildFlag(boolean flag) { 2056 libsbmlJNI.ASTNode_setIsChildFlag(swigCPtr, this, flag); 2057 } 2058 2059 2060/** 2061 * Unsets the units of this {@link ASTNode}. 2062 <p> 2063 * <p> 2064 * @return integer value indicating success/failure of the 2065 * function. The possible values 2066 * returned by this function are: 2067 * <ul> 2068 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 2069 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 2070 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 2071 * </ul> 2072 */ public 2073 int unsetUnits() { 2074 return libsbmlJNI.ASTNode_unsetUnits(swigCPtr, this); 2075 } 2076 2077 2078/** 2079 * Unsets the MathML <code>id</code> attribute of this {@link ASTNode}. 2080 <p> 2081 * <p> 2082 * @return integer value indicating success/failure of the 2083 * function. The possible values 2084 * returned by this function are: 2085 * <ul> 2086 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 2087 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 2088 * </ul> 2089 */ public 2090 int unsetId() { 2091 return libsbmlJNI.ASTNode_unsetId(swigCPtr, this); 2092 } 2093 2094 2095/** 2096 * Unsets the MathML <code>class</code> attribute of this {@link ASTNode}. 2097 <p> 2098 * <p> 2099 * @return integer value indicating success/failure of the 2100 * function. The possible values 2101 * returned by this function are: 2102 * <ul> 2103 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 2104 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 2105 * </ul> 2106 */ public 2107 int unsetClass() { 2108 return libsbmlJNI.ASTNode_unsetClass(swigCPtr, this); 2109 } 2110 2111 2112/** 2113 * Unsets the MathML <code>style</code> attribute of this {@link ASTNode}. 2114 <p> 2115 * <p> 2116 * @return integer value indicating success/failure of the 2117 * function. The possible values 2118 * returned by this function are: 2119 * <ul> 2120 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 2121 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 2122 * </ul> 2123 */ public 2124 int unsetStyle() { 2125 return libsbmlJNI.ASTNode_unsetStyle(swigCPtr, this); 2126 } 2127 2128 2129/** 2130 * Sets the MathML attribute <code>definitionURL.</code> 2131 <p> 2132 * @param url the URL value for the <code>definitionURL</code> attribute. 2133 <p> 2134 * <p> 2135 * @return integer value indicating success/failure of the 2136 * function. The possible values 2137 * returned by this function are: 2138 * <ul> 2139 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 2140 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 2141 * 2142 * </ul> <p> 2143 * @see #setDefinitionURL(String url) 2144 * @see #getDefinitionURL() 2145 * @see #getDefinitionURLString() 2146 */ public 2147 int setDefinitionURL(XMLAttributes url) { 2148 return libsbmlJNI.ASTNode_setDefinitionURL__SWIG_0(swigCPtr, this, XMLAttributes.getCPtr(url), url); 2149 } 2150 2151 2152/** 2153 * Sets the MathML attribute <code>definitionURL.</code> 2154 <p> 2155 * @param url the URL value for the <code>definitionURL</code> attribute. 2156 <p> 2157 * <p> 2158 * @return integer value indicating success/failure of the 2159 * function. The possible values 2160 * returned by this function are: 2161 * <ul> 2162 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 2163 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 2164 * 2165 * </ul> <p> 2166 * @see #setDefinitionURL(XMLAttributes url) 2167 * @see #getDefinitionURL() 2168 * @see #getDefinitionURLString() 2169 */ public 2170 int setDefinitionURL(String url) { 2171 return libsbmlJNI.ASTNode_setDefinitionURL__SWIG_1(swigCPtr, this, url); 2172 } 2173 2174 2175/** 2176 * Returns the MathML <code>definitionURL</code> attribute value. 2177 <p> 2178 * @return the value of the <code>definitionURL</code> attribute, in the form of 2179 * a libSBML {@link XMLAttributes} object. 2180 <p> 2181 * @see #setDefinitionURL(XMLAttributes url) 2182 * @see #setDefinitionURL(String url) 2183 * @see #getDefinitionURLString() 2184 */ public 2185 XMLAttributes getDefinitionURL() { 2186 long cPtr = libsbmlJNI.ASTNode_getDefinitionURL(swigCPtr, this); 2187 return (cPtr == 0) ? null : new XMLAttributes(cPtr, false); 2188 } 2189 2190 2191/** 2192 * Replaces occurrences of a given name with a given {@link ASTNode}. 2193 <p> 2194 * For example, if the formula in this {@link ASTNode} is <code>x + y</code>, 2195 * then the <code><bvar></code> is <code>x</code> and <code>arg</code> is an {@link ASTNode} 2196 * representing the real value <code>3.</code> This method substitutes <code>3</code> for 2197 * <code>x</code> within this {@link ASTNode} object. 2198 <p> 2199 * @param bvar a string representing the variable name to be substituted. 2200 <p> 2201 * @param arg an {@link ASTNode} representing the name/value/formula to use as 2202 * a replacement. 2203 */ public 2204 void replaceArgument(String bvar, ASTNode arg) { 2205 libsbmlJNI.ASTNode_replaceArgument(swigCPtr, this, bvar, ASTNode.getCPtr(arg), arg); 2206 } 2207 2208 2209/** 2210 * Returns the parent SBML object. 2211 <p> 2212 * @return the parent SBML object of this {@link ASTNode}. 2213 <p> 2214 * @see #isSetParentSBMLObject() 2215 */ public 2216 SBase getParentSBMLObject() { 2217 return libsbml.DowncastSBase(libsbmlJNI.ASTNode_getParentSBMLObject(swigCPtr, this), false); 2218} 2219 2220 2221/** 2222 * Unsets the parent SBML object. 2223 <p> 2224 * <p> 2225 * @return integer value indicating success/failure of the 2226 * function. The possible values 2227 * returned by this function are: 2228 * <ul> 2229 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 2230 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 2231 * 2232 * </ul> <p> 2233 * @see #isSetParentSBMLObject() 2234 * @see #getParentSBMLObject() 2235 */ public 2236 int unsetParentSBMLObject() { 2237 return libsbmlJNI.ASTNode_unsetParentSBMLObject(swigCPtr, this); 2238 } 2239 2240 2241/** 2242 * Returns <code>true</code> if this node has a value for the parent SBML 2243 * object. 2244 <p> 2245 * @return true if this {@link ASTNode} has an parent SBML object set, <code>false</code> otherwise. 2246 <p> 2247 * @see #getParentSBMLObject() 2248 */ public 2249 boolean isSetParentSBMLObject() { 2250 return libsbmlJNI.ASTNode_isSetParentSBMLObject(swigCPtr, this); 2251 } 2252 2253 2254/** 2255 * Reduces this {@link ASTNode} to a binary tree. 2256 <p> 2257 * Example: if this {@link ASTNode} is <code>and(x, y, z)</code>, then the 2258 * formula of the reduced node is <code>and(and(x, y), z)</code>. The 2259 * operation replaces the formula stored in the current {@link ASTNode} object. 2260 */ public 2261 void reduceToBinary() { 2262 libsbmlJNI.ASTNode_reduceToBinary(swigCPtr, this); 2263 } 2264 2265 2266/** 2267 * Unsets the user data of this node. 2268 <p> 2269 * The user data can be used by the application developer to attach custom 2270 * information to the node. In case of a deep copy, this attribute will 2271 * passed as it is. The attribute will be never interpreted by this class. 2272 <p> 2273 * <p> 2274 * @return integer value indicating success/failure of the 2275 * function. The possible values 2276 * returned by this function are: 2277 * <ul> 2278 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 2279 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 2280 * 2281 * </ul> */ public 2282 int unsetUserData() { 2283 return libsbmlJNI.ASTNode_unsetUserData(swigCPtr, this); 2284 } 2285 2286 2287/** 2288 * Returns <code>true</code> if this node has a user data object. 2289 <p> 2290 * @return true if this {@link ASTNode} has a user data object set, <code>false</code> 2291 * otherwise. 2292 */ public 2293 boolean isSetUserData() { 2294 return libsbmlJNI.ASTNode_isSetUserData(swigCPtr, this); 2295 } 2296 2297 2298/** 2299 * Returns <code>true</code> or <code>false</code> depending on whether this 2300 * {@link ASTNode} is well-formed. 2301 <p> 2302 * @note An {@link ASTNode} may be well-formed, with each node and its children 2303 * having the appropriate number of children for the given type, but may 2304 * still be invalid in the context of its use within an SBML model. 2305 <p> 2306 * @return <code>true</code> if this {@link ASTNode} is well-formed, <code>false</code> otherwise. 2307 <p> 2308 * @see #hasCorrectNumberArguments() 2309 */ public 2310 boolean isWellFormedASTNode() { 2311 return libsbmlJNI.ASTNode_isWellFormedASTNode(swigCPtr, this); 2312 } 2313 2314 2315/** 2316 * Returns <code>true</code> if this {@link ASTNode} has the correct number of children for 2317 * its type. 2318 <p> 2319 * For example, an {@link ASTNode} with type {@link libsbmlConstants#AST_PLUS AST_PLUS} 2320 * expects 2 child nodes. 2321 <p> 2322 * @return <code>true</code> if this {@link ASTNode} has the appropriate number of children 2323 * for its type, <code>false</code> otherwise. 2324 <p> 2325 * @note This function performs a check on the top-level node only. Child 2326 * nodes are not checked. 2327 <p> 2328 * @see #isWellFormedASTNode() 2329 */ public 2330 boolean hasCorrectNumberArguments() { 2331 return libsbmlJNI.ASTNode_hasCorrectNumberArguments(swigCPtr, this); 2332 } 2333 2334 2335/** 2336 * Returns the MathML <code>definitionURL</code> attribute value as a string. 2337 <p> 2338 * @return the value of the <code>definitionURL</code> attribute, as a string. 2339 <p> 2340 * @see #getDefinitionURL() 2341 * @see #setDefinitionURL(String url) 2342 * @see #setDefinitionURL(XMLAttributes url) 2343 */ public 2344 String getDefinitionURLString() { 2345 return libsbmlJNI.ASTNode_getDefinitionURLString(swigCPtr, this); 2346 } 2347 2348 2349/** * @internal */ public 2350 boolean representsBvar() { 2351 return libsbmlJNI.ASTNode_representsBvar(swigCPtr, this); 2352 } 2353 2354 2355/** * @internal */ public 2356 void write(XMLOutputStream stream) { 2357 libsbmlJNI.ASTNode_write(swigCPtr, this, XMLOutputStream.getCPtr(stream), stream); 2358 } 2359 2360 2361/** * @internal */ public 2362 boolean read(XMLInputStream stream, String reqd_prefix) { 2363 return libsbmlJNI.ASTNode_read__SWIG_0(swigCPtr, this, XMLInputStream.getCPtr(stream), stream, reqd_prefix); 2364 } 2365 2366 2367/** * @internal */ public 2368 boolean read(XMLInputStream stream) { 2369 return libsbmlJNI.ASTNode_read__SWIG_1(swigCPtr, this, XMLInputStream.getCPtr(stream), stream); 2370 } 2371 2372 2373/** * @internal */ public 2374 void writeNodeOfType(XMLOutputStream stream, int type, boolean inChildNode) { 2375 libsbmlJNI.ASTNode_writeNodeOfType__SWIG_0(swigCPtr, this, XMLOutputStream.getCPtr(stream), stream, type, inChildNode); 2376 } 2377 2378 2379/** * @internal */ public 2380 void writeNodeOfType(XMLOutputStream stream, int type) { 2381 libsbmlJNI.ASTNode_writeNodeOfType__SWIG_1(swigCPtr, this, XMLOutputStream.getCPtr(stream), stream, type); 2382 } 2383 2384 2385/** * @internal */ public 2386 long getNumBvars() { 2387 return libsbmlJNI.ASTNode_getNumBvars(swigCPtr, this); 2388 } 2389 2390 2391/** * @internal */ public 2392 int getTypeCode() { 2393 return libsbmlJNI.ASTNode_getTypeCode(swigCPtr, this); 2394 } 2395 2396 2397/** * @internal */ public 2398 String getPackageName() { 2399 return libsbmlJNI.ASTNode_getPackageName(swigCPtr, this); 2400 } 2401 2402 2403/** * @internal */ public 2404 ASTBasePlugin getPlugin(String arg0) { 2405 long cPtr = libsbmlJNI.ASTNode_getPlugin__SWIG_0(swigCPtr, this, arg0); 2406 return (cPtr == 0) ? null : new ASTBasePlugin(cPtr, false); 2407 } 2408 2409 2410/** * @internal */ public 2411 ASTBasePlugin getPlugin(long n) { 2412 long cPtr = libsbmlJNI.ASTNode_getPlugin__SWIG_2(swigCPtr, this, n); 2413 return (cPtr == 0) ? null : new ASTBasePlugin(cPtr, false); 2414 } 2415 2416 public ASTNodeList getListOfNodes() { 2417 long cPtr = libsbmlJNI.ASTNode_getListOfNodes(swigCPtr, this); 2418 return (cPtr == 0) ? null : new ASTNodeList(cPtr, true); 2419 } 2420 2421}