001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 2.0.11 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 * 013 * Abstract Syntax Tree (AST) representation of a 014 * mathematical expression. 015 * <p> 016 * <p style='color: #777; font-style: italic'> 017This class of objects is defined by libSBML only and has no direct 018equivalent in terms of SBML components. This class is not prescribed by 019the SBML specifications, although it is used to implement features 020defined in SBML. 021</p> 022 023 * <p> 024 * Abstract Syntax Trees (ASTs) are a simple kind of data structure used in 025 * libSBML for storing mathematical expressions. The {@link ASTNode} is the 026 * cornerstone of libSBML's AST representation. An AST 'node' represents the 027 * most basic, indivisible part of a mathematical formula and come in many 028 * types. For instance, there are node types to represent numbers (with 029 * subtypes to distinguish integer, real, and rational numbers), names 030 * (e.g., constants or variables), simple mathematical operators, logical 031 * or relational operators and functions. LibSBML ASTs provide a canonical, 032 * in-memory representation for all mathematical formulas regardless of 033 * their original format (which might be MathML or might be text strings). 034 * <p> 035 * An AST <em>node</em> in libSBML is a recursive structure containing a pointer 036 * to the node's value (which might be, for example, a number or a symbol) 037 * and a list of children nodes. Each {@link ASTNode} node may have none, one, 038 * two, or more children depending on its type. The following diagram 039 * illustrates an example of how the mathematical expression <code>'1 + 040 * 2'</code> is represented as an AST with one <em>plus</em> node having two 041 * <em>integer</em> children nodes for the numbers <code>1</code> and 042 * <code>2</code>. The figure also shows the corresponding MathML 043 * representation: 044 * <p> 045 * <center style='padding-bottom: 0.5em'> 046<table border='0' class='text-table width80 normal-font'> 047<caption class='top-caption'>Example AST representation of a mathematical expression.</caption> 048<tr> 049<th>Infix</th> 050<th>AST</th> 051<th>MathML</th> 052</tr> 053<tr> 054<td valign='middle'> 055<code>1 + 2</code> 056</td> 057<td valign='middle'> 058<iframe src='simple-ast.svg' width='140' height='120' scrolling='no' frameborder='0'></iframe> 059</td> 060<td valign='middle'> 061<code><math xmlns='http://www.w3.org/1998/Math/MathML'></code><br> 062<code> <apply></code><br> 063<code> <plus/></code><br> 064<code> <cn type='integer'> 1 </cn></code><br> 065<code> <cn type='integer'> 2 </cn></code><br> 066<code> </apply></code><br> 067<code></math></code> 068</td> 069</tr> 070</table> 071</center> 072 073 * <p> 074 * The following are other noteworthy points about the AST representation 075 * in libSBML: 076 * <ul> 077 * <li> A numerical value represented in MathML as a real number with an 078 * exponent is preserved as such in the AST node representation, even if 079 * the number could be stored in a <code>double</code> data type. This is done 080 * so that when an SBML model is read in and then written out again, the 081 * amount of change introduced by libSBML to the SBML during the round-trip 082 * activity is minimized. 083 * <p> 084 * <li> Rational numbers are represented in an AST node using separate 085 * numerator and denominator values. These can be retrieved using the 086 * methods {@link ASTNode#getNumerator()} and {@link ASTNode#getDenominator()}. 087 * <p> 088 * <li> The children of an {@link ASTNode} are other {@link ASTNode} objects. The list of 089 * children is empty for nodes that are leaf elements, such as numbers. 090 * For nodes that are actually roots of expression subtrees, the list of 091 * children points to the parsed objects that make up the rest of the 092 * expression. 093 * </ul> 094 * <p> 095 * <p> 096 * <h3><a class='anchor' 097 * name='ASTNodeType_t'>The set of possible ASTNode types</a></h3> 098 * <p> 099 * Every {@link ASTNode} has an associated type code to indicate, 100 * for example, whether it holds a number or stands for an arithmetic 101 * operator. 102 * <p> 103 * The type is recorded as a value drawn from a 104 * set of static integer constants defined in the class {@link 105 * libsbmlConstants}. Their names begin with the characters <code>AST_.</code> 106 * <p> 107 * <p> 108 * The list of possible types is quite long, because it covers all the 109 * mathematical functions that are permitted in SBML. The values are shown 110 * in the following table: 111 * <p> 112 * <ul class='columnlist list3'> 113<li>AST_CONSTANT_E</li> 114<li>AST_CONSTANT_FALSE</li> 115<li>AST_CONSTANT_PI</li> 116<li>AST_CONSTANT_TRUE</li> 117<li>AST_DIVIDE</li> 118<li>AST_FUNCTION</li> 119<li>AST_FUNCTION_ABS</li> 120<li>AST_FUNCTION_ARCCOS</li> 121<li>AST_FUNCTION_ARCCOSH</li> 122<li>AST_FUNCTION_ARCCOT</li> 123<li>AST_FUNCTION_ARCCOTH</li> 124<li>AST_FUNCTION_ARCCSC</li> 125<li>AST_FUNCTION_ARCCSCH</li> 126<li>AST_FUNCTION_ARCSEC</li> 127<li>AST_FUNCTION_ARCSECH</li> 128<li>AST_FUNCTION_ARCSIN</li> 129<li>AST_FUNCTION_ARCSINH</li> 130<li>AST_FUNCTION_ARCTAN</li> 131<li>AST_FUNCTION_ARCTANH</li> 132<li>AST_FUNCTION_CEILING</li> 133<li>AST_FUNCTION_COS</li> 134<li>AST_FUNCTION_COSH</li> 135<li>AST_FUNCTION_COT</li> 136<li>AST_FUNCTION_COTH</li> 137<li>AST_FUNCTION_CSC</li> 138<li>AST_FUNCTION_CSCH</li> 139<li>AST_FUNCTION_DELAY</li> 140<li>AST_FUNCTION_EXP</li> 141<li>AST_FUNCTION_FACTORIAL</li> 142<li>AST_FUNCTION_FLOOR</li> 143<li>AST_FUNCTION_LN</li> 144<li>AST_FUNCTION_LOG</li> 145<li>AST_FUNCTION_PIECEWISE</li> 146<li>AST_FUNCTION_POWER</li> 147<li>AST_FUNCTION_ROOT</li> 148<li>AST_FUNCTION_SEC</li> 149<li>AST_FUNCTION_SECH</li> 150<li>AST_FUNCTION_SIN</li> 151<li>AST_FUNCTION_SINH</li> 152<li>AST_FUNCTION_TAN</li> 153<li>AST_FUNCTION_TANH</li> 154<li>AST_INTEGER</li> 155<li>AST_LAMBDA</li> 156<li>AST_LOGICAL_AND</li> 157<li>AST_LOGICAL_NOT</li> 158<li>AST_LOGICAL_OR</li> 159<li>AST_LOGICAL_XOR</li> 160<li>AST_MINUS</li> 161<li>AST_NAME</li> 162<li><nobr>AST_NAME_AVOGADRO <em><span class='warning'>(Level 3 only)</span></em></nobr></li> 163<li>AST_NAME_TIME</li> 164<li>AST_PLUS</li> 165<li>AST_POWER</li> 166<li>AST_RATIONAL</li> 167<li>AST_REAL</li> 168<li>AST_REAL_E</li> 169<li>AST_RELATIONAL_EQ</li> 170<li>AST_RELATIONAL_GEQ</li> 171<li>AST_RELATIONAL_GT</li> 172<li>AST_RELATIONAL_LEQ</li> 173<li>AST_RELATIONAL_LT</li> 174<li>AST_RELATIONAL_NEQ</li> 175<li>AST_TIMES</li> 176<li>AST_UNKNOWN</li> 177</ul> 178<br style='clear: both'> 179 180 * <p> 181 * The types have the following meanings: 182 * <ul> 183 * <li> If the node is basic mathematical operator (e.g., <code>'+'</code>), then the 184 * node's type will be <code>AST_PLUS</code>, <code>AST_MINUS</code>, <code>AST_TIMES</code>, <code>AST_DIVIDE</code>, 185 * or <code>AST_POWER</code>, as appropriate. 186 * <p> 187 * <li> If the node is a predefined function or operator from SBML Level 1 188 * (in the string-based formula syntax used in Level 1) or SBML Levels 2 and 3 189 * (in the subset of MathML used in SBML Levels 2 and 3), then the node's type 190 * will be either <code>AST_FUNCTION_</code><em><span 191 * class='placeholder'>X</span></em>, <code>AST_LOGICAL_</code><em><span 192 * class='placeholder'>X</span></em>, or 193 * <code>AST_RELATIONAL_</code><em><span class='placeholder'>X</span></em>, 194 * as appropriate. (Examples: <code>AST_FUNCTION_LOG</code>, <code>AST_RELATIONAL_LEQ.</code>) 195 * <p> 196 * <li> If the node refers to a user-defined function, the node's type will 197 * be <code>AST_FUNCTION</code> (because it holds the name of the function). 198 * <p> 199 * <li> If the node is a lambda expression, its type will be <code>AST_LAMBDA.</code> 200 * <p> 201 * <li> If the node is a predefined constant (<code>'ExponentialE'</code>, <code>'Pi'</code>, 202 * <code>'True'</code> or <code>'False'</code>), then the node's type will be <code>AST_CONSTANT_E</code>, 203 * <code>AST_CONSTANT_PI</code>, <code>AST_CONSTANT_TRUE</code>, or <code>AST_CONSTANT_FALSE.</code> 204 * <p> 205 * <li> (Levels 2 and 3 only) If the node is the special MathML csymbol <code>time</code>, 206 * the value of the node will be <code>AST_NAME_TIME.</code> (Note, however, that the 207 * MathML csymbol <code>delay</code> is translated into a node of type 208 * <code>AST_FUNCTION_DELAY.</code> The difference is due to the fact that <code>time</code> is a 209 * single variable, whereas <code>delay</code> is actually a function taking 210 * arguments.) 211 * <p> 212 * <li> (Level 3 only) If the node is the special MathML csymbol <code>avogadro</code>, 213 * the value of the node will be <code>AST_NAME_AVOGADRO.</code> 214 * <p> 215 * <li> If the node contains a numerical value, its type will be 216 * <code>AST_INTEGER</code>, <code>AST_REAL</code>, <code>AST_REAL_E</code>, or <code>AST_RATIONAL</code>, 217 * as appropriate. 218 * </ul> 219 * <p> 220 * <p> 221 * <h3><a class='anchor' name='math-convert'>Converting between ASTs and text strings</a></h3> 222 * <p> 223 * The text-string form of mathematical formulas produced by <code><a href='libsbml.html#formulaToString(org.sbml.libsbml.ASTNode)'>libsbml.formulaToString()</a></code> and 224 * read by <code><a href='libsbml.html#parseFormula(java.lang.String)'>libsbml.parseFormula(String formula)</a></code> 225 * and 226 * <code><a href='libsbml.html#parseL3Formula(java.lang.String)'>libsbml.parseL3Formula(String formula)</a></code> 227 * are in a simple C-inspired infix notation. A 228 * formula in this text-string form can be handed to a program that 229 * understands SBML mathematical expressions, or used as part 230 * of a translation system. The libSBML distribution comes with an example 231 * program in the <code>'examples'</code> subdirectory called <code>translateMath</code> that 232 * implements an interactive command-line demonstration of translating 233 * infix formulas into MathML and vice-versa. 234 * <p> 235 * The formula strings may contain operators, function calls, symbols, and 236 * white space characters. The allowable white space characters are tab 237 * and space. The following are illustrative examples of formulas 238 * expressed in the syntax: 239 * <p> 240 * <div class='fragment'><pre> 2410.10 * k4^2 242</pre></div> 243 * <div class='fragment'><pre> 244(vm * s1)/(km + s1) 245</pre></div> 246 * <p> 247 * The following table shows the precedence rules in this syntax. In the 248 * Class column, <em>operand</em> implies the construct is an operand, 249 * <em>prefix</em> implies the operation is applied to the following arguments, 250 * <em>unary</em> implies there is one argument, and <em>binary</em> implies there are 251 * two arguments. The values in the Precedence column show how the order 252 * of different types of operation are determined. For example, the 253 * expression <em>a * b + c</em> is evaluated as <em>(a * b) + c</em> 254 * because the <code>*</code> operator has higher precedence. The 255 * Associates column shows how the order of similar precedence operations 256 * is determined; for example, <em>a - b + c</em> is evaluated as <em>(a - 257 * b) + c</em> because the <code>+</code> and <code>-</code> operators are 258 * left-associative. The precedence and associativity rules are taken from 259 * the C programming language, except for the symbol <code>^</code>, which 260 * is used in C for a different purpose. (Exponentiation can be invoked 261 * using either <code>^</code> or the function <code>power.</code>) 262 * <p> 263 * <center style='padding-bottom: 0.5em'> 264<table border='0' class='text-table width80 normal-font alt-row-colors'> 265 <tr style='background: lightgray; font-size: 14px;'> 266 <th align='left'>Token</th> 267 <th align='left'>Operation</th> 268 <th align='left'>Class</th> 269 <th>Precedence</th> 270 <th align='left'>Associates</th> 271 </tr> 272<tr><td><em>name</em></td><td>symbol reference</td><td>operand</td><td align='center'>6</td><td>n/a</td></tr> 273<tr><td><code>(</code><em>expression</em><code>)</code></td><td>expression grouping</td><td>operand</td><td align='center'>6</td><td>n/a</td></tr> 274<tr><td><code>f(</code><em>...</em><code>)</code></td><td>function call</td><td>prefix</td><td align='center'>6</td><td>left</td></tr> 275<tr><td><code>-</code></td><td>negation</td><td>unary</td><td align='center'>5</td><td>right</td></tr> 276<tr><td><code>^</code></td><td>power</td><td>binary</td><td align='center'>4</td><td>left</td></tr> 277<tr><td><code>*</code></td><td>multiplication</td><td>binary</td><td align='center'>3</td><td>left</td></tr> 278<tr><td><code>/</code></td><td>divison</td><td>binary</td><td align='center'>3</td><td>left</td></tr> 279<tr><td><code>+</code></td><td>addition</td><td>binary</td><td align='center'>2</td><td>left</td></tr> 280<tr><td><code>-</code></td><td>subtraction</td><td>binary</td><td align='center'>2</td><td>left</td></tr> 281<tr><td><code>,</code></td><td>argument delimiter</td><td>binary</td><td align='center'>1</td><td>left</td></tr> 282<caption class='top-caption'>A table of the expression operators and their precedence in the 283text-string format for mathematical expressions used by SBML_parseFormula(). 284</caption> 285</table> 286</center> 287 288 * <p> 289 * A program parsing a formula in an SBML model should assume that names 290 * appearing in the formula are the identifiers of {@link Species}, {@link Parameter}, 291 * {@link Compartment}, {@link FunctionDefinition}, {@link Reaction} (in SBML Levels 2 292 * and 3), or {@link SpeciesReference} (in SBML Level 3 only) objects 293 * defined in a model. When a function call is involved, the syntax 294 * consists of a function identifier, followed by optional white space, 295 * followed by an opening parenthesis, followed by a sequence of zero or 296 * more arguments separated by commas (with each comma optionally preceded 297 * and/or followed by zero or more white space characters), followed by a 298 * closing parenthesis. There is an almost one-to-one mapping between the 299 * list of predefined functions available, and those defined in MathML. 300 * All of the MathML functions are recognized; this set is larger than the 301 * functions defined in SBML Level 1. In the subset of functions that 302 * overlap between MathML and SBML Level 1, there exist a few 303 * differences. The following table summarizes the differences between the 304 * predefined functions in SBML Level 1 and the MathML equivalents in 305 * SBML Levels 2 and 3: 306 * <p> 307 * <center> 308<table border='0' class='text-table width80 normal-font alt-row-colors'> 309 <tr style='background: lightgray; font-size: 14px;'> 310 <th align='left'>Text string formula functions</th> 311 <th align='left'>MathML equivalents in SBML Levels 2 and 3</th> 312 </tr> 313 <tr><td><code>acos</code></td><td><code>arccos</code></td></tr> 314 <tr><td><code>asin</code></td><td><code>arcsin</code></td></tr> 315 <tr><td><code>atan</code></td><td><code>arctan</code></td></tr> 316 <tr><td><code>ceil</code></td><td><code>ceiling</code></td></tr> 317 <tr><td><code>log</code></td><td><code>ln</code></td></tr> 318 <tr><td><code>log10(x)</code></td><td><code>log(10, x)</code></td></tr> 319 <tr><td><code>pow(x, y)</code></td><td><code>power(x, y)</code></td></tr> 320 <tr><td><code>sqr(x)</code></td><td><code>power(x, 2)</code></td></tr> 321 <tr><td><code>sqrt(x)</code></td><td><code>root(2, x)</code></td></tr> 322<caption class='top-caption'>Table comparing the names of certain 323functions in the SBML text-string formula syntax and MathML. The left 324column shows the names of functions recognized by SBML_parseFormula(); the 325right column shows their equivalent function names in MathML 2.0, used 326in SBML Levels 2 and 3.</caption> 327</table> 328</center> 329 330 * <p> 331 * @warning We urge developers to keep in mind that the text-string formula syntax is 332specific to SBML Level 1's C-like mathematical formula syntax. In 333particular, it is <em>not a general-purpose mathematical expression 334syntax</em>. LibSBML provides methods for parsing and transforming 335text-string math formulas back and forth from AST structures, but it is 336important to keep the system's limitations in mind. 337 338 * <p> 339 * <p> 340 * <p> 341 * <p> 342 * @see <code><a href='libsbml.html#parseL3Formula(String formula)'>libsbml.parseL3Formula(String formula)</a></code> 343 * <p> 344 * <p> 345 * <p> 346 * @see <code><a href='libsbml.html#parseFormula(String formula)'>libsbml.parseFormula(String formula)</a></code> 347 */ 348 349public class ASTNode { 350 private long swigCPtr; 351 protected boolean swigCMemOwn; 352 353 protected ASTNode(long cPtr, boolean cMemoryOwn) 354 { 355 swigCMemOwn = cMemoryOwn; 356 swigCPtr = cPtr; 357 } 358 359 protected static long getCPtr(ASTNode obj) 360 { 361 return (obj == null) ? 0 : obj.swigCPtr; 362 } 363 364 protected static long getCPtrAndDisown (ASTNode obj) 365 { 366 long ptr = 0; 367 368 if (obj != null) 369 { 370 ptr = obj.swigCPtr; 371 obj.swigCMemOwn = false; 372 } 373 374 return ptr; 375 } 376 377 protected void finalize() { 378 delete(); 379 } 380 381 public synchronized void delete() { 382 if (swigCPtr != 0) { 383 if (swigCMemOwn) { 384 swigCMemOwn = false; 385 libsbmlJNI.delete_ASTNode(swigCPtr); 386 } 387 swigCPtr = 0; 388 } 389 } 390 391 /** 392 * Equality comparison method for ASTNode. 393 * <p> 394 * Because the Java methods for libSBML are actually wrappers around code 395 * implemented in C++ and C, certain operations will not behave as 396 * expected. Equality comparison is one such case. An instance of a 397 * libSBML object class is actually a <em>proxy object</em> 398 * wrapping the real underlying C/C++ object. The normal <code>==</code> 399 * equality operator in Java will <em>only compare the Java proxy objects</em>, 400 * not the underlying native object. The result is almost never what you 401 * want in practical situations. Unfortunately, Java does not provide a 402 * way to override <code>==</code>. 403 * <p> 404 * The alternative that must be followed is to use the 405 * <code>equals()</code> method. The <code>equals</code> method on this 406 * class overrides the default java.lang.Object one, and performs an 407 * intelligent comparison of instances of objects of this class. The 408 * result is an assessment of whether two libSBML Java objects are truly 409 * the same underlying native-code objects. 410 * <p> 411 * The use of this method in practice is the same as the use of any other 412 * Java <code>equals</code> method. For example, 413 * <em>a</em><code>.equals(</code><em>b</em><code>)</code> returns 414 * <code>true</code> if <em>a</em> and <em>b</em> are references to the 415 * same underlying object. 416 * 417 * @param sb a reference to an object to which the current object 418 * instance will be compared 419 * 420 * @return <code>true</code> if <code>sb</code> refers to the same underlying 421 * native object as this one, <code>false</code> otherwise 422 */ 423 public boolean equals(Object sb) 424 { 425 if ( this == sb ) 426 { 427 return true; 428 } 429 return swigCPtr == getCPtr((ASTNode)(sb)); 430 } 431 432 /** 433 * Returns a hashcode for this ASTNode object. 434 * 435 * @return a hash code usable by Java methods that need them. 436 */ 437 public int hashCode() 438 { 439 return (int)(swigCPtr^(swigCPtr>>>32)); 440 } 441 442 443/** 444 * Creates and returns a new {@link ASTNode}. 445 * <p> 446 * Unless the argument <code>type</code> is given, the returned node will by 447 * default have a type of {@link libsbmlConstants#AST_UNKNOWN 448 * AST_UNKNOWN}. If the type isn't supplied when caling this 449 * constructor, the caller should set the node type to something else as 450 * soon as possible using 451 * {@link ASTNode#setType(int)}. 452 * <p> 453 * @param type an optional 454 * type 455 * code indicating the type of node to create. 456 * <p> 457 * <!-- Don't remove the leading </dl> below. It's a hack for javadoc. --> 458</dl><dl class='docnote'><dt><b>Documentation note:</b></dt><dd> 459The native C++ implementation of this method defines a default argument 460value. In the documentation generated for different libSBML language 461bindings, you may or may not see corresponding arguments in the method 462declarations. For example, in Java and C#, a default argument is handled by 463declaring two separate methods, with one of them having the argument and 464the other one lacking the argument. However, the libSBML documentation will 465be <em>identical</em> for both methods. Consequently, if you are reading 466this and do not see an argument even though one is described, please look 467for descriptions of other variants of this method near where this one 468appears in the documentation. 469</dd></dl> 470 471 */ public 472 ASTNode(int type) { 473 this(libsbmlJNI.new_ASTNode__SWIG_0(type), true); 474 } 475 476 477/** 478 * Creates and returns a new {@link ASTNode}. 479 * <p> 480 * Unless the argument <code>type</code> is given, the returned node will by 481 * default have a type of {@link libsbmlConstants#AST_UNKNOWN 482 * AST_UNKNOWN}. If the type isn't supplied when caling this 483 * constructor, the caller should set the node type to something else as 484 * soon as possible using 485 * {@link ASTNode#setType(int)}. 486 * <p> 487 * @param type an optional 488 * type 489 * code indicating the type of node to create. 490 * <p> 491 * <!-- Don't remove the leading </dl> below. It's a hack for javadoc. --> 492</dl><dl class='docnote'><dt><b>Documentation note:</b></dt><dd> 493The native C++ implementation of this method defines a default argument 494value. In the documentation generated for different libSBML language 495bindings, you may or may not see corresponding arguments in the method 496declarations. For example, in Java and C#, a default argument is handled by 497declaring two separate methods, with one of them having the argument and 498the other one lacking the argument. However, the libSBML documentation will 499be <em>identical</em> for both methods. Consequently, if you are reading 500this and do not see an argument even though one is described, please look 501for descriptions of other variants of this method near where this one 502appears in the documentation. 503</dd></dl> 504 505 */ public 506 ASTNode() { 507 this(libsbmlJNI.new_ASTNode__SWIG_1(), true); 508 } 509 510 511/** 512 * Copy constructor; creates a deep copy of the given {@link ASTNode}. 513 * <p> 514 * @param orig the {@link ASTNode} to be copied. 515 */ public 516 ASTNode(ASTNode orig) { 517 this(libsbmlJNI.new_ASTNode__SWIG_2(ASTNode.getCPtr(orig), orig), true); 518 } 519 520 521/** 522 * Frees the name of this {@link ASTNode} and sets it to <code>null.</code> 523 * <p> 524 * This operation is only applicable to {@link ASTNode} objects corresponding to 525 * operators, numbers, or {@link libsbmlConstants#AST_UNKNOWN 526 * AST_UNKNOWN}. This method has no effect on other types of 527 * nodes. 528 * <p> 529 * @return integer value indicating success/failure of the 530 * function. The possible values returned by this function are: 531 * <ul> 532 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 533 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE } 534 * </ul> 535 */ public 536 int freeName() { 537 return libsbmlJNI.ASTNode_freeName(swigCPtr, this); 538 } 539 540 541/** 542 * Converts this {@link ASTNode} to a canonical form and returns <code>true</code> if 543 * successful, <code>false</code> otherwise. 544 * <p> 545 * The rules determining the canonical form conversion are as follows: 546 * <ul> 547 * <p> 548 * <li> If the node type is {@link libsbmlConstants#AST_NAME AST_NAME} 549 * and the node name matches <code>'ExponentialE'</code>, <code>'Pi'</code>, <code>'True'</code> or 550 * <code>'False'</code> the node type is converted to the corresponding 551 * <code>AST_CONSTANT_</code><em><span class='placeholder'>X</span></em> type. 552 * <p> 553 * <li> If the node type is an {@link libsbmlConstants#AST_FUNCTION 554 * AST_FUNCTION} and the node name matches an SBML (MathML) function name, logical operator name, or 555 * relational operator name, the node is converted to the corresponding 556 * <code>AST_FUNCTION_</code><em><span class='placeholder'>X</span></em> or 557 * <code>AST_LOGICAL_</code><em><span class='placeholder'>X</span></em> type. 558 * <p> 559 * </ul> 560 * <p> 561 * SBML Level 1 function names are searched first; thus, for 562 * example, canonicalizing <code>log</code> will result in a node type of {@link 563 * libsbmlConstants#AST_FUNCTION_LN AST_FUNCTION_LN}. (See the SBML 564 * Level 1 Version 2 Specification, Appendix C.) 565 * <p> 566 * Sometimes, canonicalization of a node results in a structural 567 * conversion of the node as a result of adding a child. For example, a 568 * node with the SBML Level 1 function name <code>sqr</code> and a single 569 * child node (the argument) will be transformed to a node of type 570 * {@link libsbmlConstants#AST_FUNCTION_POWER AST_FUNCTION_POWER} with 571 * two children. The first child will remain unchanged, but the second 572 * child will be an {@link ASTNode} of type {@link libsbmlConstants#AST_INTEGER 573 * AST_INTEGER} and a value of 2. The function names that result 574 * in structural changes are: <code>log10</code>, <code>sqr</code>, and <code>sqrt.</code> 575 */ public 576 boolean canonicalize() { 577 return libsbmlJNI.ASTNode_canonicalize(swigCPtr, this); 578 } 579 580 581/** 582 * Adds the given node as a child of this {@link ASTNode}. Child nodes are added 583 * in-order, from left to right. 584 * <p> 585 * @param child the {@link ASTNode} instance to add 586 * <p> 587 * @return integer value indicating success/failure of the 588 * function. The possible values returned by this function are: 589 * <ul> 590 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 591 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 592 * </ul> 593 * <p> 594 * @note Adding a child to an {@link ASTNode} may change the structure of the 595 * mathematical formula being represented by the tree structure, and may 596 * render the representation invalid. Callers need to be careful to use 597 * this method in the context of other operations to create complete and 598 * correct formulas. The method 599 * {@link ASTNode#isWellFormedASTNode()} 600 * may also be useful for checking the results of node modifications. 601 * <p> 602 * @see #prependChild(ASTNode child) 603 * @see #replaceChild(long n, ASTNode child) 604 * @see #insertChild(long n, ASTNode child) 605 * @see #removeChild(long n) 606 * @see #isWellFormedASTNode() 607 */ public 608 int addChild(ASTNode child) { 609 return libsbmlJNI.ASTNode_addChild(swigCPtr, this, ASTNode.getCPtrAndDisown(child), child); 610 } 611 612 613/** 614 * Adds the given node as a child of this {@link ASTNode}. This method adds 615 * child nodes from right to left. 616 * <p> 617 * @param child the {@link ASTNode} instance to add 618 * <p> 619 * @return integer value indicating success/failure of the 620 * function. The possible values returned by this function are: 621 * <ul> 622 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 623 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 624 * </ul> 625 * <p> 626 * @note Prepending a child to an {@link ASTNode} may change the structure of the 627 * mathematical formula being represented by the tree structure, and may 628 * render the representation invalid. 629 * <p> 630 * @see #addChild(ASTNode child) 631 * @see #replaceChild(long n, ASTNode child) 632 * @see #insertChild(long n, ASTNode child) 633 * @see #removeChild(long n) 634 */ public 635 int prependChild(ASTNode child) { 636 return libsbmlJNI.ASTNode_prependChild(swigCPtr, this, ASTNode.getCPtrAndDisown(child), child); 637 } 638 639 640/** 641 * Removes the nth child of this {@link ASTNode} object. 642 * <p> 643 * @param n long the index of the child to remove 644 * <p> 645 * @return integer value indicating success/failure of the 646 * function. The possible values returned by this function are: 647 * <ul> 648 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 649 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE } 650 * </ul> 651 * <p> 652 * @note Removing a child from an {@link ASTNode} may change the structure of the 653 * mathematical formula being represented by the tree structure, and may 654 * render the representation invalid. 655 * <p> 656 * @see #addChild(ASTNode child) 657 * @see #prependChild(ASTNode child) 658 * @see #replaceChild(long n, ASTNode child) 659 * @see #insertChild(long n, ASTNode child) 660 */ public 661 int removeChild(long n) { 662 return libsbmlJNI.ASTNode_removeChild(swigCPtr, this, n); 663 } 664 665 666/** 667 * Replaces the nth child of this {@link ASTNode} with the given {@link ASTNode}. 668 * <p> 669 * @param n long the index of the child to replace 670 * @param newChild {@link ASTNode} to replace the nth child 671 * <p> 672 * @return integer value indicating success/failure of the 673 * function. The possible values returned by this function are: 674 * <ul> 675 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 676 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE } 677 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT } 678 * </ul> 679 * <p> 680 * @note Replacing a child from an {@link ASTNode} may change the structure of the 681 * mathematical formula being represented by the tree structure, and may 682 * render the representation invalid. 683 * <p> 684 * @see #addChild(ASTNode child) 685 * @see #prependChild(ASTNode child) 686 * @see #insertChild(long n, ASTNode child) 687 * @see #removeChild(long n) 688 */ public 689 int replaceChild(long n, ASTNode newChild) { 690 return libsbmlJNI.ASTNode_replaceChild(swigCPtr, this, n, ASTNode.getCPtrAndDisown(newChild), newChild); 691 } 692 693 694/** 695 * Insert the given {@link ASTNode} at point n in the list of children 696 * of this {@link ASTNode}. 697 * <p> 698 * @param n long the index of the {@link ASTNode} being added 699 * @param newChild {@link ASTNode} to insert as the nth child 700 * <p> 701 * @return integer value indicating success/failure of the 702 * function. The possible values returned by this function are: 703 * <ul> 704 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 705 * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE } 706 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT } 707 * </ul> 708 * <p> 709 * @note Inserting a child into an {@link ASTNode} may change the structure of the 710 * mathematical formula being represented by the tree structure, and may 711 * render the representation invalid. 712 * <p> 713 * @see #addChild(ASTNode child) 714 * @see #prependChild(ASTNode child) 715 * @see #replaceChild(long n, ASTNode child) 716 * @see #removeChild(long n) 717 */ public 718 int insertChild(long n, ASTNode newChild) { 719 return libsbmlJNI.ASTNode_insertChild(swigCPtr, this, n, ASTNode.getCPtrAndDisown(newChild), newChild); 720 } 721 722 723/** 724 * Creates a recursive copy of this node and all its children. 725 * <p> 726 * @return a copy of this {@link ASTNode} and all its children. The caller owns 727 * the returned {@link ASTNode} and is reponsible for deleting it. 728 */ public 729 ASTNode deepCopy() { 730 long cPtr = libsbmlJNI.ASTNode_deepCopy(swigCPtr, this); 731 return (cPtr == 0) ? null : new ASTNode(cPtr, true); 732 } 733 734 735/** 736 * Get a child of this node according to its index number. 737 * <p> 738 * @param n the index of the child to get 739 * <p> 740 * @return the nth child of this {@link ASTNode} or <code>null</code> if this node has no nth 741 * child (<code>n > </code> 742 * {@link ASTNode#getNumChildren()} 743 * <code>- 1</code>). 744 */ public 745 ASTNode getChild(long n) { 746 long cPtr = libsbmlJNI.ASTNode_getChild(swigCPtr, this, n); 747 return (cPtr == 0) ? null : new ASTNode(cPtr, false); 748 } 749 750 751/** 752 * Get the left child of this node. 753 * <p> 754 * @return the left child of this {@link ASTNode}. This is equivalent to calling 755 * {@link ASTNode#getChild(long)} 756 * with an argument of <code>0.</code> 757 */ public 758 ASTNode getLeftChild() { 759 long cPtr = libsbmlJNI.ASTNode_getLeftChild(swigCPtr, this); 760 return (cPtr == 0) ? null : new ASTNode(cPtr, false); 761 } 762 763 764/** 765 * Get the right child of this node. 766 * <p> 767 * @return the right child of this {@link ASTNode}, or <code>null</code> if this node has no 768 * right child. If 769 * {@link ASTNode#getNumChildren()} 770 * <code>> 1</code>, then this is equivalent to: 771 * <div class='fragment'><pre> 772 * getChild( getNumChildren() - 1 );</pre></div> 773 */ public 774 ASTNode getRightChild() { 775 long cPtr = libsbmlJNI.ASTNode_getRightChild(swigCPtr, this); 776 return (cPtr == 0) ? null : new ASTNode(cPtr, false); 777 } 778 779 780/** 781 * Get the number of children that this node has. 782 * <p> 783 * @return the number of children of this {@link ASTNode}, or 0 is this node has 784 * no children. 785 */ public 786 long getNumChildren() { 787 return libsbmlJNI.ASTNode_getNumChildren(swigCPtr, this); 788 } 789 790 791/** 792 * Adds the given {@link XMLNode} as a <em>semantic annotation</em> of this {@link ASTNode}. 793 * <p> 794 * The <code><semantics></code> element is a MathML 2.0 construct 795that can be used to associate additional information with a MathML 796construct. The construct can be used to decorate a MathML expressions with 797a sequence of one or more <code><annotation></code> or 798<code><annotation-xml></code> elements. Each such element contains a 799pair of items; the first is a symbol that acts as an attribute or key, and 800the second is the value associated with the attribute or key. Please refer 801to the MathML 2.0 documentation, particularly the <a target='_blank' 802href='http://www.w3.org/TR/2007/WD-MathML3-20071005/chapter5.html#mixing.semantic.annotations'>Section 8035.2, Semantic Annotations</a> for more information about these constructs. 804 805 * <p> 806 * @param sAnnotation the annotation to add. 807 * <p> 808 * @return integer value indicating success/failure of the 809 * function. The possible values returned by this function are: 810 * <ul> 811 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 812 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 813 * </ul> 814 * <p> 815 * @note Although SBML permits the semantic annotation construct in 816 * MathML expressions, the truth is that this construct has so far (at 817 * this time of this writing, which is early 2011) seen very little use 818 * in SBML software. The full implications of using semantic annotations 819 * are still poorly understood. If you wish to use this construct, we 820 * urge you to discuss possible uses and applications on the SBML 821 * discussion lists, particularly <a target='_blank' 822 * href='http://sbml.org/Forums'>sbml-discuss@caltech.edu</a> and/or <a 823 * target='_blank' 824 * href='http://sbml.org/Forums'>sbml-interoperability@caltech.edu</a>. 825 */ public 826 int addSemanticsAnnotation(XMLNode sAnnotation) { 827 return libsbmlJNI.ASTNode_addSemanticsAnnotation(swigCPtr, this, XMLNode.getCPtrAndDisown(sAnnotation), sAnnotation); 828 } 829 830 831/** 832 * Get the number of <em>semantic annotation</em> elements inside this node. 833 * <p> 834 * The <code><semantics></code> element is a MathML 2.0 construct 835that can be used to associate additional information with a MathML 836construct. The construct can be used to decorate a MathML expressions with 837a sequence of one or more <code><annotation></code> or 838<code><annotation-xml></code> elements. Each such element contains a 839pair of items; the first is a symbol that acts as an attribute or key, and 840the second is the value associated with the attribute or key. Please refer 841to the MathML 2.0 documentation, particularly the <a target='_blank' 842href='http://www.w3.org/TR/2007/WD-MathML3-20071005/chapter5.html#mixing.semantic.annotations'>Section 8435.2, Semantic Annotations</a> for more information about these constructs. 844 845 * <p> 846 * @return the number of annotations of this {@link ASTNode}. 847 * <p> 848 * @see ASTNode#addSemanticsAnnotation(XMLNode sAnnotation) 849 */ public 850 long getNumSemanticsAnnotations() { 851 return libsbmlJNI.ASTNode_getNumSemanticsAnnotations(swigCPtr, this); 852 } 853 854 855/** 856 * Get the nth semantic annotation of this node. 857 * <p> 858 * The <code><semantics></code> element is a MathML 2.0 construct 859that can be used to associate additional information with a MathML 860construct. The construct can be used to decorate a MathML expressions with 861a sequence of one or more <code><annotation></code> or 862<code><annotation-xml></code> elements. Each such element contains a 863pair of items; the first is a symbol that acts as an attribute or key, and 864the second is the value associated with the attribute or key. Please refer 865to the MathML 2.0 documentation, particularly the <a target='_blank' 866href='http://www.w3.org/TR/2007/WD-MathML3-20071005/chapter5.html#mixing.semantic.annotations'>Section 8675.2, Semantic Annotations</a> for more information about these constructs. 868 869 * <p> 870 * @return the nth annotation of this {@link ASTNode}, or <code>null</code> if this node has 871 * no nth annotation (<code>n ></code> 872 * {@link ASTNode#getNumChildren()} 873 * <code>- 1</code>). 874 * <p> 875 * @see ASTNode#addSemanticsAnnotation(XMLNode sAnnotation) 876 */ public 877 XMLNode getSemanticsAnnotation(long n) { 878 long cPtr = libsbmlJNI.ASTNode_getSemanticsAnnotation(swigCPtr, this, n); 879 return (cPtr == 0) ? null : new XMLNode(cPtr, false); 880 } 881 882 883/** 884 * Get the value of this node as a single character. This function 885 * should be called only when 886 * {@link ASTNode#getType()} returns 887 * {@link libsbmlConstants#AST_PLUS AST_PLUS}, 888 * {@link libsbmlConstants#AST_MINUS AST_MINUS}, 889 * {@link libsbmlConstants#AST_TIMES AST_TIMES}, 890 * {@link libsbmlConstants#AST_DIVIDE AST_DIVIDE} or 891 * {@link libsbmlConstants#AST_POWER AST_POWER}. 892 * <p> 893 * @return the value of this {@link ASTNode} as a single character 894 */ public 895 char getCharacter() { 896 return libsbmlJNI.ASTNode_getCharacter(swigCPtr, this); 897 } 898 899 900/** 901 * Get the id of this {@link ASTNode}. 902 * <p> 903 * @return the mathml id of this {@link ASTNode}. 904 */ public 905 String getId() { 906 return libsbmlJNI.ASTNode_getId(swigCPtr, this); 907 } 908 909 910/** 911 * Get the class of this {@link ASTNode}. 912 * <p> 913 * @return the mathml class of this {@link ASTNode}. 914 */ public 915 String getClassName() { 916 return libsbmlJNI.ASTNode_getClassName(swigCPtr, this); 917 } 918 919 920/** 921 * Get the style of this {@link ASTNode}. 922 * <p> 923 * @return the mathml style of this {@link ASTNode}. 924 */ public 925 String getStyle() { 926 return libsbmlJNI.ASTNode_getStyle(swigCPtr, this); 927 } 928 929 930/** 931 * Get the value of this node as an integer. This function should be 932 * called only when 933 * {@link ASTNode#getType()} 934 * <code>== {@link libsbmlConstants#AST_INTEGER AST_INTEGER}</code>. 935 * <p> 936 * @return the value of this {@link ASTNode} as a (<code>long</code>) integer. 937 */ public 938 int getInteger() { 939 return libsbmlJNI.ASTNode_getInteger(swigCPtr, this); 940 } 941 942 943/** 944 * Get the value of this node as a string. This function may be called 945 * on nodes that (1) are not operators, i.e., nodes for which 946 * {@link ASTNode#isOperator()} 947 * returns <code>false</code>, and (2) are not numbers, i.e., 948 * {@link ASTNode#isNumber()} returns <code>false.</code> 949 * <p> 950 * @return the value of this {@link ASTNode} as a string. 951 */ public 952 String getName() { 953 return libsbmlJNI.ASTNode_getName(swigCPtr, this); 954 } 955 956 957/** 958 * Get the value of this operator node as a string. This function may be called 959 * on nodes that are operators, i.e., nodes for which 960 * {@link ASTNode#isOperator()} 961 * returns <code>true.</code> 962 * <p> 963 * @return the name of this operator {@link ASTNode} as a string (or null if not an operator). 964 */ public 965 String getOperatorName() { 966 return libsbmlJNI.ASTNode_getOperatorName(swigCPtr, this); 967 } 968 969 970/** 971 * Get the value of the numerator of this node. This function should be 972 * called only when 973 * {@link ASTNode#getType()} 974 * <code>== {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}</code>. 975 * <p> 976 * @return the value of the numerator of this {@link ASTNode}. 977 */ public 978 int getNumerator() { 979 return libsbmlJNI.ASTNode_getNumerator(swigCPtr, this); 980 } 981 982 983/** 984 * Get the value of the denominator of this node. This function should 985 * be called only when 986 * {@link ASTNode#getType()} 987 * <code>== {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}</code>. 988 * <p> 989 * @return the value of the denominator of this {@link ASTNode}. 990 */ public 991 int getDenominator() { 992 return libsbmlJNI.ASTNode_getDenominator(swigCPtr, this); 993 } 994 995 996/** 997 * Get the real-numbered value of this node. This function 998 * should be called only when 999 * {@link ASTNode#isReal()} 1000 * <code>== true</code>. 1001 * <p> 1002 * This function performs the necessary arithmetic if the node type is 1003 * {@link libsbmlConstants#AST_REAL_E AST_REAL_E} (<em>mantissa * 1004 * 10<sup> exponent</sup></em>) or {@link libsbmlConstants#AST_RATIONAL 1005 * AST_RATIONAL} (<em>numerator / denominator</em>). 1006 * <p> 1007 * @return the value of this {@link ASTNode} as a real (double). 1008 */ public 1009 double getReal() { 1010 return libsbmlJNI.ASTNode_getReal(swigCPtr, this); 1011 } 1012 1013 1014/** 1015 * Get the mantissa value of this node. This function should be called 1016 * only when {@link ASTNode#getType()} 1017 * returns {@link libsbmlConstants#AST_REAL_E AST_REAL_E} 1018 * or {@link libsbmlConstants#AST_REAL AST_REAL}. 1019 * If {@link ASTNode#getType()} 1020 * returns {@link libsbmlConstants#AST_REAL AST_REAL}, 1021 * this method is identical to 1022 * {@link ASTNode#getReal()}. 1023 * <p> 1024 * @return the value of the mantissa of this {@link ASTNode}. 1025 */ public 1026 double getMantissa() { 1027 return libsbmlJNI.ASTNode_getMantissa(swigCPtr, this); 1028 } 1029 1030 1031/** 1032 * Get the exponent value of this {@link ASTNode}. This function should be 1033 * called only when 1034 * {@link ASTNode#getType()} 1035 * returns {@link libsbmlConstants#AST_REAL_E AST_REAL_E} 1036 * or {@link libsbmlConstants#AST_REAL AST_REAL}. 1037 * <p> 1038 * @return the value of the exponent of this {@link ASTNode}. 1039 */ public 1040 int getExponent() { 1041 return libsbmlJNI.ASTNode_getExponent(swigCPtr, this); 1042 } 1043 1044 1045/** 1046 * Get the precedence of this node in the infix math syntax of SBML 1047 * Level 1. For more information about the infix syntax, see the 1048 * discussion about <a href='#math-convert'>text string formulas</a> at 1049 * the top of the documentation for {@link ASTNode}. 1050 * <p> 1051 * @return an integer indicating the precedence of this {@link ASTNode} 1052 */ public 1053 int getPrecedence() { 1054 return libsbmlJNI.ASTNode_getPrecedence(swigCPtr, this); 1055 } 1056 1057 1058/** 1059 * Get the type of this {@link ASTNode}. The value returned is one of the 1060 * enumeration values such as {@link libsbmlConstants#AST_LAMBDA 1061 * AST_LAMBDA}, {@link libsbmlConstants#AST_PLUS AST_PLUS}, 1062 * etc. 1063 * <p> 1064 * @return the type of this {@link ASTNode}. 1065 */ public 1066 int getType() { 1067 return libsbmlJNI.ASTNode_getType(swigCPtr, this); 1068 } 1069 1070 1071/** 1072 * Get the units of this {@link ASTNode}. 1073 * <p> 1074 * SBML Level 3 Version 1 introduced the ability to include an 1075attribute <code>sbml:units</code> on MathML <code>cn</code> elements 1076appearing in SBML mathematical formulas. The value of this attribute can 1077be used to indicate the unit of measurement to be associated with the 1078number in the content of the <code>cn</code> element. The value of this 1079attribute must be the identifier of a unit of measurement defined by SBML 1080or the enclosing {@link Model}. Here, the <code>sbml</code> portion is an XML 1081namespace prefix that must be associated with the SBML namespace for SBML 1082Level 3. The following example illustrates how this attribute can be 1083used to define a number with value <code>10</code> and unit of measurement 1084<code>second</code>: 1085<pre class='fragment'><math xmlns='http://www.w3.org/1998/Math/MathML' 1086 xmlns:sbml='http://www.sbml.org/sbml/level3/version1/core'> 1087 <cn type='integer' sbml:units='second'> 10 </cn> 1088</math> 1089</pre> 1090 1091 * <p> 1092 * @return the units of this {@link ASTNode}. 1093 * <p> 1094 * @note The <code>sbml:units</code> attribute is only available in SBML 1095 * Level 3. It may not be used in Levels 1–2 of SBML. 1096 * <p> 1097 * <p> 1098 * <p> 1099 * <p> 1100 * @see <code><a href='libsbml.html#parseL3Formula(String formula)'>libsbml.parseL3Formula(String formula)</a></code> 1101 */ public 1102 String getUnits() { 1103 return libsbmlJNI.ASTNode_getUnits(swigCPtr, this); 1104 } 1105 1106 1107/** 1108 * Predicate returning <code>true</code> (non-zero) if this node is the special 1109 * symbol <code>avogadro.</code> The predicate returns <code>false</code> (zero) otherwise. 1110 * <p> 1111 * @return <code>true</code> if this {@link ASTNode} is the special symbol avogadro. 1112 * <p> 1113 * <p> 1114 * <p> 1115 * <p> 1116 * @see <code><a href='libsbml.html#parseL3Formula(String formula)'>libsbml.parseL3Formula(String formula)</a></code> 1117 */ public 1118 boolean isAvogadro() { 1119 return libsbmlJNI.ASTNode_isAvogadro(swigCPtr, this); 1120 } 1121 1122 1123/** 1124 * Predicate returning <code>true</code> (non-zero) if this node has a boolean type 1125 * (a logical operator, a relational operator, or the constants <code>true</code> 1126 * or <code>false</code>). 1127 * <p> 1128 * @return true if this {@link ASTNode} is a boolean, false otherwise. 1129 */ public 1130 boolean isBoolean() { 1131 return libsbmlJNI.ASTNode_isBoolean(swigCPtr, this); 1132 } 1133 1134 1135/** 1136 * Predicate returning <code>true</code> (non-zero) if this node returns a boolean type 1137 * or <code>false</code> (zero) otherwise. 1138 * <p> 1139 * This function looks at the whole {@link ASTNode} rather than just the top 1140 * level of the {@link ASTNode}. Thus it will consider return values from 1141 * piecewise statements. In addition, if this {@link ASTNode} uses a function 1142 * call, the return value of the functionDefinition will be determined. 1143 * Note that this is only possible where the {@link ASTNode} can trace its parent 1144 * {@link Model}, that is, the {@link ASTNode} must represent the math element of some 1145 * SBML object that has already been added to an instance of an {@link SBMLDocument}. 1146 * <p> 1147 * @see #isBoolean() 1148 * <p> 1149 * @return true if this {@link ASTNode} returns a boolean, false otherwise. 1150 */ public 1151 boolean returnsBoolean(Model model) { 1152 return libsbmlJNI.ASTNode_returnsBoolean__SWIG_0(swigCPtr, this, Model.getCPtr(model), model); 1153 } 1154 1155 1156/** 1157 * Predicate returning <code>true</code> (non-zero) if this node returns a boolean type 1158 * or <code>false</code> (zero) otherwise. 1159 * <p> 1160 * This function looks at the whole {@link ASTNode} rather than just the top 1161 * level of the {@link ASTNode}. Thus it will consider return values from 1162 * piecewise statements. In addition, if this {@link ASTNode} uses a function 1163 * call, the return value of the functionDefinition will be determined. 1164 * Note that this is only possible where the {@link ASTNode} can trace its parent 1165 * {@link Model}, that is, the {@link ASTNode} must represent the math element of some 1166 * SBML object that has already been added to an instance of an {@link SBMLDocument}. 1167 * <p> 1168 * @see #isBoolean() 1169 * <p> 1170 * @return true if this {@link ASTNode} returns a boolean, false otherwise. 1171 */ public 1172 boolean returnsBoolean() { 1173 return libsbmlJNI.ASTNode_returnsBoolean__SWIG_1(swigCPtr, this); 1174 } 1175 1176 1177/** 1178 * Predicate returning <code>true</code> (non-zero) if this node represents a MathML 1179 * constant (e.g., <code>true</code>, <code>Pi</code>). 1180 * <p> 1181 * @return <code>true</code> if this {@link ASTNode} is a MathML constant, <code>false</code> otherwise. 1182 * <p> 1183 * @note this function will also return <code>true</code> for {@link 1184 * libsbmlConstants#AST_NAME_AVOGADRO AST_NAME_AVOGADRO} in SBML Level 3. 1185 */ public 1186 boolean isConstant() { 1187 return libsbmlJNI.ASTNode_isConstant(swigCPtr, this); 1188 } 1189 1190 1191/** 1192 * Predicate returning <code>true</code> (non-zero) if this node represents a 1193 * MathML function (e.g., <code>abs()</code>), or an SBML Level 1 1194 * function, or a user-defined function. 1195 * <p> 1196 * @return <code>true</code> if this {@link ASTNode} is a function, <code>false</code> otherwise. 1197 */ public 1198 boolean isFunction() { 1199 return libsbmlJNI.ASTNode_isFunction(swigCPtr, this); 1200 } 1201 1202 1203/** 1204 * Predicate returning <code>true</code> (non-zero) if this node represents 1205 * the special IEEE 754 value infinity, <code>false</code> (zero) otherwise. 1206 * <p> 1207 * @return <code>true</code> if this {@link ASTNode} is the special IEEE 754 value infinity, 1208 * <code>false</code> otherwise. 1209 */ public 1210 boolean isInfinity() { 1211 return libsbmlJNI.ASTNode_isInfinity(swigCPtr, this); 1212 } 1213 1214 1215/** 1216 * Predicate returning <code>true</code> (non-zero) if this node contains an 1217 * integer value, <code>false</code> (zero) otherwise. 1218 * <p> 1219 * @return <code>true</code> if this {@link ASTNode} is of type {@link 1220 * libsbmlConstants#AST_INTEGER AST_INTEGER}, <code>false</code> otherwise. 1221 */ public 1222 boolean isInteger() { 1223 return libsbmlJNI.ASTNode_isInteger(swigCPtr, this); 1224 } 1225 1226 1227/** 1228 * Predicate returning <code>true</code> (non-zero) if this node is a MathML 1229 * <code><lambda></code>, <code>false</code> (zero) otherwise. 1230 * <p> 1231 * @return <code>true</code> if this {@link ASTNode} is of type {@link libsbmlConstants#AST_LAMBDA 1232 * AST_LAMBDA}, <code>false</code> otherwise. 1233 */ public 1234 boolean isLambda() { 1235 return libsbmlJNI.ASTNode_isLambda(swigCPtr, this); 1236 } 1237 1238 1239/** 1240 * Predicate returning <code>true</code> (non-zero) if this node represents a 1241 * <code>log10</code> function, <code>false</code> (zero) otherwise. More precisely, this 1242 * predicate returns <code>true</code> if the node type is {@link 1243 * libsbmlConstants#AST_FUNCTION_LOG AST_FUNCTION_LOG} with two 1244 * children, the first of which is an {@link libsbmlConstants#AST_INTEGER 1245 * AST_INTEGER} equal to 10. 1246 * <p> 1247 * @return <code>true</code> if the given {@link ASTNode} represents a log10() function, 1248 * <code>false</code> otherwise. 1249 * <p> 1250 * <p> 1251 * <p> 1252 * <p> 1253 * @see <code><a href='libsbml.html#parseL3Formula(String formula)'>libsbml.parseL3Formula(String formula)</a></code> 1254 */ public 1255 boolean isLog10() { 1256 return libsbmlJNI.ASTNode_isLog10(swigCPtr, this); 1257 } 1258 1259 1260/** 1261 * Predicate returning <code>true</code> (non-zero) if this node is a MathML 1262 * logical operator (i.e., <code>and</code>, <code>or</code>, <code>not</code>, <code>xor</code>). 1263 * <p> 1264 * @return <code>true</code> if this {@link ASTNode} is a MathML logical operator 1265 */ public 1266 boolean isLogical() { 1267 return libsbmlJNI.ASTNode_isLogical(swigCPtr, this); 1268 } 1269 1270 1271/** 1272 * Predicate returning <code>true</code> (non-zero) if this node is a user-defined 1273 * variable name in SBML L1, L2 (MathML), or the special symbols <code>delay</code> 1274 * or <code>time.</code> The predicate returns <code>false</code> (zero) otherwise. 1275 * <p> 1276 * @return <code>true</code> if this {@link ASTNode} is a user-defined variable name in SBML 1277 * L1, L2 (MathML) or the special symbols delay or time. 1278 */ public 1279 boolean isName() { 1280 return libsbmlJNI.ASTNode_isName(swigCPtr, this); 1281 } 1282 1283 1284/** 1285 * Predicate returning <code>true</code> (non-zero) if this node represents the 1286 * special IEEE 754 value 'not a number' (NaN), <code>false</code> (zero) 1287 * otherwise. 1288 * <p> 1289 * @return <code>true</code> if this {@link ASTNode} is the special IEEE 754 NaN. 1290 */ public 1291 boolean isNaN() { 1292 return libsbmlJNI.ASTNode_isNaN(swigCPtr, this); 1293 } 1294 1295 1296/** 1297 * Predicate returning <code>true</code> (non-zero) if this node represents the 1298 * special IEEE 754 value 'negative infinity', <code>false</code> (zero) otherwise. 1299 * <p> 1300 * @return <code>true</code> if this {@link ASTNode} is the special IEEE 754 value negative 1301 * infinity, <code>false</code> otherwise. 1302 */ public 1303 boolean isNegInfinity() { 1304 return libsbmlJNI.ASTNode_isNegInfinity(swigCPtr, this); 1305 } 1306 1307 1308/** 1309 * Predicate returning <code>true</code> (non-zero) if this node contains a number, 1310 * <code>false</code> (zero) otherwise. This is functionally equivalent to the 1311 * following code: 1312 * <div class='fragment'><pre> 1313 * isInteger() || isReal()</pre></div> 1314 * <p> 1315 * @return <code>true</code> if this {@link ASTNode} is a number, <code>false</code> otherwise. 1316 */ public 1317 boolean isNumber() { 1318 return libsbmlJNI.ASTNode_isNumber(swigCPtr, this); 1319 } 1320 1321 1322/** 1323 * Predicate returning <code>true</code> (non-zero) if this node is a mathematical 1324 * operator, meaning, <code>+</code>, <code>-</code>, <code>*</code>, 1325 * <code>/</code> or <code>^</code> (power). 1326 * <p> 1327 * @return <code>true</code> if this {@link ASTNode} is an operator. 1328 */ public 1329 boolean isOperator() { 1330 return libsbmlJNI.ASTNode_isOperator(swigCPtr, this); 1331 } 1332 1333 1334/** 1335 * Predicate returning <code>true</code> (non-zero) if this node is the MathML 1336 * <code><piecewise></code> construct, <code>false</code> (zero) otherwise. 1337 * <p> 1338 * @return <code>true</code> if this {@link ASTNode} is a MathML <code>piecewise</code> function 1339 */ public 1340 boolean isPiecewise() { 1341 return libsbmlJNI.ASTNode_isPiecewise(swigCPtr, this); 1342 } 1343 1344 1345/** 1346 * Predicate returning <code>true</code> (non-zero) if this node represents a rational 1347 * number, <code>false</code> (zero) otherwise. 1348 * <p> 1349 * @return <code>true</code> if this {@link ASTNode} is of type {@link 1350 * libsbmlConstants#AST_RATIONAL AST_RATIONAL}. 1351 */ public 1352 boolean isRational() { 1353 return libsbmlJNI.ASTNode_isRational(swigCPtr, this); 1354 } 1355 1356 1357/** 1358 * Predicate returning <code>true</code> (non-zero) if this node can represent a 1359 * real number, <code>false</code> (zero) otherwise. More precisely, this node 1360 * must be of one of the following types: {@link libsbmlConstants#AST_REAL 1361 * AST_REAL}, {@link libsbmlConstants#AST_REAL_E AST_REAL_E} or 1362 * {@link libsbmlConstants#AST_RATIONAL AST_RATIONAL}. 1363 * <p> 1364 * @return <code>true</code> if the value of this {@link ASTNode} can represented as a real 1365 * number, <code>false</code> otherwise. 1366 */ public 1367 boolean isReal() { 1368 return libsbmlJNI.ASTNode_isReal(swigCPtr, this); 1369 } 1370 1371 1372/** 1373 * Predicate returning <code>true</code> (non-zero) if this node is a MathML 1374 * relational operator, meaning <code>==</code>, <code>>=</code>, 1375 * <code>></code>, <code><</code>, and <code>!=</code>. 1376 * <p> 1377 * @return <code>true</code> if this {@link ASTNode} is a MathML relational operator, 1378 * <code>false</code> otherwise 1379 */ public 1380 boolean isRelational() { 1381 return libsbmlJNI.ASTNode_isRelational(swigCPtr, this); 1382 } 1383 1384 1385/** 1386 * Predicate returning <code>true</code> (non-zero) if this node represents a 1387 * square root function, <code>false</code> (zero) otherwise. More precisely, the 1388 * node type must be {@link libsbmlConstants#AST_FUNCTION_ROOT 1389 * AST_FUNCTION_ROOT} with two children, the first of which is an 1390 * {@link libsbmlConstants#AST_INTEGER AST_INTEGER} node having value 1391 * equal to 2. 1392 * <p> 1393 * @return <code>true</code> if the given {@link ASTNode} represents a sqrt() function, 1394 * <code>false</code> otherwise. 1395 */ public 1396 boolean isSqrt() { 1397 return libsbmlJNI.ASTNode_isSqrt(swigCPtr, this); 1398 } 1399 1400 1401/** 1402 * Predicate returning <code>true</code> (non-zero) if this node is a unary minus 1403 * operator, <code>false</code> (zero) otherwise. A node is defined as a unary 1404 * minus node if it is of type {@link libsbmlConstants#AST_MINUS 1405 * AST_MINUS} and has exactly one child. 1406 * <p> 1407 * For numbers, unary minus nodes can be 'collapsed' by negating the 1408 * number. In fact, 1409 * <code><a href='libsbml.html#parseFormula(java.lang.String)'>libsbml.parseFormula(String formula)</a></code> 1410 * does this during its parsing process, and 1411 * <code><a href='libsbml.html#parseL3Formula(java.lang.String)'>libsbml.parseL3Formula(String formula)</a></code> 1412 * has a configuration option that allows this behavior to be turned 1413 * on or off. However, unary minus nodes for symbols 1414 * ({@link libsbmlConstants#AST_NAME AST_NAME}) cannot 1415 * be 'collapsed', so this predicate function is necessary. 1416 * <p> 1417 * @return <code>true</code> if this {@link ASTNode} is a unary minus, <code>false</code> otherwise. 1418 * <p> 1419 * <p> 1420 * <p> 1421 * <p> 1422 * @see <code><a href='libsbml.html#parseL3Formula(String formula)'>libsbml.parseL3Formula(String formula)</a></code> 1423 */ public 1424 boolean isUMinus() { 1425 return libsbmlJNI.ASTNode_isUMinus(swigCPtr, this); 1426 } 1427 1428 1429/** 1430 * Predicate returning <code>true</code> (non-zero) if this node is a unary plus 1431 * operator, <code>false</code> (zero) otherwise. A node is defined as a unary 1432 * minus node if it is of type {@link libsbmlConstants#AST_MINUS 1433 * AST_MINUS} and has exactly one child. 1434 * <p> 1435 * @return <code>true</code> if this {@link ASTNode} is a unary plus, <code>false</code> otherwise. 1436 */ public 1437 boolean isUPlus() { 1438 return libsbmlJNI.ASTNode_isUPlus(swigCPtr, this); 1439 } 1440 1441 1442/** 1443 * Predicate returning <code>true</code> (non-zero) if this node has an unknown type. 1444 * <p> 1445 * 'Unknown' nodes have the type {@link libsbmlConstants#AST_UNKNOWN 1446 * AST_UNKNOWN}. Nodes with unknown types will not appear in an 1447 * {@link ASTNode} tree returned by libSBML based upon valid SBML input; the only 1448 * situation in which a node with type {@link libsbmlConstants#AST_UNKNOWN 1449 * AST_UNKNOWN} may appear is immediately after having create a 1450 * new, untyped node using the {@link ASTNode} constructor. Callers creating 1451 * nodes should endeavor to set the type to a valid node type as soon as 1452 * possible after creating new nodes. 1453 * <p> 1454 * @return <code>true</code> if this {@link ASTNode} is of type {@link 1455 * libsbmlConstants#AST_UNKNOWN AST_UNKNOWN}, <code>false</code> otherwise. 1456 */ public 1457 boolean isUnknown() { 1458 return libsbmlJNI.ASTNode_isUnknown(swigCPtr, this); 1459 } 1460 1461 1462/** 1463 * Predicate returning <code>true</code> (non-zero) if this node has the mathml attribute 1464 * <code>id</code>. 1465 * <p> 1466 * @return true if this {@link ASTNode} has an attribute id, false otherwise. 1467 */ public 1468 boolean isSetId() { 1469 return libsbmlJNI.ASTNode_isSetId(swigCPtr, this); 1470 } 1471 1472 1473/** 1474 * Predicate returning <code>true</code> (non-zero) if this node has the mathml attribute 1475 * <code>class</code>. 1476 * <p> 1477 * @return true if this {@link ASTNode} has an attribute class, false otherwise. 1478 */ public 1479 boolean isSetClass() { 1480 return libsbmlJNI.ASTNode_isSetClass(swigCPtr, this); 1481 } 1482 1483 1484/** 1485 * Predicate returning <code>true</code> (non-zero) if this node has the mathml attribute 1486 * <code>style</code>. 1487 * <p> 1488 * @return true if this {@link ASTNode} has an attribute style, false otherwise. 1489 */ public 1490 boolean isSetStyle() { 1491 return libsbmlJNI.ASTNode_isSetStyle(swigCPtr, this); 1492 } 1493 1494 1495/** 1496 * Predicate returning <code>true</code> (non-zero) if this node has the attribute 1497 * <code>sbml:units</code>. 1498 * <p> 1499 * SBML Level 3 Version 1 introduced the ability to include an 1500attribute <code>sbml:units</code> on MathML <code>cn</code> elements 1501appearing in SBML mathematical formulas. The value of this attribute can 1502be used to indicate the unit of measurement to be associated with the 1503number in the content of the <code>cn</code> element. The value of this 1504attribute must be the identifier of a unit of measurement defined by SBML 1505or the enclosing {@link Model}. Here, the <code>sbml</code> portion is an XML 1506namespace prefix that must be associated with the SBML namespace for SBML 1507Level 3. The following example illustrates how this attribute can be 1508used to define a number with value <code>10</code> and unit of measurement 1509<code>second</code>: 1510<pre class='fragment'><math xmlns='http://www.w3.org/1998/Math/MathML' 1511 xmlns:sbml='http://www.sbml.org/sbml/level3/version1/core'> 1512 <cn type='integer' sbml:units='second'> 10 </cn> 1513</math> 1514</pre> 1515 1516 * <p> 1517 * @return <code>true</code> if this {@link ASTNode} has units associated with it, <code>false</code> otherwise. 1518 * <p> 1519 * @note The <code>sbml:units</code> attribute is only available in SBML 1520 * Level 3. It may not be used in Levels 1–2 of SBML. 1521 */ public 1522 boolean isSetUnits() { 1523 return libsbmlJNI.ASTNode_isSetUnits(swigCPtr, this); 1524 } 1525 1526 1527/** 1528 * Predicate returning <code>true</code> (non-zero) if this node or any of its 1529 * children nodes have the attribute <code>sbml:units</code>. 1530 * <p> 1531 * SBML Level 3 Version 1 introduced the ability to include an 1532attribute <code>sbml:units</code> on MathML <code>cn</code> elements 1533appearing in SBML mathematical formulas. The value of this attribute can 1534be used to indicate the unit of measurement to be associated with the 1535number in the content of the <code>cn</code> element. The value of this 1536attribute must be the identifier of a unit of measurement defined by SBML 1537or the enclosing {@link Model}. Here, the <code>sbml</code> portion is an XML 1538namespace prefix that must be associated with the SBML namespace for SBML 1539Level 3. The following example illustrates how this attribute can be 1540used to define a number with value <code>10</code> and unit of measurement 1541<code>second</code>: 1542<pre class='fragment'><math xmlns='http://www.w3.org/1998/Math/MathML' 1543 xmlns:sbml='http://www.sbml.org/sbml/level3/version1/core'> 1544 <cn type='integer' sbml:units='second'> 10 </cn> 1545</math> 1546</pre> 1547 1548 * <p> 1549 * @return <code>true</code> if this {@link ASTNode} or its children has units associated 1550 * with it, <code>false</code> otherwise. 1551 * <p> 1552 * @note The <code>sbml:units</code> attribute is only available in SBML 1553 * Level 3. It may not be used in Levels 1–2 of SBML. 1554 */ public 1555 boolean hasUnits() { 1556 return libsbmlJNI.ASTNode_hasUnits(swigCPtr, this); 1557 } 1558 1559 1560/** 1561 * Sets the value of this {@link ASTNode} to the given character. If character 1562 * is one of <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code> or <code>^</code>, the node 1563 * type will be set accordingly. For all other characters, the node type 1564 * will be set to {@link libsbmlConstants#AST_UNKNOWN AST_UNKNOWN}. 1565 * <p> 1566 * @param value the character value to which the node's value should be 1567 * set. 1568 * <p> 1569 * @return integer value indicating success/failure of the function. The 1570 * possible values returned by this function are: 1571 * <ul> 1572 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1573 * </ul> 1574 */ public 1575 int setCharacter(char value) { 1576 return libsbmlJNI.ASTNode_setCharacter(swigCPtr, this, value); 1577 } 1578 1579 1580/** 1581 * Sets the mathml id of this {@link ASTNode} to id. 1582 * <p> 1583 * @param id <code>string</code> representing the identifier. 1584 * <p> 1585 * @return integer value indicating success/failure of the 1586 * function. The possible values returned by this function are: 1587 * <ul> 1588 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1589 * </ul> 1590 */ public 1591 int setId(String id) { 1592 return libsbmlJNI.ASTNode_setId(swigCPtr, this, id); 1593 } 1594 1595 1596/** 1597 * Sets the mathml class of this {@link ASTNode} to className. 1598 * <p> 1599 * @param className <code>string</code> representing the mathml class for this node. 1600 * <p> 1601 * @return integer value indicating success/failure of the 1602 * function. The possible values returned by this function are: 1603 * <ul> 1604 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1605 * </ul> 1606 */ public 1607 int setClassName(String className) { 1608 return libsbmlJNI.ASTNode_setClassName(swigCPtr, this, className); 1609 } 1610 1611 1612/** 1613 * Sets the mathml style of this {@link ASTNode} to style. 1614 * <p> 1615 * @param style <code>string</code> representing the identifier. 1616 * <p> 1617 * @return integer value indicating success/failure of the 1618 * function. The possible values returned by this function are: 1619 * <ul> 1620 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1621 * </ul> 1622 */ public 1623 int setStyle(String style) { 1624 return libsbmlJNI.ASTNode_setStyle(swigCPtr, this, style); 1625 } 1626 1627 1628/** 1629 * Sets the value of this {@link ASTNode} to the given name. 1630 * <p> 1631 * As a side-effect, this {@link ASTNode} object's type will be reset to 1632 * {@link libsbmlConstants#AST_NAME AST_NAME} if (and <em>only 1633 * if</em>) the {@link ASTNode} was previously an operator ( 1634 * {@link ASTNode#isOperator()} 1635 * <code>== true</code>), number ( 1636 * {@link ASTNode#isNumber()} 1637 * <code>== true</code>), or unknown. 1638 * This allows names to be set for {@link libsbmlConstants#AST_FUNCTION 1639 * AST_FUNCTION} nodes and the like. 1640 * <p> 1641 * @param name the string containing the name to which this node's value 1642 * should be set 1643 * <p> 1644 * @return integer value indicating success/failure of the function. The 1645 * possible values returned by this function are: 1646 * <ul> 1647 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1648 * </ul> 1649 */ public 1650 int setName(String name) { 1651 return libsbmlJNI.ASTNode_setName(swigCPtr, this, name); 1652 } 1653 1654 1655/** 1656 * Sets the value of this {@link ASTNode} to the given (<code>long</code>) integer and sets 1657 * the node type to {@link libsbmlConstants#AST_INTEGER AST_INTEGER}. 1658 * <p> 1659 * @param value the integer to which this node's value should be set 1660 * <p> 1661 * @return integer value indicating success/failure of the function. The 1662 * possible values returned by this function are: 1663 * <ul> 1664 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1665 * </ul> 1666 */ public 1667 int setValue(int value) { 1668 return libsbmlJNI.ASTNode_setValue__SWIG_0(swigCPtr, this, value); 1669 } 1670 1671 1672/** 1673 * Sets the value of this {@link ASTNode} to the given rational in two parts: the 1674 * numerator and denominator. The node type is set to {@link 1675 * libsbmlConstants#AST_RATIONAL AST_RATIONAL}. 1676 * <p> 1677 * @param numerator the numerator value of the rational 1678 * @param denominator the denominator value of the rational 1679 * <p> 1680 * @return integer value indicating success/failure of the function. The 1681 * possible values returned by this function are: 1682 * <ul> 1683 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1684 * </ul> 1685 */ public 1686 int setValue(int numerator, int denominator) { 1687 return libsbmlJNI.ASTNode_setValue__SWIG_1(swigCPtr, this, numerator, denominator); 1688 } 1689 1690 1691/** 1692 * Sets the value of this {@link ASTNode} to the given real (<code>double</code>) and sets 1693 * the node type to {@link libsbmlConstants#AST_REAL AST_REAL}. 1694 * <p> 1695 * This is functionally equivalent to: 1696 * <div class='fragment'><pre> 1697 * setValue(value, 0);</pre></div> 1698 * <p> 1699 * @param value the <code>double</code> format number to which this node's value 1700 * should be set 1701 * <p> 1702 * @return integer value indicating success/failure of the function. The 1703 * possible values returned by this function are: @li {@link 1704 * libsbmlConstants#LIBSBML_OPERATION_SUCCESS 1705 * LIBSBML_OPERATION_SUCCESS } 1706 */ public 1707 int setValue(double value) { 1708 return libsbmlJNI.ASTNode_setValue__SWIG_2(swigCPtr, this, value); 1709 } 1710 1711 1712/** 1713 * Sets the value of this {@link ASTNode} to the given real (<code>double</code>) in two 1714 * parts: the mantissa and the exponent. The node type is set to 1715 * {@link libsbmlConstants#AST_REAL_E AST_REAL_E}. 1716 * <p> 1717 * @param mantissa the mantissa of this node's real-numbered value 1718 * @param exponent the exponent of this node's real-numbered value 1719 * <p> 1720 * @return integer value indicating success/failure of the 1721 * function. The possible values returned by this function are: 1722 * <ul> 1723 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1724 * </ul> 1725 */ public 1726 int setValue(double mantissa, int exponent) { 1727 return libsbmlJNI.ASTNode_setValue__SWIG_3(swigCPtr, this, mantissa, exponent); 1728 } 1729 1730 1731/** 1732 * Sets the type of this {@link ASTNode} to the given type code. A side-effect 1733 * of doing this is that any numerical values previously stored in this 1734 * node are reset to zero. 1735 * <p> 1736 * @param type the type to which this node should be set 1737 * <p> 1738 * @return integer value indicating success/failure of the 1739 * function. The possible values returned by this function are: 1740 * <ul> 1741 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1742 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE } 1743 * </ul> 1744 */ public 1745 int setType(int type) { 1746 return libsbmlJNI.ASTNode_setType(swigCPtr, this, type); 1747 } 1748 1749 1750/** 1751 * Sets the units of this {@link ASTNode} to units. 1752 * <p> 1753 * The units will be set <em>only</em> if this {@link ASTNode} object represents a 1754 * MathML <code><cn></code> element, i.e., represents a number. 1755 * Callers may use 1756 * {@link ASTNode#isNumber()} 1757 * to inquire whether the node is of that type. 1758 * <p> 1759 * SBML Level 3 Version 1 introduced the ability to include an 1760attribute <code>sbml:units</code> on MathML <code>cn</code> elements 1761appearing in SBML mathematical formulas. The value of this attribute can 1762be used to indicate the unit of measurement to be associated with the 1763number in the content of the <code>cn</code> element. The value of this 1764attribute must be the identifier of a unit of measurement defined by SBML 1765or the enclosing {@link Model}. Here, the <code>sbml</code> portion is an XML 1766namespace prefix that must be associated with the SBML namespace for SBML 1767Level 3. The following example illustrates how this attribute can be 1768used to define a number with value <code>10</code> and unit of measurement 1769<code>second</code>: 1770<pre class='fragment'><math xmlns='http://www.w3.org/1998/Math/MathML' 1771 xmlns:sbml='http://www.sbml.org/sbml/level3/version1/core'> 1772 <cn type='integer' sbml:units='second'> 10 </cn> 1773</math> 1774</pre> 1775 1776 * <p> 1777 * @param units <code>string</code> representing the unit identifier. 1778 * <p> 1779 * @return integer value indicating success/failure of the 1780 * function. The possible values returned by this function are: 1781 * <ul> 1782 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1783 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE } 1784 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE } 1785 * </ul> 1786 * <p> 1787 * @note The <code>sbml:units</code> attribute is only available in SBML 1788 * Level 3. It may not be used in Levels 1–2 of SBML. 1789 */ public 1790 int setUnits(String units) { 1791 return libsbmlJNI.ASTNode_setUnits(swigCPtr, this, units); 1792 } 1793 1794 1795/** 1796 * Swap the children of this {@link ASTNode} object with the children of the 1797 * given {@link ASTNode} object. 1798 * <p> 1799 * @param that the other node whose children should be used to replace 1800 * <em>this</em> node's children 1801 * <p> 1802 * @return integer value indicating success/failure of the 1803 * function. The possible values returned by this function are: 1804 * <ul> 1805 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1806 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 1807 * </ul> 1808 */ public 1809 int swapChildren(ASTNode that) { 1810 return libsbmlJNI.ASTNode_swapChildren(swigCPtr, this, ASTNode.getCPtr(that), that); 1811 } 1812 1813 1814/** 1815 * Renames all the SIdRef attributes on this node and any child node 1816 */ public 1817 void renameSIdRefs(String oldid, String newid) { 1818 libsbmlJNI.ASTNode_renameSIdRefs(swigCPtr, this, oldid, newid); 1819 } 1820 1821 1822/** 1823 * Renames all the UnitSIdRef attributes on this node and any child node. 1824 * (The only place UnitSIDRefs appear in MathML <code><cn></code> elements.) 1825 */ public 1826 void renameUnitSIdRefs(String oldid, String newid) { 1827 libsbmlJNI.ASTNode_renameUnitSIdRefs(swigCPtr, this, oldid, newid); 1828 } 1829 1830 1831/** 1832 * Replace any nodes of type AST_NAME with the name 'id' from the child 'math' object with the provided {@link ASTNode}. 1833 * <p> 1834 * @internal 1835 */ public 1836 void replaceIDWithFunction(String id, ASTNode function) { 1837 libsbmlJNI.ASTNode_replaceIDWithFunction(swigCPtr, this, id, ASTNode.getCPtr(function), function); 1838 } 1839 1840 1841/** 1842 * Replaces any 'AST_NAME_TIME' nodes with a node that multiplies time by the given function. 1843 * <p> 1844 * @internal 1845 */ public 1846 void multiplyTimeBy(ASTNode function) { 1847 libsbmlJNI.ASTNode_multiplyTimeBy(swigCPtr, this, ASTNode.getCPtr(function), function); 1848 } 1849 1850 1851/** 1852 * Unsets the units of this {@link ASTNode}. 1853 * <p> 1854 * @return integer value indicating success/failure of the 1855 * function. The possible values returned by this function are: 1856 * <ul> 1857 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1858 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE } 1859 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 1860 * </ul> 1861 */ public 1862 int unsetUnits() { 1863 return libsbmlJNI.ASTNode_unsetUnits(swigCPtr, this); 1864 } 1865 1866 1867/** 1868 * Unsets the mathml id of this {@link ASTNode}. 1869 * <p> 1870 * @return integer value indicating success/failure of the 1871 * function. The possible values returned by this function are: 1872 * <ul> 1873 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1874 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 1875 * </ul> 1876 */ public 1877 int unsetId() { 1878 return libsbmlJNI.ASTNode_unsetId(swigCPtr, this); 1879 } 1880 1881 1882/** 1883 * Unsets the mathml class of this {@link ASTNode}. 1884 * <p> 1885 * @return integer value indicating success/failure of the 1886 * function. The possible values returned by this function are: 1887 * <ul> 1888 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1889 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 1890 * </ul> 1891 */ public 1892 int unsetClass() { 1893 return libsbmlJNI.ASTNode_unsetClass(swigCPtr, this); 1894 } 1895 1896 1897/** 1898 * Unsets the mathml style of this {@link ASTNode}. 1899 * <p> 1900 * @return integer value indicating success/failure of the 1901 * function. The possible values returned by this function are: 1902 * <ul> 1903 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS } 1904 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED } 1905 * </ul> 1906 */ public 1907 int unsetStyle() { 1908 return libsbmlJNI.ASTNode_unsetStyle(swigCPtr, this); 1909 } 1910 1911 1912/** 1913 * Gets the MathML <code>definitionURL</code> attribute value. 1914 * <p> 1915 * @return the value of the <code>definitionURL</code> attribute, in the form of 1916 * a libSBML {@link XMLAttributes} object. 1917 */ public 1918 XMLAttributes getDefinitionURL() { 1919 long cPtr = libsbmlJNI.ASTNode_getDefinitionURL(swigCPtr, this); 1920 return (cPtr == 0) ? null : new XMLAttributes(cPtr, false); 1921 } 1922 1923 1924/** 1925 * Replaces occurences of a given name within this {@link ASTNode} with the 1926 * name/value/formula represented by <code>arg</code>. 1927 * <p> 1928 * For example, if the formula in this {@link ASTNode} is <code>x + y</code>, 1929 * then the <code><bvar></code> is <code>x</code> and <code>arg</code> is an {@link ASTNode} 1930 * representing the real value <code>3.</code> This method substitutes <code>3</code> for 1931 * <code>x</code> within this {@link ASTNode} object. 1932 * <p> 1933 * @param bvar a string representing the variable name to be substituted 1934 * @param arg an {@link ASTNode} representing the name/value/formula to substitute 1935 */ public 1936 void replaceArgument(String bvar, ASTNode arg) { 1937 libsbmlJNI.ASTNode_replaceArgument(swigCPtr, this, bvar, ASTNode.getCPtr(arg), arg); 1938 } 1939 1940 1941/** 1942 * Returns the parent SBML object. 1943 * <p> 1944 * @return the parent SBML object of this {@link ASTNode}. 1945 */ public 1946 SBase getParentSBMLObject() { 1947 return libsbml.DowncastSBase(libsbmlJNI.ASTNode_getParentSBMLObject(swigCPtr, this), false); 1948} 1949 1950 1951/** 1952 * Reduces this {@link ASTNode} to a binary tree. 1953 * <p> 1954 * Example: if this {@link ASTNode} is <code>and(x, y, z)</code>, then the 1955 * formula of the reduced node is <code>and(and(x, y), z)</code>. The 1956 * operation replaces the formula stored in the current {@link ASTNode} object. 1957 */ public 1958 void reduceToBinary() { 1959 libsbmlJNI.ASTNode_reduceToBinary(swigCPtr, this); 1960 } 1961 1962 1963/** 1964 * Predicate returning <code>true</code> or <code>false</code> depending on whether this 1965 * {@link ASTNode} is well-formed. 1966 * <p> 1967 * @note An {@link ASTNode} may be well-formed, with each node and its children 1968 * having the appropriate number of children for the given type, but may 1969 * still be invalid in the context of its use within an SBML model. 1970 * <p> 1971 * @return <code>true</code> if this {@link ASTNode} is well-formed, <code>false</code> otherwise. 1972 * <p> 1973 * @see #hasCorrectNumberArguments() 1974 */ public 1975 boolean isWellFormedASTNode() { 1976 return libsbmlJNI.ASTNode_isWellFormedASTNode(swigCPtr, this); 1977 } 1978 1979 1980/** 1981 * Predicate returning <code>true</code> or <code>false</code> depending on whether this 1982 * {@link ASTNode} has the correct number of children for it's type. 1983 * <p> 1984 * For example, an {@link ASTNode} with type {@link libsbmlConstants#AST_PLUS 1985 * AST_PLUS} expects 2 child nodes. 1986 * <p> 1987 * @note This function performs a check on the toplevel node only. 1988 * Child nodes are not checked. 1989 * <p> 1990 * @return <code>true</code> if this {@link ASTNode} is has appropriate number of children 1991 * for it's type, <code>false</code> otherwise. 1992 * <p> 1993 * @see #isWellFormedASTNode() 1994 */ public 1995 boolean hasCorrectNumberArguments() { 1996 return libsbmlJNI.ASTNode_hasCorrectNumberArguments(swigCPtr, this); 1997 } 1998 1999 2000/** 2001 * Predicate returning <code>true</code> or <code>false</code> depending on whether this 2002 * {@link ASTNode} has the correct number of children for it's type. 2003 * <p> 2004 * For example, an {@link ASTNode} with type {@link libsbmlConstants#AST_PLUS 2005 * AST_PLUS} expects 2 child nodes. 2006 * <p> 2007 * @note This function performs a check on the toplevel node only. 2008 * Child nodes are not checked. 2009 * <p> 2010 * @return <code>true</code> if this {@link ASTNode} is has appropriate number of children 2011 * for it's type, <code>false</code> otherwise. 2012 * <p> 2013 * @see #isWellFormedASTNode() 2014 * @internal 2015 */ public 2016 boolean isBvar() { 2017 return libsbmlJNI.ASTNode_isBvar(swigCPtr, this); 2018 } 2019 2020 2021/** 2022 * Predicate returning <code>true</code> or <code>false</code> depending on whether this 2023 * {@link ASTNode} has the correct number of children for it's type. 2024 * <p> 2025 * For example, an {@link ASTNode} with type {@link libsbmlConstants#AST_PLUS 2026 * AST_PLUS} expects 2 child nodes. 2027 * <p> 2028 * @note This function performs a check on the toplevel node only. 2029 * Child nodes are not checked. 2030 * <p> 2031 * @return <code>true</code> if this {@link ASTNode} is has appropriate number of children 2032 * for it's type, <code>false</code> otherwise. 2033 * <p> 2034 * @see #isWellFormedASTNode() 2035 * @internal 2036 */ public 2037 void setBvar() { 2038 libsbmlJNI.ASTNode_setBvar(swigCPtr, this); 2039 } 2040 2041 public ASTNodeList getListOfNodes() { 2042 long cPtr = libsbmlJNI.ASTNode_getListOfNodes(swigCPtr, this); 2043 return (cPtr == 0) ? null : new ASTNodeList(cPtr, true); 2044 } 2045 2046}