001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 2.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 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
031 * index)} to iterate over each one;
032 <p>
033 * @see SBMLFileResolver
034 */
035
036public class SBMLResolverRegistry {
037   private long swigCPtr;
038   protected boolean swigCMemOwn;
039
040   protected SBMLResolverRegistry(long cPtr, boolean cMemoryOwn)
041   {
042     swigCMemOwn = cMemoryOwn;
043     swigCPtr    = cPtr;
044   }
045
046   protected static long getCPtr(SBMLResolverRegistry obj)
047   {
048     return (obj == null) ? 0 : obj.swigCPtr;
049   }
050
051   protected static long getCPtrAndDisown (SBMLResolverRegistry obj)
052   {
053     long ptr = 0;
054
055     if (obj != null)
056     {
057       ptr             = obj.swigCPtr;
058       obj.swigCMemOwn = false;
059     }
060
061     return ptr;
062   }
063
064  protected void finalize() {
065    delete();
066  }
067
068  public synchronized void delete() {
069    if (swigCPtr != 0) {
070      if (swigCMemOwn) {
071        swigCMemOwn = false;
072        libsbmlJNI.delete_SBMLResolverRegistry(swigCPtr);
073      }
074      swigCPtr = 0;
075    }
076  }
077
078  
079/**
080   * Returns the singleton instance for the resolver registry.
081   <p>
082   * Prior to using the registry, callers have to obtain a copy of the
083   * registry.  This static method provides the means for doing that.
084   <p>
085   * @return the singleton for the resolver registry.
086   */ public
087 static SBMLResolverRegistry getInstance() {
088    return new SBMLResolverRegistry(libsbmlJNI.SBMLResolverRegistry_getInstance(), false);
089  }
090
091  
092/**
093   * Adds the given resolver to the registry of SBML resolvers.
094   <p>
095   * @param resolver the resolver to add to the registry.
096   <p>
097   * @return integer value indicating the success/failure of the operation.
098   *  The possible values are:
099   * <ul>
100   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
101   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT }
102   * </ul>
103   */ public
104 int addResolver(SBMLResolver resolver) {
105    return libsbmlJNI.SBMLResolverRegistry_addResolver(swigCPtr, this, SBMLResolver.getCPtr(resolver), resolver);
106  }
107
108  
109/**
110   * Removes the resolver with the given index.
111   <p>
112   * @param index the index of the resolver to be removed
113   <p>
114   * @return integer value indicating the success/failure of the operation.
115   *  The possible values are:
116   * <ul>
117   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
118   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT }
119   * </ul>
120   */ public
121 int removeResolver(int index) {
122    return libsbmlJNI.SBMLResolverRegistry_removeResolver(swigCPtr, this, index);
123  }
124
125  
126/**
127   * Returns the resolver with the given index number.
128   <p>
129   * Resolvers are given arbitrary index numbers by the registry.  Callers
130   * can use the method {@link SBMLResolverRegistry#getNumResolvers()} to find
131   * out how many resolvers are registered, then use this method to
132   * iterate over the list and obtain each one in turn.
133   <p>
134   * @param index the zero-based index of the resolver to fetch.
135   <p>
136   * @return the resolver with the given index number, or <code>null</code> if the
137   * number is less than <code>0</code> or there is no resolver at the given index
138   * position.
139   */ public
140 SBMLResolver getResolverByIndex(int index) {
141    long cPtr = libsbmlJNI.SBMLResolverRegistry_getResolverByIndex(swigCPtr, this, index);
142    return (cPtr == 0) ? null : new SBMLResolver(cPtr, false);
143  }
144
145  
146/**
147   * Returns the number of resolvers known by the registry.
148   <p>
149   * @return the number of registered resolvers.
150   <p>
151   * @see #getResolverByIndex(int index)
152   */ public
153 int getNumResolvers() {
154    return libsbmlJNI.SBMLResolverRegistry_getNumResolvers(swigCPtr, this);
155  }
156
157  
158/**
159   * Resolves the document for the given URI.
160   <p>
161   * @param uri the URI to the target document
162   * @param baseUri base URI, in case the URI is a relative one
163   <p>
164   * @return  the document, if this resolver can resolve the document or null.
165   */ public
166 SBMLDocument resolve(String uri, String baseUri) {
167    long cPtr = libsbmlJNI.SBMLResolverRegistry_resolve__SWIG_0(swigCPtr, this, uri, baseUri);
168    return (cPtr == 0) ? null : new SBMLDocument(cPtr, false);
169  }
170
171  
172/**
173   * Resolves the document for the given URI.
174   <p>
175   * @param uri the URI to the target document
176   * @param baseUri base URI, in case the URI is a relative one
177   <p>
178   * @return  the document, if this resolver can resolve the document or null.
179   */ public
180 SBMLDocument resolve(String uri) {
181    long cPtr = libsbmlJNI.SBMLResolverRegistry_resolve__SWIG_1(swigCPtr, this, uri);
182    return (cPtr == 0) ? null : new SBMLDocument(cPtr, false);
183  }
184
185  
186/**
187   * Resolves the full URI for the given URI without actually reading the
188   * document.
189   <p>
190   * @param uri the URI to the target document
191   * @param baseUri base URI, in case the URI is a relative one
192   <p>
193   * @return  the full URI to the document, if this resolver can resolve the document or null.
194   */ public
195 SBMLUri resolveUri(String uri, String baseUri) {
196    long cPtr = libsbmlJNI.SBMLResolverRegistry_resolveUri__SWIG_0(swigCPtr, this, uri, baseUri);
197    return (cPtr == 0) ? null : new SBMLUri(cPtr, false);
198  }
199
200  
201/**
202   * Resolves the full URI for the given URI without actually reading the
203   * document.
204   <p>
205   * @param uri the URI to the target document
206   * @param baseUri base URI, in case the URI is a relative one
207   <p>
208   * @return  the full URI to the document, if this resolver can resolve the document or null.
209   */ public
210 SBMLUri resolveUri(String uri) {
211    long cPtr = libsbmlJNI.SBMLResolverRegistry_resolveUri__SWIG_1(swigCPtr, this, uri);
212    return (cPtr == 0) ? null : new SBMLUri(cPtr, false);
213  }
214
215}