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