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 A resolver for documents stored on a file system.
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 * In SBML, <em>resolvers</em> come into play with the SBML Level&nbsp;3
023 * Hierarchical {@link Model} Composition package (&ldquo;comp&rdquo;); this package
024 * includes features that allow a model to be composed from pieces that are
025 * external to a given SBML document, which implies the need to be able to
026 * identify and locate those external pieces.  The identifiers used in
027 * &ldquo;comp&rdquo; are URIs (<a target='_blank'
028 * href='http://en.wikipedia.org/wiki/Uniform_resource_identifier'>Uniform
029 * Resource Identifiers</a>).
030 <p>
031 * {@link SBMLFileResolver} is a class implementing the ability to resolve URIs to
032 * files.  It works on the local file system only.  It can resolve relative
033 * and absolute paths, and directories to be searched can be specified using
034 * the methods 
035 * {@link SBMLFileResolver#addAdditionalDir(String dir)} and
036 * {@link SBMLFileResolver#clearAdditionalDirs()}.
037 <p>
038 * @see SBMLResolver
039 * @see SBMLUri
040 */
041
042public class SBMLFileResolver extends SBMLResolver {
043   private long swigCPtr;
044
045   protected SBMLFileResolver(long cPtr, boolean cMemoryOwn)
046   {
047     super(libsbmlJNI.SBMLFileResolver_SWIGUpcast(cPtr), cMemoryOwn);
048     swigCPtr = cPtr;
049   }
050
051   protected static long getCPtr(SBMLFileResolver obj)
052   {
053     return (obj == null) ? 0 : obj.swigCPtr;
054   }
055
056   protected static long getCPtrAndDisown (SBMLFileResolver obj)
057   {
058     long ptr = 0;
059
060     if (obj != null)
061     {
062       ptr             = obj.swigCPtr;
063       obj.swigCMemOwn = false;
064     }
065
066     return ptr;
067   }
068
069  protected void finalize() {
070    delete();
071  }
072
073  public synchronized void delete() {
074    if (swigCPtr != 0) {
075      if (swigCMemOwn) {
076        swigCMemOwn = false;
077        libsbmlJNI.delete_SBMLFileResolver(swigCPtr);
078      }
079      swigCPtr = 0;
080    }
081    super.delete();
082  }
083
084  
085/**
086   * Creates a new {@link SBMLFileResolver} object.
087   */ public
088 SBMLFileResolver() {
089    this(libsbmlJNI.new_SBMLFileResolver__SWIG_0(), true);
090  }
091
092  
093/**
094   * Copy constructor.  Creates a copy of an {@link SBMLFileResolver} object.
095   <p>
096   * @param c the {@link SBMLFileResolver} object to copy.
097   <p>
098   * @throws SBMLConstructorException 
099   * Thrown if the argument <code>orig</code> is <code>null.</code>
100   */ public
101 SBMLFileResolver(SBMLFileResolver c) {
102    this(libsbmlJNI.new_SBMLFileResolver__SWIG_1(SBMLFileResolver.getCPtr(c), c), true);
103  }
104
105  
106/**
107   * Creates and returns a deep copy of this {@link SBMLFileResolver} object.
108   <p>
109   * @return a (deep) copy of this {@link SBMLFileResolver} object.
110   */ public
111 SBMLResolver cloneObject() {
112    long cPtr = libsbmlJNI.SBMLFileResolver_cloneObject(swigCPtr, this);
113    return (cPtr == 0) ? null : new SBMLFileResolver(cPtr, true);
114  }
115
116  
117/**
118   * Resolves the document for the given URI.
119   <p>
120   * @param uri the URI to the target document
121   * @param baseUri base URI, in case the URI is a relative one
122   <p>
123   * @return the document, if this resolver can resolve the document or null.
124   */ public
125 SBMLDocument resolve(String uri, String baseUri) {
126    long cPtr = libsbmlJNI.SBMLFileResolver_resolve__SWIG_0(swigCPtr, this, uri, baseUri);
127    return (cPtr == 0) ? null : new SBMLDocument(cPtr, false);
128  }
129
130  
131/**
132   * Resolves the document for the given URI.
133   <p>
134   * @param uri the URI to the target document
135   * @param baseUri base URI, in case the URI is a relative one
136   <p>
137   * @return the document, if this resolver can resolve the document or null.
138   */ public
139 SBMLDocument resolve(String uri) {
140    long cPtr = libsbmlJNI.SBMLFileResolver_resolve__SWIG_1(swigCPtr, this, uri);
141    return (cPtr == 0) ? null : new SBMLDocument(cPtr, false);
142  }
143
144  
145/**
146   * Resolves the full URI for a given URI without actually reading the
147   * document.
148   <p>
149   * @param uri the URI to the target document
150   * @param baseUri base URI, in case the URI is a relative one
151   <p>
152   * @return the full URI to the document, if this resolver can resolve the
153   * document or null.
154   */ public
155 SBMLUri resolveUri(String uri, String baseUri) {
156    long cPtr = libsbmlJNI.SBMLFileResolver_resolveUri__SWIG_0(swigCPtr, this, uri, baseUri);
157    return (cPtr == 0) ? null : new SBMLUri(cPtr, false);
158  }
159
160  
161/**
162   * Resolves the full URI for a given URI without actually reading the
163   * document.
164   <p>
165   * @param uri the URI to the target document
166   * @param baseUri base URI, in case the URI is a relative one
167   <p>
168   * @return the full URI to the document, if this resolver can resolve the
169   * document or null.
170   */ public
171 SBMLUri resolveUri(String uri) {
172    long cPtr = libsbmlJNI.SBMLFileResolver_resolveUri__SWIG_1(swigCPtr, this, uri);
173    return (cPtr == 0) ? null : new SBMLUri(cPtr, false);
174  }
175
176  
177/**
178   * Removes the list of directories to search for files to resolve.
179   <p>
180   * After this method is called,
181   * {@link SBMLFileResolver#resolve(String uri, String baseUri)}
182   * will only search absolute or relative directories.  New directories can
183   * be added using {@link SBMLFileResolver#addAdditionalDir(String
184   * dir)} .
185   <p>
186   * @see #addAdditionalDir(String dir)
187   */ public
188 void clearAdditionalDirs() {
189    libsbmlJNI.SBMLFileResolver_clearAdditionalDirs(swigCPtr, this);
190  }
191
192  
193/**
194   * Adds a directory to the list of directories to search for files to
195   * resolve.
196   <p>
197   * @param dir the directory to add.
198   <p>
199   * @see #clearAdditionalDirs()
200   */ public
201 void addAdditionalDir(String dir) {
202    libsbmlJNI.SBMLFileResolver_addAdditionalDir(swigCPtr, this, dir);
203  }
204
205}