001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.10 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 not 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 3. 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> 618 * otherwise. 619 */ public 620 boolean isLitre() { 621 return libsbmlJNI.Unit_isLitre(swigCPtr, this); 622 } 623 624 625/** 626 * Predicate for testing whether this {@link Unit} is of the kind <code>lumen</code> 627 <p> 628 * @return <code>true</code> if the kind of this {@link Unit} is <code>lumen</code>, <code>false</code> 629 * otherwise. 630 */ public 631 boolean isLumen() { 632 return libsbmlJNI.Unit_isLumen(swigCPtr, this); 633 } 634 635 636/** 637 * Predicate for testing whether this {@link Unit} is of the kind <code>lux</code> 638 <p> 639 * @return <code>true</code> if the kind of this {@link Unit} is <code>lux</code>, <code>false</code> 640 * otherwise. 641 */ public 642 boolean isLux() { 643 return libsbmlJNI.Unit_isLux(swigCPtr, this); 644 } 645 646 647/** 648 * Predicate for testing whether this {@link Unit} is of the kind <code>metre</code> 649 <p> 650 * @return <code>true</code> if the kind of this {@link Unit} is <code>metre</code> or 'meter', 651 * <code>false</code> 652 * otherwise. 653 */ public 654 boolean isMetre() { 655 return libsbmlJNI.Unit_isMetre(swigCPtr, this); 656 } 657 658 659/** 660 * Predicate for testing whether this {@link Unit} is of the kind <code>mole</code> 661 <p> 662 * @return <code>true</code> if the kind of this {@link Unit} is <code>mole</code>, <code>false</code> 663 * otherwise. 664 */ public 665 boolean isMole() { 666 return libsbmlJNI.Unit_isMole(swigCPtr, this); 667 } 668 669 670/** 671 * Predicate for testing whether this {@link Unit} is of the kind <code>newton</code> 672 <p> 673 * @return <code>true</code> if the kind of this {@link Unit} is <code>newton</code>, <code>false</code> 674 * otherwise. 675 */ public 676 boolean isNewton() { 677 return libsbmlJNI.Unit_isNewton(swigCPtr, this); 678 } 679 680 681/** 682 * Predicate for testing whether this {@link Unit} is of the kind <code>ohm</code> 683 <p> 684 * @return <code>true</code> if the kind of this {@link Unit} is <code>ohm</code>, <code>false</code> 685 * otherwise. 686 */ public 687 boolean isOhm() { 688 return libsbmlJNI.Unit_isOhm(swigCPtr, this); 689 } 690 691 692/** 693 * Predicate for testing whether this {@link Unit} is of the kind <code>pascal</code> 694 <p> 695 * @return <code>true</code> if the kind of this {@link Unit} is <code>pascal</code>, <code>false</code> 696 * otherwise. 697 */ public 698 boolean isPascal() { 699 return libsbmlJNI.Unit_isPascal(swigCPtr, this); 700 } 701 702 703/** 704 * Predicate for testing whether this {@link Unit} is of the kind <code>radian</code> 705 <p> 706 * @return <code>true</code> if the kind of this {@link Unit} is <code>radian</code>, <code>false</code> 707 * otherwise. 708 */ public 709 boolean isRadian() { 710 return libsbmlJNI.Unit_isRadian(swigCPtr, this); 711 } 712 713 714/** 715 * Predicate for testing whether this {@link Unit} is of the kind <code>second</code> 716 <p> 717 * @return <code>true</code> if the kind of this {@link Unit} is <code>second</code>, <code>false</code> 718 * otherwise. 719 */ public 720 boolean isSecond() { 721 return libsbmlJNI.Unit_isSecond(swigCPtr, this); 722 } 723 724 725/** 726 * Predicate for testing whether this {@link Unit} is of the kind <code>siemens</code> 727 <p> 728 * @return <code>true</code> if the kind of this {@link Unit} is <code>siemens</code>, <code>false</code> 729 * otherwise. 730 */ public 731 boolean isSiemens() { 732 return libsbmlJNI.Unit_isSiemens(swigCPtr, this); 733 } 734 735 736/** 737 * Predicate for testing whether this {@link Unit} is of the kind <code>sievert</code> 738 <p> 739 * @return <code>true</code> if the kind of this {@link Unit} is <code>sievert</code>, <code>false</code> 740 * otherwise. 741 */ public 742 boolean isSievert() { 743 return libsbmlJNI.Unit_isSievert(swigCPtr, this); 744 } 745 746 747/** 748 * Predicate for testing whether this {@link Unit} is of the kind <code>steradian</code> 749 <p> 750 * @return <code>true</code> if the kind of this {@link Unit} is <code>steradian</code>, <code>false</code> 751 * otherwise. 752 */ public 753 boolean isSteradian() { 754 return libsbmlJNI.Unit_isSteradian(swigCPtr, this); 755 } 756 757 758/** 759 * Predicate for testing whether this {@link Unit} is of the kind <code>tesla</code> 760 <p> 761 * @return <code>true</code> if the kind of this {@link Unit} is <code>tesla</code>, <code>false</code> 762 * otherwise. 763 */ public 764 boolean isTesla() { 765 return libsbmlJNI.Unit_isTesla(swigCPtr, this); 766 } 767 768 769/** 770 * Predicate for testing whether this {@link Unit} is of the kind <code>volt</code> 771 <p> 772 * @return <code>true</code> if the kind of this {@link Unit} is <code>volt</code>, <code>false</code> 773 * otherwise. 774 */ public 775 boolean isVolt() { 776 return libsbmlJNI.Unit_isVolt(swigCPtr, this); 777 } 778 779 780/** 781 * Predicate for testing whether this {@link Unit} is of the kind <code>watt</code> 782 <p> 783 * @return <code>true</code> if the kind of this {@link Unit} is <code>watt</code>, <code>false</code> 784 * otherwise. 785 */ public 786 boolean isWatt() { 787 return libsbmlJNI.Unit_isWatt(swigCPtr, this); 788 } 789 790 791/** 792 * Predicate for testing whether this {@link Unit} is of the kind <code>weber</code> 793 <p> 794 * @return <code>true</code> if the kind of this {@link Unit} is <code>weber</code>, <code>false</code> 795 * otherwise. 796 */ public 797 boolean isWeber() { 798 return libsbmlJNI.Unit_isWeber(swigCPtr, this); 799 } 800 801 802/** 803 * Predicate to test whether the 'kind' attribute of this {@link Unit} is set. 804 <p> 805 * @return <code>true</code> if the 'kind' attribute of this {@link Unit} is set, 806 * <code>false</code> otherwise. 807 */ public 808 boolean isSetKind() { 809 return libsbmlJNI.Unit_isSetKind(swigCPtr, this); 810 } 811 812 813/** 814 * Predicate to test whether the 'exponent' attribute of this {@link Unit} 815 * is set. 816 <p> 817 * @return <code>true</code> if the 'exponent' attribute of this {@link Unit} is set, 818 * <code>false</code> otherwise. 819 */ public 820 boolean isSetExponent() { 821 return libsbmlJNI.Unit_isSetExponent(swigCPtr, this); 822 } 823 824 825/** 826 * Predicate to test whether the 'scale' attribute of this {@link Unit} 827 * is set. 828 <p> 829 * @return <code>true</code> if the 'scale' attribute of this {@link Unit} is set, 830 * <code>false</code> otherwise. 831 */ public 832 boolean isSetScale() { 833 return libsbmlJNI.Unit_isSetScale(swigCPtr, this); 834 } 835 836 837/** 838 * Predicate to test whether the 'multiplier' attribute of this {@link Unit} 839 * is set. 840 <p> 841 * @return <code>true</code> if the 'multiplier' attribute of this {@link Unit} is set, 842 * <code>false</code> otherwise. 843 */ public 844 boolean isSetMultiplier() { 845 return libsbmlJNI.Unit_isSetMultiplier(swigCPtr, this); 846 } 847 848 849/** 850 * Predicate to test whether the 'offset' attribute of this {@link Unit} 851 * is set. 852 <p> 853 * @return <code>true</code> if the 'offset' attribute of this {@link Unit} is set, 854 * <code>false</code> otherwise. 855 <p> 856 * <p> 857 * @warning <span class='warning'>The 'offset' attribute is only available in 858 * SBML Level 2 Version 1. This attribute is not present in SBML 859 * Level 2 Version 2 or above. When producing SBML models using 860 * these later specifications, modelers and software tools need to account 861 * for units with offsets explicitly. The SBML specification document 862 * offers a number of suggestions for how to achieve this. LibSBML methods 863 * such as this one related to 'offset' are retained for compatibility with 864 * earlier versions of SBML Level 2, but their use is strongly 865 * discouraged.</span> 866 */ public 867 boolean isSetOffset() { 868 return libsbmlJNI.Unit_isSetOffset(swigCPtr, this); 869 } 870 871 872/** 873 * Sets the 'kind' attribute value of this {@link Unit}. 874 <p> 875 * @param kind a unit identifier chosen from the set of constants whose 876 * names begin with <code>UNIT_KIND_</code> in <code><a 877 * href='libsbmlConstants.html'>libsbmlConstants</a></code>. 878 <p> 879 * <p> 880 * @return integer value indicating success/failure of the 881 * function. The possible values 882 * returned by this function are: 883 * <ul> 884 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 885 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 886 * </ul> 887 */ public 888 int setKind(int kind) { 889 return libsbmlJNI.Unit_setKind(swigCPtr, this, kind); 890 } 891 892 893/** 894 * Sets the 'exponent' attribute value of this {@link Unit}. 895 <p> 896 * @param value the integer to which the attribute 'exponent' should be set. 897 <p> 898 * <p> 899 * @return integer value indicating success/failure of the 900 * function. The possible values 901 * returned by this function are: 902 * <ul> 903 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 904 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 905 * </ul> 906 */ public 907 int setExponent(int value) { 908 return libsbmlJNI.Unit_setExponent__SWIG_0(swigCPtr, this, value); 909 } 910 911 912/** 913 * Sets the 'exponent' attribute value of this {@link Unit}. 914 <p> 915 * @param value the double to which the attribute 'exponent' should be set. 916 <p> 917 * <p> 918 * @return integer value indicating success/failure of the 919 * function. The possible values 920 * returned by this function are: 921 * <ul> 922 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 923 * </ul> 924 */ public 925 int setExponent(double value) { 926 return libsbmlJNI.Unit_setExponent__SWIG_1(swigCPtr, this, value); 927 } 928 929 930/** 931 * Sets the 'scale' attribute value of this {@link Unit}. 932 <p> 933 * @param value the integer to which the attribute 'scale' should be set. 934 <p> 935 * <p> 936 * @return integer value indicating success/failure of the 937 * function. The possible values 938 * returned by this function are: 939 * <ul> 940 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 941 * </ul> 942 */ public 943 int setScale(int value) { 944 return libsbmlJNI.Unit_setScale(swigCPtr, this, value); 945 } 946 947 948/** 949 * Sets the 'multipler' attribute value of this {@link Unit}. 950 <p> 951 * @param value the floating-point value to which the attribute 952 * 'multiplier' should be set. 953 <p> 954 * <p> 955 * @return integer value indicating success/failure of the 956 * function. The possible values 957 * returned by this function are: 958 * <ul> 959 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 960 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 961 * </ul> 962 */ public 963 int setMultiplier(double value) { 964 return libsbmlJNI.Unit_setMultiplier(swigCPtr, this, value); 965 } 966 967 968/** 969 * Sets the 'offset' attribute value of this {@link Unit}. 970 <p> 971 * @param value the float-point value to which the attribute 'offset' 972 * should set. 973 <p> 974 * <p> 975 * @return integer value indicating success/failure of the 976 * function. The possible values 977 * returned by this function are: 978 * <ul> 979 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 980 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 981 * 982 * </ul> <p> 983 * <p> 984 * @warning <span class='warning'>The 'offset' attribute is only available in 985 * SBML Level 2 Version 1. This attribute is not present in SBML 986 * Level 2 Version 2 or above. When producing SBML models using 987 * these later specifications, modelers and software tools need to account 988 * for units with offsets explicitly. The SBML specification document 989 * offers a number of suggestions for how to achieve this. LibSBML methods 990 * such as this one related to 'offset' are retained for compatibility with 991 * earlier versions of SBML Level 2, but their use is strongly 992 * discouraged.</span> 993 */ public 994 int setOffset(double value) { 995 return libsbmlJNI.Unit_setOffset(swigCPtr, this, value); 996 } 997 998 999/** 1000 * Unsets the 'kind' attribute value of this {@link Unit}. 1001 <p> 1002 * <p> 1003 * @return integer value indicating success/failure of the 1004 * function. The possible values 1005 * returned by this function are: 1006 * <ul> 1007 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1008 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 1009 * </ul> 1010 */ public 1011 int unsetKind() { 1012 return libsbmlJNI.Unit_unsetKind(swigCPtr, this); 1013 } 1014 1015 1016/** 1017 * Unsets the 'exponent' attribute value of this {@link Unit}. 1018 <p> 1019 * <p> 1020 * @return integer value indicating success/failure of the 1021 * function. The possible values 1022 * returned by this function are: 1023 * <ul> 1024 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1025 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 1026 * </ul> 1027 */ public 1028 int unsetExponent() { 1029 return libsbmlJNI.Unit_unsetExponent(swigCPtr, this); 1030 } 1031 1032 1033/** 1034 * Unsets the 'scale' attribute value of this {@link Unit}. 1035 <p> 1036 * <p> 1037 * @return integer value indicating success/failure of the 1038 * function. The possible values 1039 * returned by this function are: 1040 * <ul> 1041 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1042 * </ul> 1043 */ public 1044 int unsetScale() { 1045 return libsbmlJNI.Unit_unsetScale(swigCPtr, this); 1046 } 1047 1048 1049/** 1050 * Unsets the 'multipler' attribute value of this {@link Unit}. 1051 <p> 1052 * <p> 1053 * @return integer value indicating success/failure of the 1054 * function. The possible values 1055 * returned by this function are: 1056 * <ul> 1057 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1058 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 1059 * </ul> 1060 */ public 1061 int unsetMultiplier() { 1062 return libsbmlJNI.Unit_unsetMultiplier(swigCPtr, this); 1063 } 1064 1065 1066/** 1067 * Unsets the 'offset' attribute value of this {@link Unit}. 1068 <p> 1069 * <p> 1070 * @return integer value indicating success/failure of the 1071 * function. The possible values 1072 * returned by this function are: 1073 * <ul> 1074 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1075 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 1076 * 1077 * </ul> <p> 1078 * <p> 1079 * @warning <span class='warning'>The 'offset' attribute is only available in 1080 * SBML Level 2 Version 1. This attribute is not present in SBML 1081 * Level 2 Version 2 or above. When producing SBML models using 1082 * these later specifications, modelers and software tools need to account 1083 * for units with offsets explicitly. The SBML specification document 1084 * offers a number of suggestions for how to achieve this. LibSBML methods 1085 * such as this one related to 'offset' are retained for compatibility with 1086 * earlier versions of SBML Level 2, but their use is strongly 1087 * discouraged.</span> 1088 */ public 1089 int unsetOffset() { 1090 return libsbmlJNI.Unit_unsetOffset(swigCPtr, this); 1091 } 1092 1093 1094/** 1095 * Returns the libSBML type code of this object instance. 1096 <p> 1097 * <p> 1098 * LibSBML attaches an identifying code to every kind of SBML object. These 1099 * are integer constants known as <em>SBML type codes</em>. The names of all 1100 * the codes begin with the characters <code>SBML_</code>. 1101 * In the Java language interface for libSBML, the 1102 * type codes are defined as static integer constants in the interface class 1103 * {@link libsbmlConstants}. Note that different Level 3 1104 * package plug-ins may use overlapping type codes; to identify the package 1105 * to which a given object belongs, call the <code>getPackageName()</code> 1106 * method on the object. 1107 <p> 1108 * @return the SBML type code for this object: 1109 * {@link libsbmlConstants#SBML_UNIT SBML_UNIT} (default). 1110 <p> 1111 * <p> 1112 * @warning <span class='warning'>The specific integer values of the possible 1113 * type codes may be reused by different libSBML plug-ins for SBML Level 3. 1114 * packages, To fully identify the correct code, <strong>it is necessary to 1115 * invoke both getTypeCode() and getPackageName()</strong>.</span> 1116 <p> 1117 * @see #getPackageName() 1118 * @see #getElementName() 1119 */ public 1120 int getTypeCode() { 1121 return libsbmlJNI.Unit_getTypeCode(swigCPtr, this); 1122 } 1123 1124 1125/** 1126 * Returns the XML element name of this object, which for {@link Unit}, is 1127 * always <code>'unit'.</code> 1128 <p> 1129 * @return the name of this element, i.e., <code>'unit'.</code> 1130 */ public 1131 String getElementName() { 1132 return libsbmlJNI.Unit_getElementName(swigCPtr, this); 1133 } 1134 1135 1136/** 1137 * Predicate to test whether a given string is the name of a 1138 * predefined SBML unit. 1139 <p> 1140 * @param name a string to be tested against the predefined unit names. 1141 <p> 1142 * @param level the Level of SBML for which the determination should be 1143 * made. This is necessary because there are a few small differences 1144 * in allowed units between SBML Level 1 and Level 2. 1145 <p> 1146 * @return <code>true</code> if <code>name</code> is one of the five SBML predefined unit 1147 * identifiers (<code>'substance'</code>, <code>'volume'</code>, <code>'area'</code>, <code>'length'</code> or 1148 * <code>'time'</code>), <code>false</code> otherwise. 1149 <p> 1150 * @note The predefined unit identifiers <code>'length'</code> and <code>'area'</code> were 1151 * added in Level 2 Version 1. 1152 <p> 1153 * 1154 */ public 1155 static boolean isBuiltIn(String name, long level) { 1156 return libsbmlJNI.Unit_isBuiltIn(name, level); 1157 } 1158 1159 1160/** 1161 * Predicate to test whether a given string is the name of a valid 1162 * base unit in SBML (such as <code>'gram'</code> or <code>'mole'</code>). 1163 <p> 1164 * This method exists because prior to SBML Level 2 Version 3, 1165 * an enumeration called <code>UnitKind</code> was defined by SBML. This enumeration 1166 * was removed in SBML Level 2 Version 3 and its values were 1167 * folded into the space of values of a type called <code>UnitSId.</code> This method 1168 * therefore has less significance in SBML Level 2 Version 3 1169 * and Level 2 Version 4, but remains for backward 1170 * compatibility and support for reading models in older Versions of 1171 * Level 2. 1172 <p> 1173 * @param name a string to be tested. 1174 <p> 1175 * @param level a long integer representing the SBML specification 1176 * Level. 1177 <p> 1178 * @param version a long integer representing the SBML specification 1179 * Version. 1180 <p> 1181 * @return <code>true</code> if name is a valid SBML UnitKind, <code>false</code> otherwise. 1182 <p> 1183 * @note The allowed unit names differ between SBML Levels 1 1184 * and 2 and again slightly between Level 2 Versions 1 1185 * and 2. 1186 <p> 1187 * 1188 */ public 1189 static boolean isUnitKind(String name, long level, long version) { 1190 return libsbmlJNI.Unit_isUnitKind(name, level, version); 1191 } 1192 1193 1194/** 1195 * Predicate returning <code>true</code> if two 1196 * {@link Unit} objects are identical. 1197 <p> 1198 * Two {@link Unit} objects are considered to be <em>identical</em> if they match in 1199 * all attributes. (Contrast this to the method areEquivalent(Unit u1, Unit u2), which compares {@link Unit} objects only with respect 1200 * to certain attributes.) 1201 <p> 1202 * @param unit1 the first {@link Unit} object to compare. 1203 * @param unit2 the second {@link Unit} object to compare. 1204 <p> 1205 * @return <code>true</code> if all the attributes of unit1 are identical 1206 * to the attributes of unit2, <code>false</code> otherwise. 1207 <p> 1208 * 1209 <p> 1210 * @see Unit#areEquivalent(Unit u1, Unit u2) 1211 */ public 1212 static boolean areIdentical(Unit unit1, Unit unit2) { 1213 return libsbmlJNI.Unit_areIdentical(Unit.getCPtr(unit1), unit1, Unit.getCPtr(unit2), unit2); 1214 } 1215 1216 1217/** 1218 * Predicate returning <code>true</code> if 1219 * {@link Unit} objects are equivalent. 1220 <p> 1221 * Two {@link Unit} objects are considered to be <em>equivalent</em> either if (1) both 1222 * have a 'kind' attribute value of <code>dimensionless</code>, or (2) their 'kind', 1223 * 'exponent' and (for SBML Level 2 Version 1) 'offset' 1224 * attribute values are equal. (Contrast this to the method 1225 * areIdentical(Unit, Unit), which compares {@link Unit} objects with respect to all 1226 * attributes, not just the 'kind' and 'exponent'.) 1227 <p> 1228 * @param unit1 the first {@link Unit} object to compare. 1229 * @param unit2 the second {@link Unit} object to compare. 1230 <p> 1231 * @return <code>true</code> if the 'kind' and 'exponent' attributes of unit1 are 1232 * identical to the kind and exponent attributes of unit2, <code>false</code> 1233 * otherwise. 1234 <p> 1235 * 1236 <p> 1237 * @see Unit#areIdentical(Unit u1, Unit u2) 1238 */ public 1239 static boolean areEquivalent(Unit unit1, Unit unit2) { 1240 return libsbmlJNI.Unit_areEquivalent(Unit.getCPtr(unit1), unit1, Unit.getCPtr(unit2), unit2); 1241 } 1242 1243 1244/** 1245 * Manipulates the attributes of the {@link Unit} to express the unit with the 1246 * value of the scale attribute reduced to zero. 1247 <p> 1248 * For example, 1 millimetre can be expressed as a {@link Unit} with kind= 1249 * <code>'metre'</code> multiplier=<code>'1'</code> scale=<code>'-3'</code> exponent=<code>'1'.</code> It can also be 1250 * expressed as a {@link Unit} with kind=<code>'metre'</code> 1251 * multiplier=<code>'0.001'</code> scale=<code>'0'</code> exponent=<code>'1'.</code> 1252 <p> 1253 * @param unit the {@link Unit} object to manipulate. 1254 <p> 1255 * <p> 1256 * @return integer value indicating success/failure of the 1257 * function. This particular 1258 * function only does one thing irrespective of user input or 1259 * object state, and thus will only return a single value: 1260 * <ul> 1261 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1262 * 1263 * </ul> <p> 1264 * 1265 <p> 1266 * @see Unit#convertToSI(Unit u) 1267 * @see Unit#merge(Unit u1, Unit u2) 1268 */ public 1269 static int removeScale(Unit unit) { 1270 return libsbmlJNI.Unit_removeScale(Unit.getCPtr(unit), unit); 1271 } 1272 1273 1274/** 1275 * Merges two {@link Unit} objects with the same 'kind' attribute value into a 1276 * single {@link Unit}. 1277 <p> 1278 * For example, the following, 1279 * <pre class='fragment'> 1280 <unit kind='metre' exponent='2'/> 1281 <unit kind='metre' exponent='1'/> 1282 </pre> 1283 * would be merged to become 1284 * <pre class='fragment'> 1285 <unit kind='metre' exponent='3'/> 1286 </pre> 1287 <p> 1288 * @param unit1 the first {@link Unit} object; the result of the operation is 1289 * left as a new version of this unit, modified in-place. Not modified if 1290 * the two units have different kinds. 1291 <p> 1292 * @param unit2 the second {@link Unit} object to merge with the first. 1293 <p> 1294 * 1295 <p> 1296 * @see Unit#convertToSI(Unit u) 1297 * @see Unit#removeScale(Unit u) 1298 */ public 1299 static void merge(Unit unit1, Unit unit2) { 1300 libsbmlJNI.Unit_merge(Unit.getCPtr(unit1), unit1, Unit.getCPtr(unit2), unit2); 1301 } 1302 1303 1304/** 1305 * Returns a {@link UnitDefinition} object containing the given <code>unit</code> converted 1306 * to the appropriate SI unit. 1307 <p> 1308 * This method exists because some units can be expressed in terms of 1309 * others when the same physical dimension is involved. For example, one 1310 * hertz is identical to 1 sec<sup>-1</sup>, one litre is equivalent 1311 * to 1 cubic decametre, and so on. 1312 <p> 1313 * @param unit the {@link Unit} object to convert to SI. 1314 <p> 1315 * @return a {@link UnitDefinition} object containing the SI unit. 1316 <p> 1317 * 1318 <p> 1319 * @see Unit#merge(Unit u1, Unit u2) 1320 */ public 1321 static UnitDefinition convertToSI(Unit unit) { 1322 long cPtr = libsbmlJNI.Unit_convertToSI(Unit.getCPtr(unit), unit); 1323 return (cPtr == 0) ? null : new UnitDefinition(cPtr, true); 1324 } 1325 1326 1327/** 1328 * Predicate returning <code>true</code> if 1329 * all the required attributes for this {@link Unit} object 1330 * have been set. 1331 <p> 1332 * The required attributes for a {@link Unit} object are: 1333 * <ul> 1334 * <li> 'kind' 1335 * <li> 'exponent' (required in SBML Level 3; optional in Level 2) 1336 * <li> 'multiplier' (required in SBML Level 3; optional in Level 2) 1337 * <li> 'scale' (required in SBML Level 3; optional in Level 2) 1338 * 1339 * </ul> <p> 1340 * @return <code>true</code> if the required attributes have been set, <code>false</code> 1341 * otherwise. 1342 */ public 1343 boolean hasRequiredAttributes() { 1344 return libsbmlJNI.Unit_hasRequiredAttributes(swigCPtr, this); 1345 } 1346 1347}