001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.12 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * <span class="pkg-marker pkg-color-comp"><a href="group__comp.html">comp</a></span> 013 Extension of {@link SBase}. 014 <p> 015 * The {@link CompSBasePlugin} class inherits from the {@link SBasePlugin} class, and 016 * codifies the extensions to the {@link SBase} class defined in the <a href='../../../extensions-summary.html#comp'>Hierarchical Model Composition</a> 017 * (“comp”) package. This extension allows the modeler to define 018 * one or more submodel elements which the parent {@link SBase} object replaces, 019 * and/or a single submodel element which replaces the parent {@link SBase} object. 020<p> 021 * This is accomplished through the addition of an optional {@link ListOfReplacedElements} 022 * child, which may contain one or more {@link ReplacedElement} objects, each of which 023 * references a submodel object to be replaced by the containing {@link SBase} object, 024 * and through the addition of a single optional {@link ReplacedBy} child, which 025 * references a submodel object which is to replace the containing {@link SBase} object. 026<p> 027 * If a single {@link SBase} element both contains a {@link ListOfReplacedElements} and has a {@link ReplacedBy} 028 * child, it and all the referenced {@link ReplacedElement} objects are to be replaced 029 * by the object referenced by the {@link ReplacedBy} element. 030 <p> 031 * @see ReplacedElement 032 * @see ReplacedBy 033 */ 034 035public class CompSBasePlugin extends SBasePlugin { 036 private long swigCPtr; 037 038 protected CompSBasePlugin(long cPtr, boolean cMemoryOwn) 039 { 040 super(libsbmlJNI.CompSBasePlugin_SWIGUpcast(cPtr), cMemoryOwn); 041 swigCPtr = cPtr; 042 } 043 044 protected static long getCPtr(CompSBasePlugin obj) 045 { 046 return (obj == null) ? 0 : obj.swigCPtr; 047 } 048 049 protected static long getCPtrAndDisown (CompSBasePlugin obj) 050 { 051 long ptr = 0; 052 053 if (obj != null) 054 { 055 ptr = obj.swigCPtr; 056 obj.swigCMemOwn = false; 057 } 058 059 return ptr; 060 } 061 062 protected void finalize() { 063 delete(); 064 } 065 066 public synchronized void delete() { 067 if (swigCPtr != 0) { 068 if (swigCMemOwn) { 069 swigCMemOwn = false; 070 libsbmlJNI.delete_CompSBasePlugin(swigCPtr); 071 } 072 swigCPtr = 0; 073 } 074 super.delete(); 075 } 076 077 078/** 079 * Creates a new {@link CompSBasePlugin} object using the given parameters. 080 <p> 081 * <p> 082 * In the XML representation of an SBML document, XML namespaces are used to 083 * identify the origin of each XML construct used. XML namespaces are 084 * identified by their unique resource identifiers (URIs). The core SBML 085 * specifications stipulate the namespaces that must be used for core SBML 086 * constructs; for example, all XML elements that belong to SBML Level 3 087 * Version 1 Core must be placed in the XML namespace identified by the URI 088 * <code>'http://www.sbml.org/sbml/level3/version1/core'</code>. Individual 089 * SBML Level 3 packages define their own XML namespaces; for example, 090 * all elements belonging to the SBML Level 3 Layout Version 1 091 * package must be placed in the XML namespace 092 * <code>'http://www.sbml.org/sbml/level3/version1/layout/version1/'</code>. 093 <p> 094 * <p> 095 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces 096 * information. It is used to communicate the SBML Level, Version, and (in 097 * Level 3) packages used in addition to SBML Level 3 Core. A 098 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an 099 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object 100 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments. 101 <p> 102 * @param uri the URI of the SBML Level 3 package implemented by 103 * this libSBML package extension. 104 <p> 105 * @param prefix the XML namespace prefix being used for the package. 106 <p> 107 * @param compns the namespaces object for the package. 108 */ public 109 CompSBasePlugin(String uri, String prefix, CompPkgNamespaces compns) { 110 this(libsbmlJNI.new_CompSBasePlugin__SWIG_0(uri, prefix, CompPkgNamespaces.getCPtr(compns), compns), true); 111 } 112 113 114/** 115 * Copy constructor. Creates a copy of this {@link CompSBasePlugin} object. 116 <p> 117 * @param orig the instance to copy. 118 */ public 119 CompSBasePlugin(CompSBasePlugin orig) { 120 this(libsbmlJNI.new_CompSBasePlugin__SWIG_1(CompSBasePlugin.getCPtr(orig), orig), true); 121 } 122 123 124/** 125 * Creates and returns a deep copy of this {@link CompSBasePlugin} object. 126 <p> 127 * @return a (deep) copy of this {@link CompSBasePlugin} object. 128 */ public 129 SBasePlugin cloneObject() { 130 long cPtr = libsbmlJNI.CompSBasePlugin_cloneObject(swigCPtr, this); 131 return (cPtr == 0) ? null : new CompSBasePlugin(cPtr, true); 132 } 133 134 135/** * @internal */ public 136 SBase createObject(XMLInputStream stream) { 137 return libsbml.DowncastSBase(libsbmlJNI.CompSBasePlugin_createObject(swigCPtr, this, XMLInputStream.getCPtr(stream), stream), false); 138} 139 140 141/** 142 * Returns the first child element found that has the given <code>id</code> in the 143 * model-wide SId namespace, or <code>null</code> if no such object is found. 144 <p> 145 * @param id string representing the id of the object to find. 146 <p> 147 * @return a pointer to the {@link SBase} element with the given <code>id</code>. 148 */ public 149 SBase getElementBySId(String id) { 150 return libsbml.DowncastSBase(libsbmlJNI.CompSBasePlugin_getElementBySId(swigCPtr, this, id), false); 151} 152 153 154/** 155 * Returns the first child element it can find with the given <code>metaid</code>, or 156 * itself if it has the given <code>metaid</code>, or <code>null</code> if no such object is 157 * found. 158 <p> 159 * @param metaid string representing the metaid of the object to find. 160 <p> 161 * @return a pointer to the {@link SBase} element with the given <code>metaid</code>. 162 */ public 163 SBase getElementByMetaId(String metaid) { 164 return libsbml.DowncastSBase(libsbmlJNI.CompSBasePlugin_getElementByMetaId(swigCPtr, this, metaid), false); 165} 166 167 168/** 169 * Returns the {@link ListOf} object that holds all replacedElements. 170 <p> 171 * @return the {@link ListOf} object that holds all replacedElements. 172 */ public 173 ListOfReplacedElements getListOfReplacedElements() { 174 long cPtr = libsbmlJNI.CompSBasePlugin_getListOfReplacedElements(swigCPtr, this); 175 return (cPtr == 0) ? null : new ListOfReplacedElements(cPtr, false); 176 } 177 178 179/** 180 * Returns the {@link ReplacedElement} with the given index. 181 <p> 182 * @param n the index number of the {@link ReplacedElement} to get. 183 <p> 184 * @return the nth {@link ReplacedElement} in the {@link ListOfReplacedElements}. If the 185 * index is invalid, <code>null</code> is returned. 186 */ public 187 ReplacedElement getReplacedElement(long n) { 188 long cPtr = libsbmlJNI.CompSBasePlugin_getReplacedElement__SWIG_0(swigCPtr, this, n); 189 return (cPtr == 0) ? null : new ReplacedElement(cPtr, false); 190 } 191 192 193/** 194 * Adds a copy of the given {@link ReplacedElement} object to the list of ReplacedElements. 195 <p> 196 * @param replacedElement the {@link ReplacedElement} object to be added to the 197 * list of ReplacedElements. Fails if the added {@link ReplacedElement} is <code>null</code>, 198 * does not match the level/version/package of the parent object, or cannot 199 * be added to the list of replaced elements. 200 <p> 201 * <p> 202 * @return integer value indicating success/failure of the 203 * function. The possible values 204 * returned by this function are: 205 * <ul> 206 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 207 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 208 * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH} 209 * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH} 210 * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_PKG_VERSION_MISMATCH} 211 * </ul> 212 */ public 213 int addReplacedElement(ReplacedElement replacedElement) { 214 return libsbmlJNI.CompSBasePlugin_addReplacedElement(swigCPtr, this, ReplacedElement.getCPtr(replacedElement), replacedElement); 215 } 216 217 218/** 219 * Returns the number of ReplacedElements for this {@link CompSBasePlugin}. 220 <p> 221 * @return the number of ReplacedElements for this {@link CompSBasePlugin}. 222 */ public 223 long getNumReplacedElements() { 224 return libsbmlJNI.CompSBasePlugin_getNumReplacedElements(swigCPtr, this); 225 } 226 227 228/** 229 * Remove all ReplacedElements, if any exist. 230 */ public 231 void clearReplacedElements() { 232 libsbmlJNI.CompSBasePlugin_clearReplacedElements(swigCPtr, this); 233 } 234 235 236/** 237 * Creates a {@link ReplacedElement} object, adds it to the end of the 238 * {@link ReplacedElement} objects list and returns a pointer to the newly 239 * created object. 240 <p> 241 * @return a newly created {@link ReplacedElement} object. 242 */ public 243 ReplacedElement createReplacedElement() { 244 long cPtr = libsbmlJNI.CompSBasePlugin_createReplacedElement(swigCPtr, this); 245 return (cPtr == 0) ? null : new ReplacedElement(cPtr, false); 246 } 247 248 249/** 250 * Removes the {@link ReplacedElement} with the given index. 251 <p> 252 * A pointer to the {@link ReplacedElement} that was removed is returned. 253 * If no {@link ReplacedElement} has been removed, <code>null</code> is returned. 254 <p> 255 * @param index the index of the {@link ReplacedElement} object to remove. 256 <p> 257 * @return the {@link ReplacedElement} object removed. As mentioned above, 258 * the caller owns the returned object. <code>null</code> is returned if 259 * the given index is out of range. 260 */ public 261 ReplacedElement removeReplacedElement(long index) { 262 long cPtr = libsbmlJNI.CompSBasePlugin_removeReplacedElement(swigCPtr, this, index); 263 return (cPtr == 0) ? null : new ReplacedElement(cPtr, false); 264 } 265 266 267/** 268 * Get the child {@link ReplacedBy} of this {@link SBase}. 269 <p> 270 * @return the {@link ReplacedBy} child of this {@link SBase}. 271 */ public 272 ReplacedBy getReplacedBy() { 273 long cPtr = libsbmlJNI.CompSBasePlugin_getReplacedBy__SWIG_0(swigCPtr, this); 274 return (cPtr == 0) ? null : new ReplacedBy(cPtr, false); 275 } 276 277 278/** 279 * Predicate for testing whether the {@link ReplacedBy} for this {@link SBase} is set. 280 <p> 281 * @return <code>true</code> if the {@link ReplacedBy} of this {@link SBase} is set, <code>false</code> 282 * otherwise. 283 */ public 284 boolean isSetReplacedBy() { 285 return libsbmlJNI.CompSBasePlugin_isSetReplacedBy(swigCPtr, this); 286 } 287 288 289/** 290 * Sets the {@link ReplacedBy} definition of this {@link SBase} to a copy of the given 291 * {@link ReplacedBy} object instance. 292 <p> 293 * This method fails if the added {@link ReplacedBy} does not match the 294 * level/version/package of the parent object or if the added {@link ReplacedBy} 295 * cannot be copied. 296 <p> 297 * @param replacedBy the {@link ReplacedBy} object instance to use. 298 <p> 299 * <p> 300 * @return integer value indicating success/failure of the 301 * function. The possible values 302 * returned by this function are: 303 * <ul> 304 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 305 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 306 * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH} 307 * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH} 308 * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_PKG_VERSION_MISMATCH} 309 * </ul> 310 */ public 311 int setReplacedBy(ReplacedBy replacedBy) { 312 return libsbmlJNI.CompSBasePlugin_setReplacedBy(swigCPtr, this, ReplacedBy.getCPtr(replacedBy), replacedBy); 313 } 314 315 316/** 317 * Creates a new, empty {@link ReplacedBy}, adds it to this {@link CompSBasePlugin} and 318 * returns the created {@link ReplacedBy}. 319 <p> 320 * @return the newly created {@link ReplacedBy} object instance. 321 */ public 322 ReplacedBy createReplacedBy() { 323 long cPtr = libsbmlJNI.CompSBasePlugin_createReplacedBy(swigCPtr, this); 324 return (cPtr == 0) ? null : new ReplacedBy(cPtr, false); 325 } 326 327 328/** 329 * Unsets the child {@link ReplacedBy} of this {@link SBase}. 330 <p> 331 * <p> 332 * @return integer value indicating success/failure of the 333 * function. The possible values 334 * returned by this function are: 335 * <ul> 336 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 337 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 338 * </ul> 339 */ public 340 int unsetReplacedBy() { 341 return libsbmlJNI.CompSBasePlugin_unsetReplacedBy(swigCPtr, this); 342 } 343 344 345/** 346 * Helper to log a common type of error. 347 */ public 348 void logInvalidId(String attribute, String wrongattribute) { 349 libsbmlJNI.CompSBasePlugin_logInvalidId(swigCPtr, this, attribute, wrongattribute); 350 } 351 352 353/** * @internal */ public 354 void connectToChild() { 355 libsbmlJNI.CompSBasePlugin_connectToChild(swigCPtr, this); 356 } 357 358 359/** * @internal */ public 360 void connectToParent(SBase parent) { 361 libsbmlJNI.CompSBasePlugin_connectToParent(swigCPtr, this, SBase.getCPtr(parent), parent); 362 } 363 364 365/** * @internal */ public 366 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) { 367 libsbmlJNI.CompSBasePlugin_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag); 368 } 369 370}