001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.12 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * A single unit referenced in an SBML <em>unit definition</em>. 013 <p> 014 * The SBML unit definition facility uses two classes of objects, 015 * {@link UnitDefinition} and {@link Unit}. The approach to defining units in SBML is 016 * compositional; for example, <em>meter second<sup> –2</sup></em> is 017 * constructed by combining a {@link Unit} object representing <em>meter</em> with 018 * another {@link Unit} object representing <em>second<sup> –2</sup></em>. 019 * The combination is wrapped inside a {@link UnitDefinition}, which provides for 020 * assigning an identifier and optional name to the combination. The 021 * identifier can then be referenced from elsewhere in a model. Thus, the 022 * {@link UnitDefinition} class is the container, and {@link Unit} instances are placed 023 * inside {@link UnitDefinition} instances. 024 <p> 025 * A {@link Unit} has four attributes named 'kind', 'exponent', 'scale' 026 * and 'multiplier'. It represents a (possibly transformed) reference to a 027 * base unit. The attribute 'kind' on {@link Unit} indicates the chosen base unit. 028 * Its value must be one of the text strings listed below; this list 029 * corresponds to SBML Level 3: 030 <p> 031 * <p> 032<table border='0' class='centered text-table width80 normal-font code' 033 style='border: none !important'> 034<tr> 035<td>ampere</td><td>farad</td><td>joule</td><td>lux</td><td>radian</td><td>volt</td> 036</tr> 037<tr> 038<td>avogadro</td><td>gram</td><td>katal</td><td>metre</td><td>second</td><td>watt</td> 039</tr> 040<tr> 041<td>becquerel</td><td>gray</td><td>kelvin</td><td>mole</td><td>siemens</td><td>weber</td> 042</tr> 043<tr> 044<td>candela</td><td>henry</td><td>kilogram</td><td>newton</td><td>sievert</td> 045</tr> 046<tr> 047<td>coulomb</td><td>hertz</td><td>litre</td><td>ohm</td><td>steradian</td> 048</tr> 049<tr> 050<td>dimensionless</td><td>item</td><td>lumen</td><td>pascal</td><td>tesla</td> 051</tr> 052</table> 053 <p> 054 * A few small differences exist between the Level 3 list of base 055 * units and the list defined in other Level/Version combinations of SBML. 056 * Specifically, Levels of SBML before Level 3 do not define 057 * <code>avogadro</code>; conversely, Level 2 Version 1 defines <code>Celsius</code>, 058 * and Level 1 defines <code>celsius</code>, <code>meter</code>, and <code>liter</code>, none of 059 * which are available in Level 3. In libSBML, each of the predefined 060 * base unit names is represented by an enumeration value whose name begins with the characters 061 * <code>UNIT_KIND_</code>, discussed in a separate section below. 062 <p> 063 * The attribute named 'exponent' on {@link Unit} represents an exponent on the 064 * unit. In SBML Level 2, the attribute is optional and has a default 065 * value of <code>1</code> (one); in SBML Level 3, the attribute is mandatory 066 * and there is no default value. A {@link Unit} also has an attribute 067 * called 'scale'; its value must be an integer exponent for a power-of-ten 068 * multiplier used to set the scale of the unit. For example, a unit 069 * having a 'kind' value of <code>gram</code> and a 'scale' value of <code>-3</code> signifies 070 * 10<sup> –3</sup> × gram, or milligrams. In SBML 071 * Level 2, the attribute is optional and has a default value of <code>0</code> 072 * (zero), because 10<sup> 0</sup> = 1; in SBML Level 3, the attribute 073 * is mandatory and has no default value. Lastly, the attribute named 074 * 'multiplier' can be used to multiply the unit by a real-numbered factor; 075 * this enables the definition of units that are not power-of-ten multiples 076 * of SI units. For instance, a multiplier of 0.3048 could be used to 077 * define <code>foot</code> as a measure of length in terms of a <code>metre.</code> The 078 * 'multiplier' attribute is optional in SBML Level 2, where it has a 079 * default value of <code>1</code> (one); in SBML Level 3, the attribute is 080 * mandatory and has no default value. 081 <p> 082 * * <h3><a class='anchor' name='UnitKind_t'>Unit identification codes</a></h3> 083 <p> 084 * As discussed above, SBML defines a set of base units which serves as the 085 * starting point for new unit definitions. This set of base units 086 * consists of the SI units and a small number of additional convenience 087 * units. 088 <p> 089 * In SBML Level 2 Versions before 090 * Version 3, there existed an enumeration of units called 091 * <code>UnitKind.</code> In Version 3, this enumeration was removed and the 092 * identifier class <code>UnitSId</code> redefined to include the previous 093 * <code>UnitKind</code> values as reserved symbols. This change has no net effect on 094 * permissible models, their representation or their syntax. The purpose 095 * of the change in the SBML specification was simply to clean up an 096 * inconsistency about the contexts in which these values were usable. 097 * However, libSBML maintains UnitKind in the form of of a set of static 098 * integer constants whose names begin with the characters 099 * <code>UNIT_KIND_</code>. These constants are defined in the class 100 * <code><a href='libsbmlConstants.html'>libsbmlConstants</a></code>. 101 <p> 102 * As a consequence of the fact that libSBML supports models in all Levels 103 * and Versions of SBML, libSBML's set of <code>UNIT_KIND_</code> values is a union 104 * of all the possible base unit names defined in the different SBML 105 * specifications. However, not every base unit is allowed in every 106 * Level+Version combination of SBML. Note in particular the following 107 * exceptions: 108 * <ul> 109 * <li> The alternate spelling <code>'meter'</code> is included in 110 * addition to the official SI spelling <code>'metre'.</code> This spelling is only 111 * permitted in SBML Level 1 models. 112 <p> 113 * <li> The alternate spelling <code>'liter'</code> is included in addition to the 114 * official SI spelling <code>'litre'.</code> This spelling is only permitted in 115 * SBML Level 1 models. 116 <p> 117 * <li> The unit <code>'Celsius'</code> is included because of its presence in 118 * specifications of SBML prior to SBML Level 2 Version 2. 119 <p> 120 * <li> The unit <code>avogadro</code> was introduced in SBML Level 3, and 121 * is only permitted for use in SBML Level 3 models. 122 * </ul> 123 <p> 124 * The table below lists the unit 125 * constants defined in libSBML, and their meanings. 126 <p> 127 * <table border="0" class="centered text-table width80 normal-font alt-row-colors"> 128 <tr> 129 <th align="left" width="200">Enumerator</th> 130 <th align="left">Meaning</th> 131 </tr> 132<tr><td><code>UNIT_KIND_AMPERE</code></td><td>The ampere unit.</td></tr> 133<tr><td><code>UNIT_KIND_AVOGADRO</code></td><td>The unit 134<code>dimensionless</code> multiplied by the numerical value of Avogadro's 135constant. (<span class="warning">Only usable in SBML Level 3 models.</span>)</td></tr> 136<tr><td><code>UNIT_KIND_BECQUEREL</code></td><td>The becquerel unit.</td></tr> 137<tr><td><code>UNIT_KIND_CANDELA</code></td><td>The candela unit.</td></tr> 138<tr><td><code>UNIT_KIND_CELSIUS</code></td><td>The Celsius unit. (<span 139class="warning">Only usable in SBML Level 1 and SBML Level 2 140Version 1 models.</span>)</td></tr> 141<tr><td><code>UNIT_KIND_COULOMB</code></td><td>The coulomb unit.</td></tr> 142<tr><td><code>UNIT_KIND_DIMENSIONLESS</code></td><td>A pseudo-unit 143indicating a dimensionless quantity.</td></tr> 144<tr><td><code>UNIT_KIND_FARAD</code></td><td>The farad unit.</td></tr> 145<tr><td><code>UNIT_KIND_GRAM</code></td><td>The gram unit.</td></tr> 146<tr><td><code>UNIT_KIND_GRAY</code></td><td>The gray unit.</td></tr> 147<tr><td><code>UNIT_KIND_HENRY</code></td><td>The henry unit.</td></tr> 148<tr><td><code>UNIT_KIND_HERTZ</code></td><td>The hertz unit.</td></tr> 149<tr><td><code>UNIT_KIND_ITEM</code></td><td>A pseudo-unit representing a 150single "thing".</td></tr> 151<tr><td><code>UNIT_KIND_JOULE</code></td><td>The joule unit.</td></tr> 152<tr><td><code>UNIT_KIND_KATAL</code></td><td>The katal unit.</td></tr> 153<tr><td><code>UNIT_KIND_KELVIN</code></td><td>The kelvin unit.</td></tr> 154<tr><td><code>UNIT_KIND_KILOGRAM</code></td><td>The kilogram unit.</td></tr> 155<tr><td><code>UNIT_KIND_LITER</code></td><td>Alternate spelling of litre.</td></tr> 156<tr><td><code>UNIT_KIND_LITRE</code></td><td>The litre unit.</td></tr> 157<tr><td><code>UNIT_KIND_LUMEN</code></td><td>The lumen unit.</td></tr> 158<tr><td><code>UNIT_KIND_LUX</code></td><td>The lux unit.</td></tr> 159<tr><td><code>UNIT_KIND_METER</code></td><td>Alternate spelling of metre.</td></tr> 160<tr><td><code>UNIT_KIND_METRE</code></td><td>The metre unit.</td></tr> 161<tr><td><code>UNIT_KIND_MOLE</code></td><td>The mole unit.</td></tr> 162<tr><td><code>UNIT_KIND_NEWTON</code></td><td>The newton unit.</td></tr> 163<tr><td><code>UNIT_KIND_OHM</code></td><td>The ohm unit.</td></tr> 164<tr><td><code>UNIT_KIND_PASCAL</code></td><td>The pascal unit.</td></tr> 165<tr><td><code>UNIT_KIND_RADIAN</code></td><td>The radian unit.</td></tr> 166<tr><td><code>UNIT_KIND_SECOND</code></td><td>The second unit.</td></tr> 167<tr><td><code>UNIT_KIND_SIEMENS</code></td><td>The siemens unit.</td></tr> 168<tr><td><code>UNIT_KIND_SIEVERT</code></td><td>The sievert unit.</td></tr> 169<tr><td><code>UNIT_KIND_STERADIAN</code></td><td>The steradian unit.</td></tr> 170<tr><td><code>UNIT_KIND_TESLA</code></td><td>The tesla unit.</td></tr> 171<tr><td><code>UNIT_KIND_VOLT</code></td><td>The volt unit.</td></tr> 172<tr><td><code>UNIT_KIND_WATT</code></td><td>The watt unit.</td></tr> 173<tr><td><code>UNIT_KIND_WEBER</code></td><td>The weber unit.</td></tr> 174<tr><td><code>UNIT_KIND_INVALID</code></td><td>Marker used by libSBML 175to indicate an invalid or unset unit.</td></tr> 176</table> 177 178 179 */ 180 181public class Unit extends SBase { 182 private long swigCPtr; 183 184 protected Unit(long cPtr, boolean cMemoryOwn) 185 { 186 super(libsbmlJNI.Unit_SWIGUpcast(cPtr), cMemoryOwn); 187 swigCPtr = cPtr; 188 } 189 190 protected static long getCPtr(Unit obj) 191 { 192 return (obj == null) ? 0 : obj.swigCPtr; 193 } 194 195 protected static long getCPtrAndDisown (Unit obj) 196 { 197 long ptr = 0; 198 199 if (obj != null) 200 { 201 ptr = obj.swigCPtr; 202 obj.swigCMemOwn = false; 203 } 204 205 return ptr; 206 } 207 208 protected void finalize() { 209 delete(); 210 } 211 212 public synchronized void delete() { 213 if (swigCPtr != 0) { 214 if (swigCMemOwn) { 215 swigCMemOwn = false; 216 libsbmlJNI.delete_Unit(swigCPtr); 217 } 218 swigCPtr = 0; 219 } 220 super.delete(); 221 } 222 223 224/** 225 * Creates a new {@link Unit} using the given SBML <code>level</code> and <code>version</code> 226 * values. 227 <p> 228 * @param level a long integer, the SBML Level to assign to this {@link Unit}. 229 <p> 230 * @param version a long integer, the SBML Version to assign to this 231 * {@link Unit}. 232 <p> 233 * <p> 234 * @throws SBMLConstructorException 235 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid 236 * or if this object is incompatible with the given level and version. 237 <p> 238 * <p> 239 * @note Attempting to add an object to an {@link SBMLDocument} having a different 240 * combination of SBML Level, Version and XML namespaces than the object 241 * itself will result in an error at the time a caller attempts to make the 242 * addition. A parent object must have compatible Level, Version and XML 243 * namespaces. (Strictly speaking, a parent may also have more XML 244 * namespaces than a child, but the reverse is not permitted.) The 245 * restriction is necessary to ensure that an SBML model has a consistent 246 * overall structure. This requires callers to manage their objects 247 * carefully, but the benefit is increased flexibility in how models can be 248 * created by permitting callers to create objects bottom-up if desired. In 249 * situations where objects are not yet attached to parents (e.g., 250 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 251 * libSBML determine such things as whether it is valid to assign a 252 * particular value to an attribute. 253 */ public 254 Unit(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 255 this(libsbmlJNI.new_Unit__SWIG_0(level, version), true); 256 } 257 258 259/** 260 * Creates a new {@link Unit} using the given {@link SBMLNamespaces} object 261 * <code>sbmlns</code>. 262 <p> 263 * <p> 264 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces 265 * information. It is used to communicate the SBML Level, Version, and (in 266 * Level 3) packages used in addition to SBML Level 3 Core. A 267 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an 268 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object 269 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments. 270 <p> 271 * @param sbmlns an {@link SBMLNamespaces} object. 272 <p> 273 * <p> 274 * @throws SBMLConstructorException 275 * Thrown if the given <code>sbmlns</code> is inconsistent or incompatible 276 * with this object. 277 <p> 278 * <p> 279 * @note Attempting to add an object to an {@link SBMLDocument} having a different 280 * combination of SBML Level, Version and XML namespaces than the object 281 * itself will result in an error at the time a caller attempts to make the 282 * addition. A parent object must have compatible Level, Version and XML 283 * namespaces. (Strictly speaking, a parent may also have more XML 284 * namespaces than a child, but the reverse is not permitted.) The 285 * restriction is necessary to ensure that an SBML model has a consistent 286 * overall structure. This requires callers to manage their objects 287 * carefully, but the benefit is increased flexibility in how models can be 288 * created by permitting callers to create objects bottom-up if desired. In 289 * situations where objects are not yet attached to parents (e.g., 290 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 291 * libSBML determine such things as whether it is valid to assign a 292 * particular value to an attribute. 293 */ public 294 Unit(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException { 295 this(libsbmlJNI.new_Unit__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 296 } 297 298 299/** 300 * Copy constructor; creates a copy of this {@link Unit}. 301 <p> 302 * @param orig the object to copy. 303 */ public 304 Unit(Unit orig) throws org.sbml.libsbml.SBMLConstructorException { 305 this(libsbmlJNI.new_Unit__SWIG_2(Unit.getCPtr(orig), orig), true); 306 } 307 308 309/** 310 * Creates and returns a deep copy of this {@link Unit} object. 311 <p> 312 * @return the (deep) copy of this {@link Unit} object. 313 */ public 314 Unit cloneObject() { 315 long cPtr = libsbmlJNI.Unit_cloneObject(swigCPtr, this); 316 return (cPtr == 0) ? null : new Unit(cPtr, true); 317 } 318 319 320/** 321 * Initializes the fields of this {@link Unit} object to 'typical' default 322 * values. 323 <p> 324 * The SBML {@link Unit} component has slightly different aspects and default 325 * attribute values in different SBML Levels and Versions. This method 326 * sets the values to certain common defaults, based mostly on what they 327 * are in SBML Level 2. Specifically: 328 * <ul> 329 * <li> Sets attribute 'exponent' to <code>1</code> 330 * <li> Sets attribute 'scale' to <code>0</code> 331 * <li> Sets attribute 'multiplier' to <code>1.0</code> 332 * </ul> 333 <p> 334 * The 'kind' attribute is left unchanged. 335 */ public 336 void initDefaults() { 337 libsbmlJNI.Unit_initDefaults(swigCPtr, this); 338 } 339 340 341/** 342 * Returns the 'kind' of {@link Unit} this is. 343 <p> 344 * @return the value of the 'kind' attribute of this {@link Unit} as a 345 * value from the set of constants whose names begin 346 * with <code>UNIT_KIND_</code> defined in the class 347 * <code><a href='libsbmlConstants.html'>libsbmlConstants</a></code>. 348 */ public 349 int getKind() { 350 return libsbmlJNI.Unit_getKind(swigCPtr, this); 351 } 352 353 354/** 355 * Returns the value of the 'exponent' attribute of this unit. 356 <p> 357 * @return the 'exponent' value of this {@link Unit}, as an integer. 358 */ public 359 int getExponent() { 360 return libsbmlJNI.Unit_getExponent(swigCPtr, this); 361 } 362 363 364/** 365 * Returns the value of the 'exponent' attribute of this unit. 366 <p> 367 * @return the 'exponent' value of this {@link Unit}, as a double. 368 */ public 369 double getExponentAsDouble() { 370 return libsbmlJNI.Unit_getExponentAsDouble(swigCPtr, this); 371 } 372 373 374/** 375 * Returns the value of the 'scale' attribute of this unit. 376 <p> 377 * @return the 'scale' value of this {@link Unit}, as an integer. 378 */ public 379 int getScale() { 380 return libsbmlJNI.Unit_getScale(swigCPtr, this); 381 } 382 383 384/** 385 * Returns the value of the 'multiplier' attribute of this {@link Unit}. 386 <p> 387 * @return the 'multiplier' value of this {@link Unit}, as a double. 388 */ public 389 double getMultiplier() { 390 return libsbmlJNI.Unit_getMultiplier(swigCPtr, this); 391 } 392 393 394/** 395 * Returns the value of the 'offset' attribute of this {@link Unit}. 396 <p> 397 * @return the 'offset' value of this {@link Unit}, as a double. 398 <p> 399 * <p> 400 * @warning <span class='warning'>The 'offset' attribute is only available in 401 * SBML Level 2 Version 1. This attribute is not present in SBML 402 * Level 2 Version 2 or above. When producing SBML models using 403 * these later specifications, modelers and software tools need to account 404 * for units with offsets explicitly. The SBML specification document 405 * offers a number of suggestions for how to achieve this. LibSBML methods 406 * such as this one related to 'offset' are retained for compatibility with 407 * earlier versions of SBML Level 2, but their use is strongly 408 * discouraged.</span> 409 */ public 410 double getOffset() { 411 return libsbmlJNI.Unit_getOffset(swigCPtr, this); 412 } 413 414 415/** 416 * Predicate for testing whether this {@link Unit} is of the kind <code>ampere.</code> 417 <p> 418 * @return <code>true</code> if the kind of this {@link Unit} is <code>ampere</code>, <code>false</code> 419 * otherwise. 420 */ public 421 boolean isAmpere() { 422 return libsbmlJNI.Unit_isAmpere(swigCPtr, this); 423 } 424 425 426/** 427 * Predicate for testing whether this {@link Unit} is of the kind <code>avogadro.</code> 428 <p> 429 * @return <code>true</code> if the kind of this {@link Unit} is <code>avogadro</code>, <code>false</code> 430 * otherwise. 431 <p> 432 * @note The unit <code>avogadro</code> was introduced in SBML Level 3, and 433 * is only permitted for use in SBML Level 3 models. 434 */ public 435 boolean isAvogadro() { 436 return libsbmlJNI.Unit_isAvogadro(swigCPtr, this); 437 } 438 439 440/** 441 * Predicate for testing whether this {@link Unit} is of the kind <code>becquerel</code> 442 <p> 443 * @return <code>true</code> if the kind of this {@link Unit} is <code>becquerel</code>, <code>false</code> 444 * otherwise. 445 */ public 446 boolean isBecquerel() { 447 return libsbmlJNI.Unit_isBecquerel(swigCPtr, this); 448 } 449 450 451/** 452 * Predicate for testing whether this {@link Unit} is of the kind <code>candela</code> 453 <p> 454 * @return <code>true</code> if the kind of this {@link Unit} is <code>candela</code>, <code>false</code> 455 * otherwise. 456 */ public 457 boolean isCandela() { 458 return libsbmlJNI.Unit_isCandela(swigCPtr, this); 459 } 460 461 462/** 463 * Predicate for testing whether this {@link Unit} is of the kind <code>Celsius</code> 464 <p> 465 * @return <code>true</code> if the kind of this {@link Unit} is <code>Celsius</code>, <code>false</code> 466 * otherwise. 467 <p> 468 * @warning <span class='warning'>The predefined unit <code>Celsius</code> was 469 * removed from the list of predefined units in SBML Level 2 470 * Version 2 at the same time that the 'offset' attribute was removed 471 * from {@link Unit} definitions. LibSBML methods such as this one related to 472 * <code>Celsius</code> are retained in order to support SBML Level 2 473 * Version 1, but their use is strongly discouraged.</span> 474 */ public 475 boolean isCelsius() { 476 return libsbmlJNI.Unit_isCelsius(swigCPtr, this); 477 } 478 479 480/** 481 * Predicate for testing whether this {@link Unit} is of the kind <code>coulomb</code> 482 <p> 483 * @return <code>true</code> if the kind of this {@link Unit} is <code>coulomb</code>, <code>false</code> 484 * otherwise. 485 */ public 486 boolean isCoulomb() { 487 return libsbmlJNI.Unit_isCoulomb(swigCPtr, this); 488 } 489 490 491/** 492 * Predicate for testing whether this {@link Unit} is of the kind 493 * <code>dimensionless.</code> 494 <p> 495 * @return <code>true</code> if the kind of this {@link Unit} is <code>dimensionless</code>, <code>false</code> 496 * otherwise. 497 */ public 498 boolean isDimensionless() { 499 return libsbmlJNI.Unit_isDimensionless(swigCPtr, this); 500 } 501 502 503/** 504 * Predicate for testing whether this {@link Unit} is of the kind <code>farad</code> 505 <p> 506 * @return <code>true</code> if the kind of this {@link Unit} is <code>farad</code>, <code>false</code> 507 * otherwise. 508 */ public 509 boolean isFarad() { 510 return libsbmlJNI.Unit_isFarad(swigCPtr, this); 511 } 512 513 514/** 515 * Predicate for testing whether this {@link Unit} is of the kind <code>gram</code> 516 <p> 517 * @return <code>true</code> if the kind of this {@link Unit} is <code>gram</code>, <code>false</code> 518 * otherwise. 519 */ public 520 boolean isGram() { 521 return libsbmlJNI.Unit_isGram(swigCPtr, this); 522 } 523 524 525/** 526 * Predicate for testing whether this {@link Unit} is of the kind <code>gray</code> 527 <p> 528 * @return <code>true</code> if the kind of this {@link Unit} is <code>gray</code>, <code>false</code> 529 * otherwise. 530 */ public 531 boolean isGray() { 532 return libsbmlJNI.Unit_isGray(swigCPtr, this); 533 } 534 535 536/** 537 * Predicate for testing whether this {@link Unit} is of the kind <code>henry</code> 538 <p> 539 * @return <code>true</code> if the kind of this {@link Unit} is <code>henry</code>, <code>false</code> 540 * otherwise. 541 */ public 542 boolean isHenry() { 543 return libsbmlJNI.Unit_isHenry(swigCPtr, this); 544 } 545 546 547/** 548 * Predicate for testing whether this {@link Unit} is of the kind <code>hertz</code> 549 <p> 550 * @return <code>true</code> if the kind of this {@link Unit} is <code>hertz</code>, <code>false</code> 551 * otherwise. 552 */ public 553 boolean isHertz() { 554 return libsbmlJNI.Unit_isHertz(swigCPtr, this); 555 } 556 557 558/** 559 * Predicate for testing whether this {@link Unit} is of the kind <code>item</code> 560 <p> 561 * @return <code>true</code> if the kind of this {@link Unit} is <code>item</code>, <code>false</code> 562 * otherwise. 563 */ public 564 boolean isItem() { 565 return libsbmlJNI.Unit_isItem(swigCPtr, this); 566 } 567 568 569/** 570 * Predicate for testing whether this {@link Unit} is of the kind <code>joule</code> 571 <p> 572 * @return <code>true</code> if the kind of this {@link Unit} is <code>joule</code>, <code>false</code> 573 * otherwise. 574 */ public 575 boolean isJoule() { 576 return libsbmlJNI.Unit_isJoule(swigCPtr, this); 577 } 578 579 580/** 581 * Predicate for testing whether this {@link Unit} is of the kind <code>katal</code> 582 <p> 583 * @return <code>true</code> if the kind of this {@link Unit} is <code>katal</code>, <code>false</code> 584 * otherwise. 585 */ public 586 boolean isKatal() { 587 return libsbmlJNI.Unit_isKatal(swigCPtr, this); 588 } 589 590 591/** 592 * Predicate for testing whether this {@link Unit} is of the kind <code>kelvin</code> 593 <p> 594 * @return <code>true</code> if the kind of this {@link Unit} is <code>kelvin</code>, <code>false</code> 595 * otherwise. 596 */ public 597 boolean isKelvin() { 598 return libsbmlJNI.Unit_isKelvin(swigCPtr, this); 599 } 600 601 602/** 603 * Predicate for testing whether this {@link Unit} is of the kind <code>kilogram</code> 604 <p> 605 * @return <code>true</code> if the kind of this {@link Unit} is <code>kilogram</code>, <code>false</code> 606 * otherwise. 607 */ public 608 boolean isKilogram() { 609 return libsbmlJNI.Unit_isKilogram(swigCPtr, this); 610 } 611 612 613/** 614 * Predicate for testing whether this {@link Unit} is of the kind <code>litre</code> 615 <p> 616 * @return <code>true</code> if the kind of this {@link Unit} is <code>litre</code> or 'liter', 617 * <code>false</code> otherwise. 618 */ public 619 boolean isLitre() { 620 return libsbmlJNI.Unit_isLitre(swigCPtr, this); 621 } 622 623 624/** 625 * Predicate for testing whether this {@link Unit} is of the kind <code>lumen</code> 626 <p> 627 * @return <code>true</code> if the kind of this {@link Unit} is <code>lumen</code>, <code>false</code> 628 * otherwise. 629 */ public 630 boolean isLumen() { 631 return libsbmlJNI.Unit_isLumen(swigCPtr, this); 632 } 633 634 635/** 636 * Predicate for testing whether this {@link Unit} is of the kind <code>lux</code> 637 <p> 638 * @return <code>true</code> if the kind of this {@link Unit} is <code>lux</code>, <code>false</code> 639 * otherwise. 640 */ public 641 boolean isLux() { 642 return libsbmlJNI.Unit_isLux(swigCPtr, this); 643 } 644 645 646/** 647 * Predicate for testing whether this {@link Unit} is of the kind <code>metre</code> 648 <p> 649 * @return <code>true</code> if the kind of this {@link Unit} is <code>metre</code> or 'meter', 650 * <code>false</code> 651 * otherwise. 652 */ public 653 boolean isMetre() { 654 return libsbmlJNI.Unit_isMetre(swigCPtr, this); 655 } 656 657 658/** 659 * Predicate for testing whether this {@link Unit} is of the kind <code>mole</code> 660 <p> 661 * @return <code>true</code> if the kind of this {@link Unit} is <code>mole</code>, <code>false</code> 662 * otherwise. 663 */ public 664 boolean isMole() { 665 return libsbmlJNI.Unit_isMole(swigCPtr, this); 666 } 667 668 669/** 670 * Predicate for testing whether this {@link Unit} is of the kind <code>newton</code> 671 <p> 672 * @return <code>true</code> if the kind of this {@link Unit} is <code>newton</code>, <code>false</code> 673 * otherwise. 674 */ public 675 boolean isNewton() { 676 return libsbmlJNI.Unit_isNewton(swigCPtr, this); 677 } 678 679 680/** 681 * Predicate for testing whether this {@link Unit} is of the kind <code>ohm</code> 682 <p> 683 * @return <code>true</code> if the kind of this {@link Unit} is <code>ohm</code>, <code>false</code> 684 * otherwise. 685 */ public 686 boolean isOhm() { 687 return libsbmlJNI.Unit_isOhm(swigCPtr, this); 688 } 689 690 691/** 692 * Predicate for testing whether this {@link Unit} is of the kind <code>pascal</code> 693 <p> 694 * @return <code>true</code> if the kind of this {@link Unit} is <code>pascal</code>, <code>false</code> 695 * otherwise. 696 */ public 697 boolean isPascal() { 698 return libsbmlJNI.Unit_isPascal(swigCPtr, this); 699 } 700 701 702/** 703 * Predicate for testing whether this {@link Unit} is of the kind <code>radian</code> 704 <p> 705 * @return <code>true</code> if the kind of this {@link Unit} is <code>radian</code>, <code>false</code> 706 * otherwise. 707 */ public 708 boolean isRadian() { 709 return libsbmlJNI.Unit_isRadian(swigCPtr, this); 710 } 711 712 713/** 714 * Predicate for testing whether this {@link Unit} is of the kind <code>second</code> 715 <p> 716 * @return <code>true</code> if the kind of this {@link Unit} is <code>second</code>, <code>false</code> 717 * otherwise. 718 */ public 719 boolean isSecond() { 720 return libsbmlJNI.Unit_isSecond(swigCPtr, this); 721 } 722 723 724/** 725 * Predicate for testing whether this {@link Unit} is of the kind <code>siemens</code> 726 <p> 727 * @return <code>true</code> if the kind of this {@link Unit} is <code>siemens</code>, <code>false</code> 728 * otherwise. 729 */ public 730 boolean isSiemens() { 731 return libsbmlJNI.Unit_isSiemens(swigCPtr, this); 732 } 733 734 735/** 736 * Predicate for testing whether this {@link Unit} is of the kind <code>sievert</code> 737 <p> 738 * @return <code>true</code> if the kind of this {@link Unit} is <code>sievert</code>, <code>false</code> 739 * otherwise. 740 */ public 741 boolean isSievert() { 742 return libsbmlJNI.Unit_isSievert(swigCPtr, this); 743 } 744 745 746/** 747 * Predicate for testing whether this {@link Unit} is of the kind <code>steradian</code> 748 <p> 749 * @return <code>true</code> if the kind of this {@link Unit} is <code>steradian</code>, <code>false</code> 750 * otherwise. 751 */ public 752 boolean isSteradian() { 753 return libsbmlJNI.Unit_isSteradian(swigCPtr, this); 754 } 755 756 757/** 758 * Predicate for testing whether this {@link Unit} is of the kind <code>tesla</code> 759 <p> 760 * @return <code>true</code> if the kind of this {@link Unit} is <code>tesla</code>, <code>false</code> 761 * otherwise. 762 */ public 763 boolean isTesla() { 764 return libsbmlJNI.Unit_isTesla(swigCPtr, this); 765 } 766 767 768/** 769 * Predicate for testing whether this {@link Unit} is of the kind <code>volt</code> 770 <p> 771 * @return <code>true</code> if the kind of this {@link Unit} is <code>volt</code>, <code>false</code> 772 * otherwise. 773 */ public 774 boolean isVolt() { 775 return libsbmlJNI.Unit_isVolt(swigCPtr, this); 776 } 777 778 779/** 780 * Predicate for testing whether this {@link Unit} is of the kind <code>watt</code> 781 <p> 782 * @return <code>true</code> if the kind of this {@link Unit} is <code>watt</code>, <code>false</code> 783 * otherwise. 784 */ public 785 boolean isWatt() { 786 return libsbmlJNI.Unit_isWatt(swigCPtr, this); 787 } 788 789 790/** 791 * Predicate for testing whether this {@link Unit} is of the kind <code>weber</code> 792 <p> 793 * @return <code>true</code> if the kind of this {@link Unit} is <code>weber</code>, <code>false</code> 794 * otherwise. 795 */ public 796 boolean isWeber() { 797 return libsbmlJNI.Unit_isWeber(swigCPtr, this); 798 } 799 800 801/** 802 * Predicate to test whether the 'kind' attribute of this {@link Unit} is set. 803 <p> 804 * @return <code>true</code> if the 'kind' attribute of this {@link Unit} is set, 805 * <code>false</code> otherwise. 806 */ public 807 boolean isSetKind() { 808 return libsbmlJNI.Unit_isSetKind(swigCPtr, this); 809 } 810 811 812/** 813 * Predicate to test whether the 'exponent' attribute of this {@link Unit} 814 * is set. 815 <p> 816 * @return <code>true</code> if the 'exponent' attribute of this {@link Unit} is set, 817 * <code>false</code> otherwise. 818 */ public 819 boolean isSetExponent() { 820 return libsbmlJNI.Unit_isSetExponent(swigCPtr, this); 821 } 822 823 824/** 825 * Predicate to test whether the 'scale' attribute of this {@link Unit} 826 * is set. 827 <p> 828 * @return <code>true</code> if the 'scale' attribute of this {@link Unit} is set, 829 * <code>false</code> otherwise. 830 */ public 831 boolean isSetScale() { 832 return libsbmlJNI.Unit_isSetScale(swigCPtr, this); 833 } 834 835 836/** 837 * Predicate to test whether the 'multiplier' attribute of this {@link Unit} 838 * is set. 839 <p> 840 * @return <code>true</code> if the 'multiplier' attribute of this {@link Unit} is set, 841 * <code>false</code> otherwise. 842 */ public 843 boolean isSetMultiplier() { 844 return libsbmlJNI.Unit_isSetMultiplier(swigCPtr, this); 845 } 846 847 848/** 849 * Predicate to test whether the 'offset' attribute of this {@link Unit} 850 * is set. 851 <p> 852 * @return <code>true</code> if the 'offset' attribute of this {@link Unit} is set, 853 * <code>false</code> otherwise. 854 <p> 855 * <p> 856 * @warning <span class='warning'>The 'offset' attribute is only available in 857 * SBML Level 2 Version 1. This attribute is not present in SBML 858 * Level 2 Version 2 or above. When producing SBML models using 859 * these later specifications, modelers and software tools need to account 860 * for units with offsets explicitly. The SBML specification document 861 * offers a number of suggestions for how to achieve this. LibSBML methods 862 * such as this one related to 'offset' are retained for compatibility with 863 * earlier versions of SBML Level 2, but their use is strongly 864 * discouraged.</span> 865 */ public 866 boolean isSetOffset() { 867 return libsbmlJNI.Unit_isSetOffset(swigCPtr, this); 868 } 869 870 871/** 872 * Sets the 'kind' attribute value of this {@link Unit}. 873 <p> 874 * @param kind a unit identifier chosen from the set of constants whose 875 * names begin with <code>UNIT_KIND_</code> in <code><a 876 * href='libsbmlConstants.html'>libsbmlConstants</a></code>. 877 <p> 878 * <p> 879 * @return integer value indicating success/failure of the 880 * function. The possible values 881 * returned by this function are: 882 * <ul> 883 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 884 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 885 * </ul> 886 */ public 887 int setKind(int kind) { 888 return libsbmlJNI.Unit_setKind(swigCPtr, this, kind); 889 } 890 891 892/** 893 * Sets the 'exponent' attribute value of this {@link Unit}. 894 <p> 895 * @param value the integer to which the attribute 'exponent' should be set. 896 <p> 897 * <p> 898 * @return integer value indicating success/failure of the 899 * function. The possible values 900 * returned by this function are: 901 * <ul> 902 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 903 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 904 * </ul> 905 */ public 906 int setExponent(int value) { 907 return libsbmlJNI.Unit_setExponent__SWIG_0(swigCPtr, this, value); 908 } 909 910 911/** 912 * Sets the 'exponent' attribute value of this {@link Unit}. 913 <p> 914 * @param value the double to which the attribute 'exponent' should be set. 915 <p> 916 * <p> 917 * @return integer value indicating success/failure of the 918 * function. The possible values 919 * returned by this function are: 920 * <ul> 921 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 922 * </ul> 923 */ public 924 int setExponent(double value) { 925 return libsbmlJNI.Unit_setExponent__SWIG_1(swigCPtr, this, value); 926 } 927 928 929/** 930 * Sets the 'scale' attribute value of this {@link Unit}. 931 <p> 932 * @param value the integer to which the attribute 'scale' should be set. 933 <p> 934 * <p> 935 * @return integer value indicating success/failure of the 936 * function. The possible values 937 * returned by this function are: 938 * <ul> 939 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 940 * </ul> 941 */ public 942 int setScale(int value) { 943 return libsbmlJNI.Unit_setScale(swigCPtr, this, value); 944 } 945 946 947/** 948 * Sets the 'multipler' attribute value of this {@link Unit}. 949 <p> 950 * @param value the floating-point value to which the attribute 951 * 'multiplier' should be set. 952 <p> 953 * <p> 954 * @return integer value indicating success/failure of the 955 * function. The possible values 956 * returned by this function are: 957 * <ul> 958 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 959 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 960 * </ul> 961 */ public 962 int setMultiplier(double value) { 963 return libsbmlJNI.Unit_setMultiplier(swigCPtr, this, value); 964 } 965 966 967/** 968 * Sets the 'offset' attribute value of this {@link Unit}. 969 <p> 970 * @param value the floating point value to which the attribute 'offset' 971 * should set. 972 <p> 973 * <p> 974 * @return integer value indicating success/failure of the 975 * function. The possible values 976 * returned by this function are: 977 * <ul> 978 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 979 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 980 * 981 * </ul> <p> 982 * <p> 983 * @warning <span class='warning'>The 'offset' attribute is only available in 984 * SBML Level 2 Version 1. This attribute is not present in SBML 985 * Level 2 Version 2 or above. When producing SBML models using 986 * these later specifications, modelers and software tools need to account 987 * for units with offsets explicitly. The SBML specification document 988 * offers a number of suggestions for how to achieve this. LibSBML methods 989 * such as this one related to 'offset' are retained for compatibility with 990 * earlier versions of SBML Level 2, but their use is strongly 991 * discouraged.</span> 992 */ public 993 int setOffset(double value) { 994 return libsbmlJNI.Unit_setOffset(swigCPtr, this, value); 995 } 996 997 998/** 999 * Unsets the 'kind' attribute value of this {@link Unit}. 1000 <p> 1001 * <p> 1002 * @return integer value indicating success/failure of the 1003 * function. The possible values 1004 * returned by this function are: 1005 * <ul> 1006 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1007 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 1008 * </ul> 1009 */ public 1010 int unsetKind() { 1011 return libsbmlJNI.Unit_unsetKind(swigCPtr, this); 1012 } 1013 1014 1015/** 1016 * Unsets the 'exponent' attribute value of this {@link Unit}. 1017 <p> 1018 * <p> 1019 * @return integer value indicating success/failure of the 1020 * function. The possible values 1021 * returned by this function are: 1022 * <ul> 1023 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1024 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 1025 * </ul> 1026 */ public 1027 int unsetExponent() { 1028 return libsbmlJNI.Unit_unsetExponent(swigCPtr, this); 1029 } 1030 1031 1032/** 1033 * Unsets the 'scale' attribute value of this {@link Unit}. 1034 <p> 1035 * <p> 1036 * @return integer value indicating success/failure of the 1037 * function. The possible values 1038 * returned by this function are: 1039 * <ul> 1040 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1041 * </ul> 1042 */ public 1043 int unsetScale() { 1044 return libsbmlJNI.Unit_unsetScale(swigCPtr, this); 1045 } 1046 1047 1048/** 1049 * Unsets the 'multipler' attribute value of this {@link Unit}. 1050 <p> 1051 * <p> 1052 * @return integer value indicating success/failure of the 1053 * function. The possible values 1054 * returned by this function are: 1055 * <ul> 1056 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1057 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 1058 * </ul> 1059 */ public 1060 int unsetMultiplier() { 1061 return libsbmlJNI.Unit_unsetMultiplier(swigCPtr, this); 1062 } 1063 1064 1065/** 1066 * Unsets the 'offset' attribute value of this {@link Unit}. 1067 <p> 1068 * <p> 1069 * @return integer value indicating success/failure of the 1070 * function. The possible values 1071 * returned by this function are: 1072 * <ul> 1073 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1074 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 1075 * 1076 * </ul> <p> 1077 * <p> 1078 * @warning <span class='warning'>The 'offset' attribute is only available in 1079 * SBML Level 2 Version 1. This attribute is not present in SBML 1080 * Level 2 Version 2 or above. When producing SBML models using 1081 * these later specifications, modelers and software tools need to account 1082 * for units with offsets explicitly. The SBML specification document 1083 * offers a number of suggestions for how to achieve this. LibSBML methods 1084 * such as this one related to 'offset' are retained for compatibility with 1085 * earlier versions of SBML Level 2, but their use is strongly 1086 * discouraged.</span> 1087 */ public 1088 int unsetOffset() { 1089 return libsbmlJNI.Unit_unsetOffset(swigCPtr, this); 1090 } 1091 1092 1093/** 1094 * Returns the libSBML type code of this object instance. 1095 <p> 1096 * <p> 1097 * LibSBML attaches an identifying code to every kind of SBML object. These 1098 * are integer constants known as <em>SBML type codes</em>. The names of all 1099 * the codes begin with the characters <code>SBML_</code>. 1100 * In the Java language interface for libSBML, the 1101 * type codes are defined as static integer constants in the interface class 1102 * {@link libsbmlConstants}. Note that different Level 3 1103 * package plug-ins may use overlapping type codes; to identify the package 1104 * to which a given object belongs, call the 1105 * <code>{@link SBase#getPackageName()} 1106 * </code> 1107 * method on the object. 1108 <p> 1109 * @return the SBML type code for this object: 1110 * {@link libsbmlConstants#SBML_UNIT SBML_UNIT} (default). 1111 <p> 1112 * <p> 1113 * @warning <span class='warning'>The specific integer values of the possible 1114 * type codes may be reused by different libSBML plug-ins for SBML Level 3. 1115 * packages, To fully identify the correct code, <strong>it is necessary to 1116 * invoke both getTypeCode() and getPackageName()</strong>.</span> 1117 <p> 1118 * @see #getPackageName() 1119 * @see #getElementName() 1120 */ public 1121 int getTypeCode() { 1122 return libsbmlJNI.Unit_getTypeCode(swigCPtr, this); 1123 } 1124 1125 1126/** 1127 * Returns the XML element name of this object, which for {@link Unit}, is 1128 * always <code>'unit'.</code> 1129 <p> 1130 * @return the name of this element, i.e., <code>'unit'.</code> 1131 */ public 1132 String getElementName() { 1133 return libsbmlJNI.Unit_getElementName(swigCPtr, this); 1134 } 1135 1136 1137/** 1138 * Predicate to test whether a given string is the name of a built-in SBML 1139 * unit, depending on the SBML level, since new predefined units were added 1140 * between level 2 versions 1 and 2, and then all predefined units were removed 1141 * again in SBML Level 3. 1142 <p> 1143 * @param name a string to be tested against the built-in unit names. 1144 * @param level the level of SBML one is checking. 1145 <p> 1146 * @return <code>true</code> if <code>name</code> is one of <code>'substance'</code>, <code>'volume'</code>, 1147 * or <code>'time'</code> and the <code>level</code> is <code>1</code>; or if <code>name</code> is one of 1148 * <code>'substance'</code>, <code>'volume'</code>, <code>'area'</code>, <code>'length'</code>, or <code>'time'</code> and 1149 * the <code>level</code> is <code>2</code>; <code>false</code> otherwise (including all values when 1150 * <code>level</code> is <code>3</code>). 1151 <p> 1152 * 1153 */ public 1154 static boolean isBuiltIn(String name, long level) { 1155 return libsbmlJNI.Unit_isBuiltIn(name, level); 1156 } 1157 1158 1159/** 1160 * Predicate to test whether a given string is the name of a valid 1161 * base unit in SBML (such as <code>'gram'</code> or <code>'mole'</code>). 1162 <p> 1163 * This method exists because prior to SBML Level 2 Version 3, 1164 * an enumeration called <code>UnitKind</code> was defined by SBML. This enumeration 1165 * was removed in SBML Level 2 Version 3 and its values were 1166 * folded into the space of values of a type called <code>UnitSId.</code> This method 1167 * therefore has less significance in SBML Level 2 Version 3 1168 * and Level 2 Version 4, but remains for backward 1169 * compatibility and support for reading models in older Versions of 1170 * Level 2. 1171 <p> 1172 * @param name a string to be tested. 1173 <p> 1174 * @param level a long integer representing the SBML specification 1175 * Level. 1176 <p> 1177 * @param version a long integer representing the SBML specification 1178 * Version. 1179 <p> 1180 * @return <code>true</code> if name is a valid SBML UnitKind, <code>false</code> otherwise. 1181 <p> 1182 * @note The allowed unit names differ between SBML Levels 1 1183 * and 2 and again slightly between Level 2 Versions 1 1184 * and 2. 1185 <p> 1186 * 1187 */ public 1188 static boolean isUnitKind(String name, long level, long version) { 1189 return libsbmlJNI.Unit_isUnitKind(name, level, version); 1190 } 1191 1192 1193/** 1194 * Predicate returning <code>true</code> if two 1195 * {@link Unit} objects are identical. 1196 <p> 1197 * Two {@link Unit} objects are considered to be <em>identical</em> if they match in 1198 * all attributes. (Contrast this to the method areEquivalent(Unit u1, Unit u2), which compares {@link Unit} objects only with respect 1199 * to certain attributes.) 1200 <p> 1201 * @param unit1 the first {@link Unit} object to compare. 1202 * @param unit2 the second {@link Unit} object to compare. 1203 <p> 1204 * @return <code>true</code> if all the attributes of unit1 are identical 1205 * to the attributes of unit2, <code>false</code> otherwise. 1206 <p> 1207 * 1208 <p> 1209 * @see Unit#areEquivalent(Unit u1, Unit u2) 1210 */ public 1211 static boolean areIdentical(Unit unit1, Unit unit2) { 1212 return libsbmlJNI.Unit_areIdentical(Unit.getCPtr(unit1), unit1, Unit.getCPtr(unit2), unit2); 1213 } 1214 1215 1216/** 1217 * Predicate returning <code>true</code> if 1218 * {@link Unit} objects are equivalent. 1219 <p> 1220 * Two {@link Unit} objects are considered to be <em>equivalent</em> either if (1) both 1221 * have a 'kind' attribute value of <code>dimensionless</code>, or (2) their 'kind', 1222 * 'exponent' and (for SBML Level 2 Version 1) 'offset' 1223 * attribute values are equal. (Contrast this to the method 1224 * areIdentical(Unit, Unit), which compares {@link Unit} objects with respect to all 1225 * attributes, not just the 'kind' and 'exponent'.) 1226 <p> 1227 * @param unit1 the first {@link Unit} object to compare. 1228 * @param unit2 the second {@link Unit} object to compare. 1229 <p> 1230 * @return <code>true</code> if the 'kind' and 'exponent' attributes of unit1 are 1231 * identical to the kind and exponent attributes of unit2, or if the kind 1232 * attributes of both are <code>dimensionless</code>; <code>false</code> otherwise. 1233 <p> 1234 * 1235 <p> 1236 * @see Unit#areIdentical(Unit u1, Unit u2) 1237 */ public 1238 static boolean areEquivalent(Unit unit1, Unit unit2) { 1239 return libsbmlJNI.Unit_areEquivalent(Unit.getCPtr(unit1), unit1, Unit.getCPtr(unit2), unit2); 1240 } 1241 1242 1243/** 1244 * Manipulates the attributes of the {@link Unit} to express the unit with the 1245 * value of the scale attribute reduced to zero. 1246 <p> 1247 * For example, 1 millimetre can be expressed as a {@link Unit} with kind= 1248 * <code>'metre'</code> multiplier=<code>'1'</code> scale=<code>'-3'</code> exponent=<code>'1'.</code> It can also be 1249 * expressed as a {@link Unit} with kind=<code>'metre'</code> 1250 * multiplier=<code>'0.001'</code> scale=<code>'0'</code> exponent=<code>'1'.</code> 1251 <p> 1252 * @param unit the {@link Unit} object to manipulate. 1253 <p> 1254 * <p> 1255 * @return integer value indicating success/failure of the 1256 * function. This particular 1257 * function only does one thing irrespective of user input or 1258 * object state, and thus will only return a single value: 1259 * <ul> 1260 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1261 * 1262 * </ul> <p> 1263 * 1264 <p> 1265 * @see Unit#convertToSI(Unit u) 1266 * @see Unit#merge(Unit u1, Unit u2) 1267 */ public 1268 static int removeScale(Unit unit) { 1269 return libsbmlJNI.Unit_removeScale(Unit.getCPtr(unit), unit); 1270 } 1271 1272 1273/** 1274 * Merges two {@link Unit} objects with the same 'kind' attribute value into a 1275 * single {@link Unit}. 1276 <p> 1277 * For example, the following, 1278 * <pre class='fragment'> 1279 <unit kind='metre' exponent='2'/> 1280 <unit kind='metre' exponent='1'/> 1281 </pre> 1282 * would be merged to become 1283 * <pre class='fragment'> 1284 <unit kind='metre' exponent='3'/> 1285 </pre> 1286 <p> 1287 * @param unit1 the first {@link Unit} object; the result of the operation is 1288 * left as a new version of this unit, modified in-place. Not modified if 1289 * the two units have different kinds. 1290 <p> 1291 * @param unit2 the second {@link Unit} object to merge with the first. 1292 <p> 1293 * 1294 <p> 1295 * @see Unit#convertToSI(Unit u) 1296 * @see Unit#removeScale(Unit u) 1297 */ public 1298 static void merge(Unit unit1, Unit unit2) { 1299 libsbmlJNI.Unit_merge(Unit.getCPtr(unit1), unit1, Unit.getCPtr(unit2), unit2); 1300 } 1301 1302 1303/** 1304 * Returns a {@link UnitDefinition} object containing the given <code>unit</code> converted 1305 * to the appropriate SI unit. 1306 <p> 1307 * This method exists because some units can be expressed in terms of 1308 * others when the same physical dimension is involved. For example, one 1309 * hertz is identical to 1 sec<sup>-1</sup>, one litre is equivalent 1310 * to 1 cubic decametre, and so on. 1311 <p> 1312 * @param unit the {@link Unit} object to convert to SI. 1313 <p> 1314 * @return a {@link UnitDefinition} object containing the SI unit. 1315 <p> 1316 * 1317 <p> 1318 * @see Unit#merge(Unit u1, Unit u2) 1319 */ public 1320 static UnitDefinition convertToSI(Unit unit) { 1321 long cPtr = libsbmlJNI.Unit_convertToSI(Unit.getCPtr(unit), unit); 1322 return (cPtr == 0) ? null : new UnitDefinition(cPtr, true); 1323 } 1324 1325 1326/** 1327 * Predicate returning <code>true</code> if 1328 * all the required attributes for this {@link Unit} object 1329 * have been set. 1330 <p> 1331 * The required attributes for a {@link Unit} object are: 1332 * <ul> 1333 * <li> 'kind' 1334 * <li> 'exponent' (required in SBML Level 3; optional in Level 2) 1335 * <li> 'multiplier' (required in SBML Level 3; optional in Level 2) 1336 * <li> 'scale' (required in SBML Level 3; optional in Level 2) 1337 * 1338 * </ul> <p> 1339 * @return <code>true</code> if the required attributes have been set, <code>false</code> 1340 * otherwise. 1341 */ public 1342 boolean hasRequiredAttributes() { 1343 return libsbmlJNI.Unit_hasRequiredAttributes(swigCPtr, this); 1344 } 1345 1346}