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 list of {@link Constraint} objects. 013 <p> 014 * <p> 015 * The various ListOf___ classes in SBML 016 * are merely containers used for organizing the main components of an SBML 017 * model. In libSBML's implementation, ListOf___ 018 * classes are derived from the 019 * intermediate utility class {@link ListOf}, which 020 * is not defined by the SBML specifications but serves as a useful 021 * programmatic construct. {@link ListOf} is itself is in turn derived from {@link SBase}, 022 * which provides all of the various ListOf___ 023 * classes with common features 024 * defined by the SBML specification, such as 'metaid' attributes and 025 * annotations. 026 <p> 027 * Readers may wonder about the motivations for using the ListOf___ 028 * containers in SBML. A simpler approach in XML might be to place the 029 * components all directly at the top level of the model definition. The 030 * choice made in SBML is to group them within XML elements named after 031 * ListOf<em>Classname</em>, in part because it helps organize the 032 * components. More importantly, the fact that the container classes are 033 * derived from {@link SBase} means that software tools can add information <em>about</em> 034 * the lists themselves into each list container's 'annotation'. 035 <p> 036 * @see ListOfFunctionDefinitions 037 * @see ListOfUnitDefinitions 038 * @see ListOfCompartmentTypes 039 * @see ListOfSpeciesTypes 040 * @see ListOfCompartments 041 * @see ListOfSpecies 042 * @see ListOfParameters 043 * @see ListOfInitialAssignments 044 * @see ListOfRules 045 * @see ListOfConstraints 046 * @see ListOfReactions 047 * @see ListOfEvents 048 */ 049 050public class ListOfConstraints extends ListOf { 051 private long swigCPtr; 052 053 protected ListOfConstraints(long cPtr, boolean cMemoryOwn) 054 { 055 super(libsbmlJNI.ListOfConstraints_SWIGUpcast(cPtr), cMemoryOwn); 056 swigCPtr = cPtr; 057 } 058 059 protected static long getCPtr(ListOfConstraints obj) 060 { 061 return (obj == null) ? 0 : obj.swigCPtr; 062 } 063 064 protected static long getCPtrAndDisown (ListOfConstraints obj) 065 { 066 long ptr = 0; 067 068 if (obj != null) 069 { 070 ptr = obj.swigCPtr; 071 obj.swigCMemOwn = false; 072 } 073 074 return ptr; 075 } 076 077 protected void finalize() { 078 delete(); 079 } 080 081 public synchronized void delete() { 082 if (swigCPtr != 0) { 083 if (swigCMemOwn) { 084 swigCMemOwn = false; 085 libsbmlJNI.delete_ListOfConstraints(swigCPtr); 086 } 087 swigCPtr = 0; 088 } 089 super.delete(); 090 } 091 092 093/** 094 * Creates a new {@link ListOfConstraints} object. 095 <p> 096 * The object is constructed such that it is valid for the given SBML 097 * Level and Version combination. 098 <p> 099 * @param level the SBML Level 100 <p> 101 * @param version the Version within the SBML Level 102 <p> 103 * <p> 104 * @throws SBMLConstructorException 105 * Thrown if the given <code>level</code> and <code>version</code> combination are invalid 106 * or if this object is incompatible with the given level and version. 107 <p> 108 * <p> 109 * @note Attempting to add an object to an {@link SBMLDocument} having a different 110 * combination of SBML Level, Version and XML namespaces than the object 111 * itself will result in an error at the time a caller attempts to make the 112 * addition. A parent object must have compatible Level, Version and XML 113 * namespaces. (Strictly speaking, a parent may also have more XML 114 * namespaces than a child, but the reverse is not permitted.) The 115 * restriction is necessary to ensure that an SBML model has a consistent 116 * overall structure. This requires callers to manage their objects 117 * carefully, but the benefit is increased flexibility in how models can be 118 * created by permitting callers to create objects bottom-up if desired. In 119 * situations where objects are not yet attached to parents (e.g., 120 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 121 * libSBML determine such things as whether it is valid to assign a 122 * particular value to an attribute. 123 */ public 124 ListOfConstraints(long level, long version) throws org.sbml.libsbml.SBMLConstructorException { 125 this(libsbmlJNI.new_ListOfConstraints__SWIG_0(level, version), true); 126 } 127 128 129/** 130 * Creates a new {@link ListOfConstraints} object. 131 <p> 132 * The object is constructed such that it is valid for the SBML Level and 133 * Version combination determined by the {@link SBMLNamespaces} object in 134 * <code>sbmlns</code>. 135 <p> 136 * @param sbmlns an {@link SBMLNamespaces} object that is used to determine the 137 * characteristics of the {@link ListOfConstraints} object to be created. 138 <p> 139 * <p> 140 * @throws SBMLConstructorException 141 * Thrown if the given <code>sbmlns</code> is inconsistent or incompatible 142 * with this object. 143 <p> 144 * <p> 145 * @note Attempting to add an object to an {@link SBMLDocument} having a different 146 * combination of SBML Level, Version and XML namespaces than the object 147 * itself will result in an error at the time a caller attempts to make the 148 * addition. A parent object must have compatible Level, Version and XML 149 * namespaces. (Strictly speaking, a parent may also have more XML 150 * namespaces than a child, but the reverse is not permitted.) The 151 * restriction is necessary to ensure that an SBML model has a consistent 152 * overall structure. This requires callers to manage their objects 153 * carefully, but the benefit is increased flexibility in how models can be 154 * created by permitting callers to create objects bottom-up if desired. In 155 * situations where objects are not yet attached to parents (e.g., 156 * {@link SBMLDocument}), knowledge of the intented SBML Level and Version help 157 * libSBML determine such things as whether it is valid to assign a 158 * particular value to an attribute. 159 */ public 160 ListOfConstraints(SBMLNamespaces sbmlns) throws org.sbml.libsbml.SBMLConstructorException { 161 this(libsbmlJNI.new_ListOfConstraints__SWIG_1(SBMLNamespaces.getCPtr(sbmlns), sbmlns), true); 162 } 163 164 165/** 166 * Creates and returns a deep copy of this {@link ListOfConstraints} object. 167 <p> 168 * @return the (deep) copy of this {@link ListOfConstraints} object. 169 */ public 170 ListOfConstraints cloneObject() { 171 long cPtr = libsbmlJNI.ListOfConstraints_cloneObject(swigCPtr, this); 172 return (cPtr == 0) ? null : new ListOfConstraints(cPtr, true); 173 } 174 175 176/** 177 * Returns the libSBML type code for the objects contained in this {@link ListOf} 178 * (i.e., {@link Constraint} objects, if the list is non-empty). 179 <p> 180 * <p> 181 * LibSBML attaches an identifying code to every kind of SBML object. These 182 * are integer constants known as <em>SBML type codes</em>. The names of all 183 * the codes begin with the characters <code>SBML_</code>. 184 * In the Java language interface for libSBML, the 185 * type codes are defined as static integer constants in the interface class 186 * {@link libsbmlConstants}. Note that different Level 3 187 * package plug-ins may use overlapping type codes; to identify the package 188 * to which a given object belongs, call the <code>getPackageName()</code> 189 * method on the object. 190 <p> 191 * @return the SBML type code for the objects contained in this {@link ListOf} 192 * instance: {@link libsbmlConstants#SBML_CONSTRAINT SBML_CONSTRAINT} (default). 193 <p> 194 * @see #getElementName() 195 * @see #getPackageName() 196 */ public 197 int getItemTypeCode() { 198 return libsbmlJNI.ListOfConstraints_getItemTypeCode(swigCPtr, this); 199 } 200 201 202/** 203 * Returns the XML element name of this object. 204 <p> 205 * For {@link ListOfConstraints}, the XML element name is <code>'listOfConstraints'.</code> 206 <p> 207 * @return the name of this element. 208 */ public 209 String getElementName() { 210 return libsbmlJNI.ListOfConstraints_getElementName(swigCPtr, this); 211 } 212 213 214/** 215 * Get a {@link Constraint} from the {@link ListOfConstraints}. 216 <p> 217 * @param n the index number of the {@link Constraint} to get. 218 <p> 219 * @return the nth {@link Constraint} in this {@link ListOfConstraints}. 220 <p> 221 * @see #size() 222 */ public 223 Constraint get(long n) { 224 long cPtr = libsbmlJNI.ListOfConstraints_get__SWIG_0(swigCPtr, this, n); 225 return (cPtr == 0) ? null : new Constraint(cPtr, false); 226 } 227 228 229/** 230 * Removes the nth item from this {@link ListOfConstraints} items and returns a 231 * pointer to it. 232 <p> 233 * The caller owns the returned item and is responsible for deleting it. 234 <p> 235 * @param n the index of the item to remove 236 <p> 237 * @see #size() 238 */ public 239 Constraint remove(long n) { 240 long cPtr = libsbmlJNI.ListOfConstraints_remove(swigCPtr, this, n); 241 return (cPtr == 0) ? null : new Constraint(cPtr, true); 242 } 243 244}