001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.10 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 Resolves 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 3 023 * Hierarchical Model Composition package (“comp”); 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 * “comp” 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)} 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 */ public 098 SBMLFileResolver(SBMLFileResolver c) { 099 this(libsbmlJNI.new_SBMLFileResolver__SWIG_1(SBMLFileResolver.getCPtr(c), c), true); 100 } 101 102 103/** 104 * Creates and returns a deep copy of this {@link SBMLFileResolver} object. 105 <p> 106 * @return a (deep) copy of this {@link SBMLFileResolver} object. 107 */ public 108 SBMLResolver cloneObject() { 109 long cPtr = libsbmlJNI.SBMLFileResolver_cloneObject(swigCPtr, this); 110 return (cPtr == 0) ? null : new SBMLFileResolver(cPtr, true); 111 } 112 113 114/** 115 * Resolves the document for the given URI. 116 <p> 117 * @param uri the URI to the target document. 118 * @param baseUri base URI, in case the URI is a relative one. 119 <p> 120 * @return the document, if this resolver can resolve the document or null. 121 */ public 122 SBMLDocument resolve(String uri, String baseUri) { 123 long cPtr = libsbmlJNI.SBMLFileResolver_resolve__SWIG_0(swigCPtr, this, uri, baseUri); 124 return (cPtr == 0) ? null : new SBMLDocument(cPtr, false); 125 } 126 127 128/** 129 * Resolves the document for the given URI. 130 <p> 131 * @param uri the URI to the target document. 132 * @param baseUri base URI, in case the URI is a relative one. 133 <p> 134 * @return the document, if this resolver can resolve the document or null. 135 */ public 136 SBMLDocument resolve(String uri) { 137 long cPtr = libsbmlJNI.SBMLFileResolver_resolve__SWIG_1(swigCPtr, this, uri); 138 return (cPtr == 0) ? null : new SBMLDocument(cPtr, false); 139 } 140 141 142/** 143 * Resolves the full URI for a given URI without actually reading the 144 * document. 145 <p> 146 * @param uri the URI to the target document. 147 * @param baseUri base URI, in case the URI is a relative one. 148 <p> 149 * @return the full URI to the document, if this resolver can resolve the 150 * document or null. 151 */ public 152 SBMLUri resolveUri(String uri, String baseUri) { 153 long cPtr = libsbmlJNI.SBMLFileResolver_resolveUri__SWIG_0(swigCPtr, this, uri, baseUri); 154 return (cPtr == 0) ? null : new SBMLUri(cPtr, false); 155 } 156 157 158/** 159 * Resolves the full URI for a given URI without actually reading the 160 * document. 161 <p> 162 * @param uri the URI to the target document. 163 * @param baseUri base URI, in case the URI is a relative one. 164 <p> 165 * @return the full URI to the document, if this resolver can resolve the 166 * document or null. 167 */ public 168 SBMLUri resolveUri(String uri) { 169 long cPtr = libsbmlJNI.SBMLFileResolver_resolveUri__SWIG_1(swigCPtr, this, uri); 170 return (cPtr == 0) ? null : new SBMLUri(cPtr, false); 171 } 172 173 174/** 175 * Removes the list of directories to search for files to resolve. 176 <p> 177 * After this method is called, {@link SBMLFileResolver#resolve(String uri, String baseUri)} will only search absolute or relative 178 * directories. New directories can be added using 179 * {@link SBMLFileResolver#addAdditionalDir(String)} . 180 <p> 181 * @see #addAdditionalDir(String) 182 */ public 183 void clearAdditionalDirs() { 184 libsbmlJNI.SBMLFileResolver_clearAdditionalDirs(swigCPtr, this); 185 } 186 187 188/** 189 * Adds a directory to the list of directories to search for files to 190 * resolve. 191 <p> 192 * @param dir the directory to add. 193 <p> 194 * @see #clearAdditionalDirs() 195 */ public 196 void addAdditionalDir(String dir) { 197 libsbmlJNI.SBMLFileResolver_addAdditionalDir(swigCPtr, this, dir); 198 } 199 200}