001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.0.7
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   */ public
085 SBMLUri(SBMLUri orig) {
086    this(libsbmlJNI.new_SBMLUri__SWIG_1(SBMLUri.getCPtr(orig), orig), true);
087  }
088
089  
090/**
091   * Creates and returns a deep copy of this {@link SBMLUri} object.
092   <p>
093   * @return a (deep) copy of this {@link SBMLFileResolver} object.
094   */ public
095 SBMLUri cloneObject() {
096    long cPtr = libsbmlJNI.SBMLUri_cloneObject(swigCPtr, this);
097    return (cPtr == 0) ? null : new SBMLUri(cPtr, true);
098  }
099
100  
101/**
102   * Returns the scheme of the stored URI.
103   <p>
104   * The <em>scheme</em> of the URI is the text before the first colon character.
105   * Typical examples of what this might return are the strings <code>'file'</code> or
106   * <code>'http'.</code>  If the current URI does not have a scheme, this method
107   * returns an empty string.
108   <p>
109   * @return the parsed scheme, such as <code>'http'</code>, or an empty string if no
110   * scheme exists for the current URI.
111   */ public
112 String getScheme() {
113    return libsbmlJNI.SBMLUri_getScheme(swigCPtr, this);
114  }
115
116  
117/**
118   * Returns the host portion of the stored URI.
119   <p>
120   * For a scheme such as <code>'http'</code>, this method returns the part of the URI
121   * after <code>'http:</code>//' and before the next <code>'</code>/' character.  URIs with file
122   * or URN schemes have no host; in that case, this method returns an empty
123   * string.
124   <p>
125   * @return the host of the URI, or an empty string in the case of files
126   * or URNs schemes that do not possess a host portion.
127   */ public
128 String getHost() {
129    return libsbmlJNI.SBMLUri_getHost(swigCPtr, this);
130  }
131
132  
133/**
134   * Returns the path and filename portion of the stored URI.
135   <p>
136   * This method returns the text after the scheme, colon, and host (if
137   * present), and before the next <code>'?'</code> character.  The result may be an
138   * empty string for some URIs.
139   <p>
140   * @return the path of the URI (i.e., the full filename with path)
141   */ public
142 String getPath() {
143    return libsbmlJNI.SBMLUri_getPath(swigCPtr, this);
144  }
145
146  
147/**
148   * Returns the query portion of the stored URI.
149   <p>
150   * The equery portion of a URI is the text after a filename, starting with
151   * the character <code>'?'.</code>  For many URIs, this is an empty string.
152   <p>
153   * @return the query of the URI (i.e., the part after the full filename
154   * with path)
155   */ public
156 String getQuery() {
157    return libsbmlJNI.SBMLUri_getQuery(swigCPtr, this);
158  }
159
160  
161/**
162   * Returns the full stored URI, after replacing backslashes with slashes.
163   <p>
164   * @return the original URI, with backslashes replaced with slashes.
165   */ public
166 String getUri() {
167    return libsbmlJNI.SBMLUri_getUri(swigCPtr, this);
168  }
169
170  
171/**
172   * Constructs a new URI relative to this object and the given URI.
173   <p>
174   * For example,
175   <p>
176<pre class='fragment'>
177{@link SBMLUri}('c:\test').relativeTo('test.xml');
178</pre>
179<p>
180   * would construct a new file URI, with path
181   * <code>c:/test/test.xml</code>.
182   <p>
183   * @param uri a URI to be added to this object
184   <p>
185   * @return the resulting new URI
186   */ public
187 SBMLUri relativeTo(String uri) {
188    return new SBMLUri(libsbmlJNI.SBMLUri_relativeTo(swigCPtr, this, uri), true);
189  }
190
191}