001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.8 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * 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 Version 1 Core: 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 <p> 497 * otherwise. 498 */ public 499 boolean isDimensionless() { 500 return libsbmlJNI.Unit_isDimensionless(swigCPtr, this); 501 } 502 503 504/** 505 * Predicate for testing whether this {@link Unit} is of the kind <code>farad</code> 506 <p> 507 * @return <code>true</code> if the kind of this {@link Unit} is <code>farad</code>, <code>false</code> 508 * otherwise. 509 */ public 510 boolean isFarad() { 511 return libsbmlJNI.Unit_isFarad(swigCPtr, this); 512 } 513 514 515/** 516 * Predicate for testing whether this {@link Unit} is of the kind <code>gram</code> 517 <p> 518 * @return <code>true</code> if the kind of this {@link Unit} is <code>gram</code>, <code>false</code> 519 * otherwise. 520 */ public 521 boolean isGram() { 522 return libsbmlJNI.Unit_isGram(swigCPtr, this); 523 } 524 525 526/** 527 * Predicate for testing whether this {@link Unit} is of the kind <code>gray</code> 528 <p> 529 * @return <code>true</code> if the kind of this {@link Unit} is <code>gray</code>, <code>false</code> 530 * otherwise. 531 */ public 532 boolean isGray() { 533 return libsbmlJNI.Unit_isGray(swigCPtr, this); 534 } 535 536 537/** 538 * Predicate for testing whether this {@link Unit} is of the kind <code>henry</code> 539 <p> 540 * @return <code>true</code> if the kind of this {@link Unit} is <code>henry</code>, <code>false</code> 541 * otherwise. 542 */ public 543 boolean isHenry() { 544 return libsbmlJNI.Unit_isHenry(swigCPtr, this); 545 } 546 547 548/** 549 * Predicate for testing whether this {@link Unit} is of the kind <code>hertz</code> 550 <p> 551 * @return <code>true</code> if the kind of this {@link Unit} is <code>hertz</code>, <code>false</code> 552 * otherwise. 553 */ public 554 boolean isHertz() { 555 return libsbmlJNI.Unit_isHertz(swigCPtr, this); 556 } 557 558 559/** 560 * Predicate for testing whether this {@link Unit} is of the kind <code>item</code> 561 <p> 562 * @return <code>true</code> if the kind of this {@link Unit} is <code>item</code>, <code>false</code> 563 * otherwise. 564 */ public 565 boolean isItem() { 566 return libsbmlJNI.Unit_isItem(swigCPtr, this); 567 } 568 569 570/** 571 * Predicate for testing whether this {@link Unit} is of the kind <code>joule</code> 572 <p> 573 * @return <code>true</code> if the kind of this {@link Unit} is <code>joule</code>, <code>false</code> 574 * otherwise. 575 */ public 576 boolean isJoule() { 577 return libsbmlJNI.Unit_isJoule(swigCPtr, this); 578 } 579 580 581/** 582 * Predicate for testing whether this {@link Unit} is of the kind <code>katal</code> 583 <p> 584 * @return <code>true</code> if the kind of this {@link Unit} is <code>katal</code>, <code>false</code> 585 * otherwise. 586 */ public 587 boolean isKatal() { 588 return libsbmlJNI.Unit_isKatal(swigCPtr, this); 589 } 590 591 592/** 593 * Predicate for testing whether this {@link Unit} is of the kind <code>kelvin</code> 594 <p> 595 * @return <code>true</code> if the kind of this {@link Unit} is <code>kelvin</code>, <code>false</code> 596 * otherwise. 597 */ public 598 boolean isKelvin() { 599 return libsbmlJNI.Unit_isKelvin(swigCPtr, this); 600 } 601 602 603/** 604 * Predicate for testing whether this {@link Unit} is of the kind <code>kilogram</code> 605 <p> 606 * @return <code>true</code> if the kind of this {@link Unit} is <code>kilogram</code>, <code>false</code> 607 * otherwise. 608 */ public 609 boolean isKilogram() { 610 return libsbmlJNI.Unit_isKilogram(swigCPtr, this); 611 } 612 613 614/** 615 * Predicate for testing whether this {@link Unit} is of the kind <code>litre</code> 616 <p> 617 * @return <code>true</code> if the kind of this {@link Unit} is <code>litre</code> or 'liter', 618 * <code>false</code> 619 * otherwise. 620 */ public 621 boolean isLitre() { 622 return libsbmlJNI.Unit_isLitre(swigCPtr, this); 623 } 624 625 626/** 627 * Predicate for testing whether this {@link Unit} is of the kind <code>lumen</code> 628 <p> 629 * @return <code>true</code> if the kind of this {@link Unit} is <code>lumen</code>, <code>false</code> 630 * otherwise. 631 */ public 632 boolean isLumen() { 633 return libsbmlJNI.Unit_isLumen(swigCPtr, this); 634 } 635 636 637/** 638 * Predicate for testing whether this {@link Unit} is of the kind <code>lux</code> 639 <p> 640 * @return <code>true</code> if the kind of this {@link Unit} is <code>lux</code>, <code>false</code> 641 * otherwise. 642 */ public 643 boolean isLux() { 644 return libsbmlJNI.Unit_isLux(swigCPtr, this); 645 } 646 647 648/** 649 * Predicate for testing whether this {@link Unit} is of the kind <code>metre</code> 650 <p> 651 * @return <code>true</code> if the kind of this {@link Unit} is <code>metre</code> or 'meter', 652 * <code>false</code> 653 * otherwise. 654 */ public 655 boolean isMetre() { 656 return libsbmlJNI.Unit_isMetre(swigCPtr, this); 657 } 658 659 660/** 661 * Predicate for testing whether this {@link Unit} is of the kind <code>mole</code> 662 <p> 663 * @return <code>true</code> if the kind of this {@link Unit} is <code>mole</code>, <code>false</code> 664 * otherwise. 665 */ public 666 boolean isMole() { 667 return libsbmlJNI.Unit_isMole(swigCPtr, this); 668 } 669 670 671/** 672 * Predicate for testing whether this {@link Unit} is of the kind <code>newton</code> 673 <p> 674 * @return <code>true</code> if the kind of this {@link Unit} is <code>newton</code>, <code>false</code> 675 * otherwise. 676 */ public 677 boolean isNewton() { 678 return libsbmlJNI.Unit_isNewton(swigCPtr, this); 679 } 680 681 682/** 683 * Predicate for testing whether this {@link Unit} is of the kind <code>ohm</code> 684 <p> 685 * @return <code>true</code> if the kind of this {@link Unit} is <code>ohm</code>, <code>false</code> 686 * otherwise. 687 */ public 688 boolean isOhm() { 689 return libsbmlJNI.Unit_isOhm(swigCPtr, this); 690 } 691 692 693/** 694 * Predicate for testing whether this {@link Unit} is of the kind <code>pascal</code> 695 <p> 696 * @return <code>true</code> if the kind of this {@link Unit} is <code>pascal</code>, <code>false</code> 697 * otherwise. 698 */ public 699 boolean isPascal() { 700 return libsbmlJNI.Unit_isPascal(swigCPtr, this); 701 } 702 703 704/** 705 * Predicate for testing whether this {@link Unit} is of the kind <code>radian</code> 706 <p> 707 * @return <code>true</code> if the kind of this {@link Unit} is <code>radian</code>, <code>false</code> 708 * otherwise. 709 */ public 710 boolean isRadian() { 711 return libsbmlJNI.Unit_isRadian(swigCPtr, this); 712 } 713 714 715/** 716 * Predicate for testing whether this {@link Unit} is of the kind <code>second</code> 717 <p> 718 * @return <code>true</code> if the kind of this {@link Unit} is <code>second</code>, <code>false</code> 719 * otherwise. 720 */ public 721 boolean isSecond() { 722 return libsbmlJNI.Unit_isSecond(swigCPtr, this); 723 } 724 725 726/** 727 * Predicate for testing whether this {@link Unit} is of the kind <code>siemens</code> 728 <p> 729 * @return <code>true</code> if the kind of this {@link Unit} is <code>siemens</code>, <code>false</code> 730 * otherwise. 731 */ public 732 boolean isSiemens() { 733 return libsbmlJNI.Unit_isSiemens(swigCPtr, this); 734 } 735 736 737/** 738 * Predicate for testing whether this {@link Unit} is of the kind <code>sievert</code> 739 <p> 740 * @return <code>true</code> if the kind of this {@link Unit} is <code>sievert</code>, <code>false</code> 741 * otherwise. 742 */ public 743 boolean isSievert() { 744 return libsbmlJNI.Unit_isSievert(swigCPtr, this); 745 } 746 747 748/** 749 * Predicate for testing whether this {@link Unit} is of the kind <code>steradian</code> 750 <p> 751 * @return <code>true</code> if the kind of this {@link Unit} is <code>steradian</code>, <code>false</code> 752 * otherwise. 753 */ public 754 boolean isSteradian() { 755 return libsbmlJNI.Unit_isSteradian(swigCPtr, this); 756 } 757 758 759/** 760 * Predicate for testing whether this {@link Unit} is of the kind <code>tesla</code> 761 <p> 762 * @return <code>true</code> if the kind of this {@link Unit} is <code>tesla</code>, <code>false</code> 763 * otherwise. 764 */ public 765 boolean isTesla() { 766 return libsbmlJNI.Unit_isTesla(swigCPtr, this); 767 } 768 769 770/** 771 * Predicate for testing whether this {@link Unit} is of the kind <code>volt</code> 772 <p> 773 * @return <code>true</code> if the kind of this {@link Unit} is <code>volt</code>, <code>false</code> 774 * otherwise. 775 */ public 776 boolean isVolt() { 777 return libsbmlJNI.Unit_isVolt(swigCPtr, this); 778 } 779 780 781/** 782 * Predicate for testing whether this {@link Unit} is of the kind <code>watt</code> 783 <p> 784 * @return <code>true</code> if the kind of this {@link Unit} is <code>watt</code>, <code>false</code> 785 * otherwise. 786 */ public 787 boolean isWatt() { 788 return libsbmlJNI.Unit_isWatt(swigCPtr, this); 789 } 790 791 792/** 793 * Predicate for testing whether this {@link Unit} is of the kind <code>weber</code> 794 <p> 795 * @return <code>true</code> if the kind of this {@link Unit} is <code>weber</code>, <code>false</code> 796 * otherwise. 797 */ public 798 boolean isWeber() { 799 return libsbmlJNI.Unit_isWeber(swigCPtr, this); 800 } 801 802 803/** 804 * Predicate to test whether the 'kind' attribute of this {@link Unit} is set. 805 <p> 806 * @return <code>true</code> if the 'kind' attribute of this {@link Unit} is set, 807 * <code>false</code> otherwise. 808 */ public 809 boolean isSetKind() { 810 return libsbmlJNI.Unit_isSetKind(swigCPtr, this); 811 } 812 813 814/** 815 * Predicate to test whether the 'exponent' attribute of this {@link Unit} 816 * is set. 817 <p> 818 * @return <code>true</code> if the 'exponent' attribute of this {@link Unit} is set, 819 * <code>false</code> otherwise. 820 */ public 821 boolean isSetExponent() { 822 return libsbmlJNI.Unit_isSetExponent(swigCPtr, this); 823 } 824 825 826/** 827 * Predicate to test whether the 'scale' attribute of this {@link Unit} 828 * is set. 829 <p> 830 * @return <code>true</code> if the 'scale' attribute of this {@link Unit} is set, 831 * <code>false</code> otherwise. 832 */ public 833 boolean isSetScale() { 834 return libsbmlJNI.Unit_isSetScale(swigCPtr, this); 835 } 836 837 838/** 839 * Predicate to test whether the 'multiplier' attribute of this {@link Unit} 840 * is set. 841 <p> 842 * @return <code>true</code> if the 'multiplier' attribute of this {@link Unit} is set, 843 * <code>false</code> otherwise. 844 */ public 845 boolean isSetMultiplier() { 846 return libsbmlJNI.Unit_isSetMultiplier(swigCPtr, this); 847 } 848 849 850/** 851 * Predicate to test whether the 'offset' attribute of this {@link Unit} 852 * is set. 853 <p> 854 * @return <code>true</code> if the 'offset' attribute of this {@link Unit} is set, 855 * <code>false</code> otherwise. 856 <p> 857 * <p> 858 * @warning <span class='warning'>The 'offset' attribute is only available in 859 * SBML Level 2 Version 1. This attribute is not present in SBML 860 * Level 2 Version 2 or above. When producing SBML models using 861 * these later specifications, modelers and software tools need to account 862 * for units with offsets explicitly. The SBML specification document 863 * offers a number of suggestions for how to achieve this. LibSBML methods 864 * such as this one related to 'offset' are retained for compatibility with 865 * earlier versions of SBML Level 2, but their use is strongly 866 * discouraged.</span> 867 */ public 868 boolean isSetOffset() { 869 return libsbmlJNI.Unit_isSetOffset(swigCPtr, this); 870 } 871 872 873/** 874 * Sets the 'kind' attribute value of this {@link Unit}. 875 <p> 876 * @param kind a unit identifier chosen from the set of constants whose 877 * names begin with <code>UNIT_KIND_</code> in <code><a 878 * href='libsbmlConstants.html'>libsbmlConstants</a></code>. 879 <p> 880 * <p> 881 * @return integer value indicating success/failure of the 882 * function. The possible values 883 * returned by this function are: 884 * <ul> 885 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 886 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 887 * </ul> 888 */ public 889 int setKind(int kind) { 890 return libsbmlJNI.Unit_setKind(swigCPtr, this, kind); 891 } 892 893 894/** 895 * Sets the 'exponent' attribute value of this {@link Unit}. 896 <p> 897 * @param value the integer to which the attribute 'exponent' should be set 898 <p> 899 * <p> 900 * @return integer value indicating success/failure of the 901 * function. The possible values 902 * returned by this function are: 903 * <ul> 904 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 905 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 906 * </ul> 907 */ public 908 int setExponent(int value) { 909 return libsbmlJNI.Unit_setExponent__SWIG_0(swigCPtr, this, value); 910 } 911 912 913/** 914 * Sets the 'exponent' attribute value of this {@link Unit}. 915 <p> 916 * @param value the double to which the attribute 'exponent' should be set 917 <p> 918 * <p> 919 * @return integer value indicating success/failure of the 920 * function. The possible values 921 * returned by this function are: 922 * <ul> 923 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 924 * </ul> 925 */ public 926 int setExponent(double value) { 927 return libsbmlJNI.Unit_setExponent__SWIG_1(swigCPtr, this, value); 928 } 929 930 931/** 932 * Sets the 'scale' attribute value of this {@link Unit}. 933 <p> 934 * @param value the integer to which the attribute 'scale' should be set 935 <p> 936 * <p> 937 * @return integer value indicating success/failure of the 938 * function. The possible values 939 * returned by this function are: 940 * <ul> 941 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 942 * </ul> 943 */ public 944 int setScale(int value) { 945 return libsbmlJNI.Unit_setScale(swigCPtr, this, value); 946 } 947 948 949/** 950 * Sets the 'multipler' attribute value of this {@link Unit}. 951 <p> 952 * @param value the floating-point value to which the attribute 953 * 'multiplier' should be set 954 <p> 955 * <p> 956 * @return integer value indicating success/failure of the 957 * function. The possible values 958 * returned by this function are: 959 * <ul> 960 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 961 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 962 * </ul> 963 */ public 964 int setMultiplier(double value) { 965 return libsbmlJNI.Unit_setMultiplier(swigCPtr, this, value); 966 } 967 968 969/** 970 * Sets the 'offset' attribute value of this {@link Unit}. 971 <p> 972 * @param value the float-point value to which the attribute 'offset' 973 * should set 974 <p> 975 * <p> 976 * @return integer value indicating success/failure of the 977 * function. The possible values 978 * returned by this function are: 979 * <ul> 980 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 981 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 982 * 983 * </ul> <p> 984 * <p> 985 * @warning <span class='warning'>The 'offset' attribute is only available in 986 * SBML Level 2 Version 1. This attribute is not present in SBML 987 * Level 2 Version 2 or above. When producing SBML models using 988 * these later specifications, modelers and software tools need to account 989 * for units with offsets explicitly. The SBML specification document 990 * offers a number of suggestions for how to achieve this. LibSBML methods 991 * such as this one related to 'offset' are retained for compatibility with 992 * earlier versions of SBML Level 2, but their use is strongly 993 * discouraged.</span> 994 */ public 995 int setOffset(double value) { 996 return libsbmlJNI.Unit_setOffset(swigCPtr, this, value); 997 } 998 999 1000/** 1001 * Unsets the 'kind' attribute value of this {@link Unit}. 1002 <p> 1003 * <p> 1004 * @return integer value indicating success/failure of the 1005 * function. The possible values 1006 * returned by this function are: 1007 * <ul> 1008 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1009 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 1010 * </ul> 1011 */ public 1012 int unsetKind() { 1013 return libsbmlJNI.Unit_unsetKind(swigCPtr, this); 1014 } 1015 1016 1017/** 1018 * Unsets the 'exponent' attribute value of this {@link Unit}. 1019 <p> 1020 * <p> 1021 * @return integer value indicating success/failure of the 1022 * function. The possible values 1023 * returned by this function are: 1024 * <ul> 1025 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1026 * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE} 1027 * </ul> 1028 */ public 1029 int unsetExponent() { 1030 return libsbmlJNI.Unit_unsetExponent(swigCPtr, this); 1031 } 1032 1033 1034/** 1035 * Unsets the 'scale' attribute value of this {@link Unit}. 1036 <p> 1037 * <p> 1038 * @return integer value indicating success/failure of the 1039 * function. The possible values 1040 * returned by this function are: 1041 * <ul> 1042 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1043 * </ul> 1044 */ public 1045 int unsetScale() { 1046 return libsbmlJNI.Unit_unsetScale(swigCPtr, this); 1047 } 1048 1049 1050/** 1051 * Unsets the 'multipler' attribute value of this {@link Unit}. 1052 <p> 1053 * <p> 1054 * @return integer value indicating success/failure of the 1055 * function. The possible values 1056 * returned by this function are: 1057 * <ul> 1058 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1059 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 1060 * </ul> 1061 */ public 1062 int unsetMultiplier() { 1063 return libsbmlJNI.Unit_unsetMultiplier(swigCPtr, this); 1064 } 1065 1066 1067/** 1068 * Unsets the 'offset' attribute value of this {@link Unit}. 1069 <p> 1070 * <p> 1071 * @return integer value indicating success/failure of the 1072 * function. The possible values 1073 * returned by this function are: 1074 * <ul> 1075 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 1076 * <li> {@link libsbmlConstants#LIBSBML_UNEXPECTED_ATTRIBUTE LIBSBML_UNEXPECTED_ATTRIBUTE} 1077 * 1078 * </ul> <p> 1079 * <p> 1080 * @warning <span class='warning'>The 'offset' attribute is only available in 1081 * SBML Level 2 Version 1. This attribute is not present in SBML 1082 * Level 2 Version 2 or above. When producing SBML models using 1083 * these later specifications, modelers and software tools need to account 1084 * for units with offsets explicitly. The SBML specification document 1085 * offers a number of suggestions for how to achieve this. LibSBML methods 1086 * such as this one related to 'offset' are retained for compatibility with 1087 * earlier versions of SBML Level 2, but their use is strongly 1088 * discouraged.</span> 1089 */ public 1090 int unsetOffset() { 1091 return libsbmlJNI.Unit_unsetOffset(swigCPtr, this); 1092 } 1093 1094 1095/** 1096 * Returns the libSBML type code of this object instance. 1097 <p> 1098 * <p> 1099 * LibSBML attaches an identifying code to every kind of SBML object. These 1100 * are integer constants known as <em>SBML type codes</em>. The names of all 1101 * the codes begin with the characters <code>SBML_</code>. 1102 * In the Java language interface for libSBML, the 1103 * type codes are defined as static integer constants in the interface class 1104 * {@link libsbmlConstants}. Note that different Level 3 1105 * package plug-ins may use overlapping type codes; to identify the package 1106 * to which a given object belongs, call the <code>getPackageName()</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 Level 3 package plug-ins. 1115 * Thus, to identifiy the correct code, <strong>it is necessary to invoke 1116 * 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 1139 * predefined SBML unit. 1140 <p> 1141 * @param name a string to be tested against the predefined unit names 1142 <p> 1143 * @param level the Level of SBML for which the determination should be 1144 * made. This is necessary because there are a few small differences 1145 * in allowed units between SBML Level 1 and Level 2. 1146 <p> 1147 * @return <code>true</code> if <code>name</code> is one of the five SBML predefined unit 1148 * identifiers (<code>'substance'</code>, <code>'volume'</code>, <code>'area'</code>, <code>'length'</code> or 1149 * <code>'time'</code>), <code>false</code> otherwise. 1150 <p> 1151 * @note The predefined unit identifiers <code>'length'</code> and <code>'area'</code> were 1152 * added in Level 2 Version 1. 1153 <p> 1154 * 1155 */ public 1156 static boolean isBuiltIn(String name, long level) { 1157 return libsbmlJNI.Unit_isBuiltIn(name, level); 1158 } 1159 1160 1161/** 1162 * Predicate to test whether a given string is the name of a valid 1163 * base unit in SBML (such as <code>'gram'</code> or <code>'mole'</code>). 1164 <p> 1165 * This method exists because prior to SBML Level 2 Version 3, 1166 * an enumeration called <code>UnitKind</code> was defined by SBML. This enumeration 1167 * was removed in SBML Level 2 Version 3 and its values were 1168 * folded into the space of values of a type called <code>UnitSId.</code> This method 1169 * therefore has less significance in SBML Level 2 Version 3 1170 * and Level 2 Version 4, but remains for backward 1171 * compatibility and support for reading models in older Versions of 1172 * Level 2. 1173 <p> 1174 * @param name a string to be tested 1175 <p> 1176 * @param level a long integer representing the SBML specification 1177 * Level 1178 <p> 1179 * @param version a long integer representing the SBML specification 1180 * Version 1181 <p> 1182 * @return <code>true</code> if name is a valid SBML UnitKind, <code>false</code> otherwise 1183 <p> 1184 * @note The allowed unit names differ between SBML Levels 1 1185 * and 2 and again slightly between Level 2 Versions 1 1186 * and 2. 1187 <p> 1188 * 1189 */ public 1190 static boolean isUnitKind(String name, long level, long version) { 1191 return libsbmlJNI.Unit_isUnitKind(name, level, version); 1192 } 1193 1194 1195/** 1196 * Predicate returning <code>true</code> if two 1197 * {@link Unit} objects are identical. 1198 <p> 1199 * Two {@link Unit} objects are considered to be <em>identical</em> if they match in 1200 * all attributes. (Contrast this to the method areEquivalent(Unit u1, Unit u2), which compares {@link Unit} objects only with respect 1201 * to certain attributes.) 1202 <p> 1203 * @param unit1 the first {@link Unit} object to compare 1204 * @param unit2 the second {@link Unit} object to compare 1205 <p> 1206 * @return <code>true</code> if all the attributes of unit1 are identical 1207 * to the attributes of unit2, <code>false</code> otherwise. 1208 <p> 1209 * 1210 <p> 1211 * @see Unit#areEquivalent(Unit u1, Unit u2) 1212 */ public 1213 static boolean areIdentical(Unit unit1, Unit unit2) { 1214 return libsbmlJNI.Unit_areIdentical(Unit.getCPtr(unit1), unit1, Unit.getCPtr(unit2), unit2); 1215 } 1216 1217 1218/** 1219 * Predicate returning <code>true</code> if 1220 * {@link Unit} objects are equivalent. 1221 <p> 1222 * Two {@link Unit} objects are considered to be <em>equivalent</em> either if (1) both 1223 * have a 'kind' attribute value of <code>dimensionless</code>, or (2) their 'kind', 1224 * 'exponent' and (for SBML Level 2 Version 1) 'offset' 1225 * attribute values are equal. (Contrast this to the method 1226 * areIdentical(Unit, Unit), which compares {@link Unit} objects with respect to all 1227 * attributes, not just the 'kind' and 'exponent'.) 1228 <p> 1229 * @param unit1 the first {@link Unit} object to compare 1230 * @param unit2 the second {@link Unit} object to compare 1231 <p> 1232 * @return <code>true</code> if the 'kind' and 'exponent' attributes of unit1 are 1233 * identical to the kind and exponent attributes of unit2, <code>false</code> 1234 * otherwise. 1235 <p> 1236 * 1237 <p> 1238 * @see Unit#areIdentical(Unit u1, Unit u2) 1239 */ public 1240 static boolean areEquivalent(Unit unit1, Unit unit2) { 1241 return libsbmlJNI.Unit_areEquivalent(Unit.getCPtr(unit1), unit1, Unit.getCPtr(unit2), unit2); 1242 } 1243 1244 1245/** 1246 * Manipulates the attributes of the {@link Unit} to express the unit with the 1247 * value of the scale attribute reduced to zero. 1248 <p> 1249 * For example, 1 millimetre can be expressed as a {@link Unit} with kind= 1250 * <code>'metre'</code> multiplier=<code>'1'</code> scale=<code>'-3'</code> exponent=<code>'1'.</code> It can also be 1251 * expressed as a {@link Unit} with kind=<code>'metre'</code> 1252 * multiplier=<code>'0.001'</code> scale=<code>'0'</code> exponent=<code>'1'.</code> 1253 <p> 1254 * @param unit the {@link Unit} object to manipulate. 1255 <p> 1256 * <p> 1257 * @return integer value indicating success/failure of the 1258 * function. The possible values 1259 * returned by this function are: 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}