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 * <span class="pkg-marker pkg-color-comp"><a href="group__comp.html">comp</a></span>
013 Convenience class.
014 <p>
015 * The {@link Replacing} class does not exist officialy in the the 
016 * 'Hierarchical Model Composition' package
017 * (&ldquo;comp&rdquo;), but is implemented here as a convenience subclass of
018 * the {@link ReplacedElement} and {@link ReplacedBy} classes, since both of those classes
019 * define a 'submodelRef' attribute.
020 <p>
021 * The required attribute 'submodelRef' takes a value of type
022 * SIdRef, which must be the identifier of a {@link Submodel} object in
023 * the containing model.  The model referenced by the
024 * {@link Submodel} object establishes the object namespaces for the
025 * 'portRef', 'idRef', 'unitRef' and 'metaIdRef'
026 * attributes: only objects within the {@link Model} object may be referenced by
027 * those attributes.
028 */
029
030public class Replacing extends SBaseRef {
031   private long swigCPtr;
032
033   protected Replacing(long cPtr, boolean cMemoryOwn)
034   {
035     super(libsbmlJNI.Replacing_SWIGUpcast(cPtr), cMemoryOwn);
036     swigCPtr = cPtr;
037   }
038
039   protected static long getCPtr(Replacing obj)
040   {
041     return (obj == null) ? 0 : obj.swigCPtr;
042   }
043
044   protected static long getCPtrAndDisown (Replacing obj)
045   {
046     long ptr = 0;
047
048     if (obj != null)
049     {
050       ptr             = obj.swigCPtr;
051       obj.swigCMemOwn = false;
052     }
053
054     return ptr;
055   }
056
057  protected void finalize() {
058    delete();
059  }
060
061  public synchronized void delete() {
062    if (swigCPtr != 0) {
063      if (swigCMemOwn) {
064        swigCMemOwn = false;
065        libsbmlJNI.delete_Replacing(swigCPtr);
066      }
067      swigCPtr = 0;
068    }
069    super.delete();
070  }
071
072  
073/**
074   * Returns the value of the 'submodelRef' attribute of this {@link SBaseRef}.
075   <p>
076   * @return the value of the 'submodelRef' attribute of this {@link SBaseRef}.
077   */ public
078 String getSubmodelRef() {
079    return libsbmlJNI.Replacing_getSubmodelRef(swigCPtr, this);
080  }
081
082  
083/**
084   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
085   * {@link SBaseRef}'s 'submodelRef' attribute has been set.
086   <p>
087   * @return <code>true</code> if this {@link SBaseRef}'s 'submodelRef' attribute has been set, 
088   * otherwise <code>false</code> is returned.
089   */ public
090 boolean isSetSubmodelRef() {
091    return libsbmlJNI.Replacing_isSetSubmodelRef(swigCPtr, this);
092  }
093
094  
095/**
096   * Sets the value of the 'submodelRef' attribute of this {@link SBaseRef}.  Fails
097   * if the id is not a valid syntax for an SIdRef.
098   <p>
099   * <p>
100 * @return integer value indicating success/failure of the
101 * function.   The possible values
102 * returned by this function are:
103   * <ul>
104   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
105   * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}
106   * </ul>
107   */ public
108 int setSubmodelRef(String id) {
109    return libsbmlJNI.Replacing_setSubmodelRef(swigCPtr, this, id);
110  }
111
112  
113/**
114   * Unsets the value of the 'SubmodelRef' attribute of this {@link SBaseRef}.
115   <p>
116   * <p>
117 * @return integer value indicating success/failure of the
118 * function.   The possible values
119 * returned by this function are:
120   * <ul>
121   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
122   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
123   * </ul>
124   */ public
125 int unsetSubmodelRef() {
126    return libsbmlJNI.Replacing_unsetSubmodelRef(swigCPtr, this);
127  }
128
129  
130/**
131   * Returns true if getNumReferents() is exactly 1 and if the submodelRef is set.
132   <p>
133   * @return boolean: 'true' if the attributes are correctly set; 'false' if not.
134   */ public
135 boolean hasRequiredAttributes() {
136    return libsbmlJNI.Replacing_hasRequiredAttributes(swigCPtr, this);
137  }
138
139  
140/**
141   * Finds and stores the referenced object.  Finds the {@link Submodel} to which
142   * it refers, getting the instantiated {@link Model} inside that {@link Submodel}, calling
143   * 'getReferencedElementFrom' on that model, and storing the result.
144   <p>
145   * <p>
146 * @return integer value indicating success/failure of the
147 * function.   The possible values
148 * returned by this function are:
149   * <ul>
150   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
151   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
152   * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}
153   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
154   * </ul>
155   */ public
156 int saveReferencedElement() {
157    return libsbmlJNI.Replacing_saveReferencedElement(swigCPtr, this);
158  }
159
160  
161/**
162   * <p>
163 * Replaces all uses of a given <code>SIdRef</code> type attribute value with another
164 * value.
165 <p>
166 * <p>
167 * In SBML, object identifiers are of a data type called <code>SId</code>.
168 * In SBML Level&nbsp;3, an explicit data type called <code>SIdRef</code> was
169 * introduced for attribute values that refer to <code>SId</code> values; in
170 * previous Levels of SBML, this data type did not exist and attributes were
171 * simply described to as 'referring to an identifier', but the effective
172 * data type was the same as <code>SIdRef</code>in Level&nbsp;3.  These and
173 * other methods of libSBML refer to the type <code>SIdRef</code> for all
174 * Levels of SBML, even if the corresponding SBML specification did not
175 * explicitly name the data type.
176 <p>
177 * This method works by looking at all attributes and (if appropriate)
178 * mathematical formulas in MathML content, comparing the referenced
179 * identifiers to the value of <code>oldid</code>.  If any matches are found, the
180 * matching values are replaced with <code>newid</code>.  The method does <em>not</em>
181 * descend into child elements.
182 <p>
183 * @param oldid the old identifier
184 * @param newid the new identifier
185   */ public
186 void renameSIdRefs(String oldid, String newid) {
187    libsbmlJNI.Replacing_renameSIdRefs(swigCPtr, this, oldid, newid);
188  }
189
190  
191/**
192   * DEPRECATED FUNCTION:  DO NOT USE
193   <p>
194   * To retain old functionality, this function calls performReplacementAndCollect,
195   * and then actually removes the now-redundant element.  However, this can lead
196   * to doubly-deleted elements, as well as the incorrect interpretation of some
197   * models.  The replacement function performReplacementAndCollect
198   * has been marked protected, in the hopes that people will instead simply
199   * use CompModelPlugin.instantiateSubmodels, which hides all the complexity while
200   * still allowing access to a non-flattened version of a hierarchical model.
201   */ public
202 int performReplacement() {
203    return libsbmlJNI.Replacing_performReplacement(swigCPtr, this);
204  }
205
206  
207/** * @internal */ public
208 int replaceWithAndMaybeDelete(SBase replacement, boolean deleteme, ASTNode conversionFactor) {
209    return libsbmlJNI.Replacing_replaceWithAndMaybeDelete(swigCPtr, this, SBase.getCPtr(replacement), replacement, deleteme, ASTNode.getCPtr(conversionFactor), conversionFactor);
210  }
211
212}