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 utility class for handling URIs.
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 * This class implements functionality for parsing URIs and extracting
023 * information about them.
024 <p>
025 * @see SBMLResolver
026 * @see SBMLFileResolver
027 */
028
029public class SBMLUri {
030   private long swigCPtr;
031   protected boolean swigCMemOwn;
032
033   protected SBMLUri(long cPtr, boolean cMemoryOwn)
034   {
035     swigCMemOwn = cMemoryOwn;
036     swigCPtr    = cPtr;
037   }
038
039   protected static long getCPtr(SBMLUri obj)
040   {
041     return (obj == null) ? 0 : obj.swigCPtr;
042   }
043
044   protected static long getCPtrAndDisown (SBMLUri obj)
045   {
046     long ptr = 0;
047
048     if (obj != null)
049     {
050       ptr             = obj.swigCPtr;
051       obj.swigCMemOwn = false;
052     }
053
054     return ptr;
055   }
056
057  protected void finalize() {
058    delete();
059  }
060
061  public synchronized void delete() {
062    if (swigCPtr != 0) {
063      if (swigCMemOwn) {
064        swigCMemOwn = false;
065        libsbmlJNI.delete_SBMLUri(swigCPtr);
066      }
067      swigCPtr = 0;
068    }
069  }
070
071  
072/**
073   * Creates a new {@link SBMLUri} from the given string URI.
074   */ public
075 SBMLUri(String uri) {
076    this(libsbmlJNI.new_SBMLUri__SWIG_0(uri), true);
077  }
078
079  
080/**
081   * Copy constructor.  Creates a copy of an {@link SBMLUri} object.
082   <p>
083   * @param orig the {@link SBMLUri} object to copy.
084   <p>
085   * @throws SBMLConstructorException 
086   * Thrown if the argument <code>orig</code> is <code>null.</code>
087   */ public
088 SBMLUri(SBMLUri orig) {
089    this(libsbmlJNI.new_SBMLUri__SWIG_1(SBMLUri.getCPtr(orig), orig), true);
090  }
091
092  
093/**
094   * Creates and returns a deep copy of this {@link SBMLUri} object.
095   <p>
096   * @return a (deep) copy of this {@link SBMLFileResolver} object.
097   */ public
098 SBMLUri cloneObject() {
099    long cPtr = libsbmlJNI.SBMLUri_cloneObject(swigCPtr, this);
100    return (cPtr == 0) ? null : new SBMLUri(cPtr, true);
101  }
102
103  
104/**
105   * Returns the scheme of the stored URI.
106   <p>
107   * The <em>scheme</em> of the URI is the text before the first colon character.
108   * Typical examples of what this might return are the strings <code>'file'</code> or
109   * <code>'http'.</code>  If the current URI does not have a scheme, this method
110   * returns an empty string.
111   <p>
112   * @return the parsed scheme, such as <code>'http'</code>, or an empty string if no
113   * scheme exists for the current URI.
114   */ public
115 String getScheme() {
116    return libsbmlJNI.SBMLUri_getScheme(swigCPtr, this);
117  }
118
119  
120/**
121   * Returns the host portion of the stored URI.
122   <p>
123   * For a scheme such as <code>'http'</code>, this method returns the part of the URI
124   * after <code>'http:</code>//' and before the next <code>'</code>/' character.  URIs with file
125   * or URN schemes have no host; in that case, this method returns an empty
126   * string.
127   <p>
128   * @return the host of the URI, or an empty string in the case of files
129   * or URNs schemes that do not possess a host portion.
130   */ public
131 String getHost() {
132    return libsbmlJNI.SBMLUri_getHost(swigCPtr, this);
133  }
134
135  
136/**
137   * Returns the path and filename portion of the stored URI.
138   <p>
139   * This method returns the text after the scheme, colon, and host (if
140   * present), and before the next <code>'?'</code> character.  The result may be an
141   * empty string for some URIs.
142   <p>
143   * @return the path of the URI (i.e., the full filename with path)
144   */ public
145 String getPath() {
146    return libsbmlJNI.SBMLUri_getPath(swigCPtr, this);
147  }
148
149  
150/**
151   * Returns the query portion of the stored URI.
152   <p>
153   * The equery portion of a URI is the text after a filename, starting with
154   * the character <code>'?'.</code>  For many URIs, this is an empty string.
155   <p>
156   * @return the query of the URI (i.e., the part after the full filename
157   * with path)
158   */ public
159 String getQuery() {
160    return libsbmlJNI.SBMLUri_getQuery(swigCPtr, this);
161  }
162
163  
164/**
165   * Returns the full stored URI, after replacing backslashes with slashes.
166   <p>
167   * @return the original URI, with backslashes replaced with slashes.
168   */ public
169 String getUri() {
170    return libsbmlJNI.SBMLUri_getUri(swigCPtr, this);
171  }
172
173  
174/**
175   * Constructs a new URI relative to this object and the given URI. 
176   <p>
177   * For example,
178   <div class='fragment'><pre class='fragment'>
179{@link SBMLUri}('c:\test').relativeTo('test.xml')
180</pre></div>
181   * would construct a new file URI, with path
182   * <code>c:/test/test.xml</code>.
183   <p>
184   * @param uri a URI to be added to this object
185   <p>
186   * @return the resulting new URI
187   */ public
188 SBMLUri relativeTo(String uri) {
189    return new SBMLUri(libsbmlJNI.SBMLUri_relativeTo(swigCPtr, this, uri), true);
190  }
191
192}