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 Registry of all SBML resolvers. 014 <p> 015 * <p style='color: #777; font-style: italic'> 016This class of objects is defined by libSBML only and has no direct 017equivalent in terms of SBML components. It is a class used in 018the implementation of extra functionality provided by libSBML. 019</p> 020 021 <p> 022 * LibSBML provides facilities for resolving SBML documents in various ways 023 * from a given URI. Resolvers are implemented as objects derived from the 024 * class {@link SBMLResolver}. 025 <p> 026 * The resolver registry maintains a list of known resolvers and provides 027 * methods for discovering them. It is implemented as a singleton object of 028 * class {@link SBMLResolverRegistry}. Callers can use the method 029 * {@link SBMLResolverRegistry#getNumResolvers()} to find out how many resolvers are 030 * registered, then use {@link SBMLResolverRegistry#getResolverByIndex(int)} to iterate over each one; 031 <p> 032 * @see SBMLFileResolver 033 */ 034 035public class SBMLResolverRegistry { 036 private long swigCPtr; 037 protected boolean swigCMemOwn; 038 039 protected SBMLResolverRegistry(long cPtr, boolean cMemoryOwn) 040 { 041 swigCMemOwn = cMemoryOwn; 042 swigCPtr = cPtr; 043 } 044 045 protected static long getCPtr(SBMLResolverRegistry obj) 046 { 047 return (obj == null) ? 0 : obj.swigCPtr; 048 } 049 050 protected static long getCPtrAndDisown (SBMLResolverRegistry obj) 051 { 052 long ptr = 0; 053 054 if (obj != null) 055 { 056 ptr = obj.swigCPtr; 057 obj.swigCMemOwn = false; 058 } 059 060 return ptr; 061 } 062 063 protected void finalize() { 064 delete(); 065 } 066 067 public synchronized void delete() { 068 if (swigCPtr != 0) { 069 if (swigCMemOwn) { 070 swigCMemOwn = false; 071 libsbmlJNI.delete_SBMLResolverRegistry(swigCPtr); 072 } 073 swigCPtr = 0; 074 } 075 } 076 077 078/** 079 * Returns the singleton instance for the resolver registry. 080 <p> 081 * Prior to using the registry, callers have to obtain a copy of the 082 * registry. This static method provides the means for doing that. 083 <p> 084 * @return the singleton for the resolver registry. 085 */ public 086 static SBMLResolverRegistry getInstance() { 087 return new SBMLResolverRegistry(libsbmlJNI.SBMLResolverRegistry_getInstance(), false); 088 } 089 090 091/** 092 * Adds the given resolver to the registry of SBML resolvers. 093 <p> 094 * @param resolver the resolver to add to the registry. 095 <p> 096 * <p> 097 * @return integer value indicating success/failure of the 098 * function. The possible values 099 * returned by this function are: 100 * <ul> 101 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 102 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 103 * </ul> 104 */ public 105 int addResolver(SBMLResolver resolver) { 106 return libsbmlJNI.SBMLResolverRegistry_addResolver(swigCPtr, this, SBMLResolver.getCPtr(resolver), resolver); 107 } 108 109 110/** 111 * Adds the given {@link SBMLDocument} to the registry of SBML documents that will need to be deleted. 112 <p> 113 * When calculating reference cycles, sometimes we need SBML Documents to persist, but nobody 114 * else owns them directly. We hand them to the registry here so they can be cleaned up 115 <p> 116 * @param doc the SBML Document to add to the registry. 117 <p> 118 * <p> 119 * @return integer value indicating success/failure of the 120 * function. The possible values 121 * returned by this function are: 122 * <ul> 123 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 124 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 125 * </ul> 126 */ public 127 int addOwnedSBMLDocument(SBMLDocument doc) { 128 return libsbmlJNI.SBMLResolverRegistry_addOwnedSBMLDocument(swigCPtr, this, SBMLDocument.getCPtr(doc), doc); 129 } 130 131 132/** 133 * Removes the resolver with the given index. 134 <p> 135 * @param index the index of the resolver to be removed 136 <p> 137 * <p> 138 * @return integer value indicating success/failure of the 139 * function. The possible values 140 * returned by this function are: 141 * <ul> 142 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 143 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 144 * </ul> 145 */ public 146 int removeResolver(int index) { 147 return libsbmlJNI.SBMLResolverRegistry_removeResolver(swigCPtr, this, index); 148 } 149 150 151/** 152 * Returns the resolver with the given index number. 153 <p> 154 * Resolvers are given arbitrary index numbers by the registry. Callers 155 * can use the method {@link SBMLResolverRegistry#getNumResolvers()} to find 156 * out how many resolvers are registered, then use this method to 157 * iterate over the list and obtain each one in turn. 158 <p> 159 * @param index the zero-based index of the resolver to fetch. 160 <p> 161 * @return the resolver with the given index number, or <code>null</code> if the 162 * number is less than <code>0</code> or there is no resolver at the given index 163 * position. 164 */ public 165 SBMLResolver getResolverByIndex(int index) { 166 long cPtr = libsbmlJNI.SBMLResolverRegistry_getResolverByIndex(swigCPtr, this, index); 167 return (cPtr == 0) ? null : new SBMLResolver(cPtr, false); 168 } 169 170 171/** 172 * Returns the number of resolvers known by the registry. 173 <p> 174 * @return the number of registered resolvers. 175 <p> 176 * @see #getResolverByIndex(int) 177 */ public 178 int getNumResolvers() { 179 return libsbmlJNI.SBMLResolverRegistry_getNumResolvers(swigCPtr, this); 180 } 181 182 183/** 184 * Resolves the document for the given URI. 185 <p> 186 * @param uri the URI to the target document 187 * @param baseUri base URI, in case the URI is a relative one 188 <p> 189 * @return the document, if this resolver can resolve the document or null. 190 */ public 191 SBMLDocument resolve(String uri, String baseUri) { 192 long cPtr = libsbmlJNI.SBMLResolverRegistry_resolve__SWIG_0(swigCPtr, this, uri, baseUri); 193 return (cPtr == 0) ? null : new SBMLDocument(cPtr, false); 194 } 195 196 197/** 198 * Resolves the document for the given URI. 199 <p> 200 * @param uri the URI to the target document 201 * @param baseUri base URI, in case the URI is a relative one 202 <p> 203 * @return the document, if this resolver can resolve the document or null. 204 */ public 205 SBMLDocument resolve(String uri) { 206 long cPtr = libsbmlJNI.SBMLResolverRegistry_resolve__SWIG_1(swigCPtr, this, uri); 207 return (cPtr == 0) ? null : new SBMLDocument(cPtr, false); 208 } 209 210 211/** 212 * Resolves the full URI for the given URI without actually reading the 213 * document. 214 <p> 215 * @param uri the URI to the target document 216 * @param baseUri base URI, in case the URI is a relative one 217 <p> 218 * @return the full URI to the document, if this resolver can resolve the document or null. 219 */ public 220 SBMLUri resolveUri(String uri, String baseUri) { 221 long cPtr = libsbmlJNI.SBMLResolverRegistry_resolveUri__SWIG_0(swigCPtr, this, uri, baseUri); 222 return (cPtr == 0) ? null : new SBMLUri(cPtr, false); 223 } 224 225 226/** 227 * Resolves the full URI for the given URI without actually reading the 228 * document. 229 <p> 230 * @param uri the URI to the target document 231 * @param baseUri base URI, in case the URI is a relative one 232 <p> 233 * @return the full URI to the document, if this resolver can resolve the document or null. 234 */ public 235 SBMLUri resolveUri(String uri) { 236 long cPtr = libsbmlJNI.SBMLResolverRegistry_resolveUri__SWIG_1(swigCPtr, this, uri); 237 return (cPtr == 0) ? null : new SBMLUri(cPtr, false); 238 } 239 240}