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 *  An XML Namespace.
013 <p>
014 * <p style='color: #777; font-style: italic'>
015This class of objects is defined by libSBML only and has no direct
016equivalent in terms of SBML components.  This class is not prescribed by
017the SBML specifications, although it is used to implement features
018defined in SBML.
019</p>
020
021 <p>
022 * This class serves to organize functionality for tracking XML namespaces
023 * in a document or data stream.  The namespace declarations are stored as
024 * a list of pairs of XML namespace URIs and prefix strings.  These
025 * correspond to the parts of a namespace declaration on an XML element.
026 * For example, in the following XML fragment,
027 * <pre class='fragment'>
028&lt;annotation&gt;
029    &lt;mysim:nodecolors xmlns:mysim='urn:lsid:mysim.org'
030         mysim:bgcolor='green' mysim:fgcolor='white'/&gt;
031&lt;/annotation&gt;
032</pre>
033 * there is one namespace declaration.  Its URI is
034 * <code>urn:lsid:mysim.org</code> and its prefix is <code>mysim</code>.
035 * This pair could be stored as one item in an {@link XMLNamespaces} list.
036 <p>
037 * {@link XMLNamespaces} provides various methods for manipulating the list of
038 * prefix-URI pairs.  Individual namespaces stored in a given XMLNamespace
039 * object instance can be retrieved based on their index using
040 * {@link XMLNamespaces#getPrefix(int index)}, or by their characteristics such as
041 * their URI or position in the list.
042 */
043
044public class XMLNamespaces {
045   private long swigCPtr;
046   protected boolean swigCMemOwn;
047
048   protected XMLNamespaces(long cPtr, boolean cMemoryOwn)
049   {
050     swigCMemOwn = cMemoryOwn;
051     swigCPtr    = cPtr;
052   }
053
054   protected static long getCPtr(XMLNamespaces obj)
055   {
056     return (obj == null) ? 0 : obj.swigCPtr;
057   }
058
059   protected static long getCPtrAndDisown (XMLNamespaces obj)
060   {
061     long ptr = 0;
062
063     if (obj != null)
064     {
065       ptr             = obj.swigCPtr;
066       obj.swigCMemOwn = false;
067     }
068
069     return ptr;
070   }
071
072  protected void finalize() {
073    delete();
074  }
075
076  public synchronized void delete() {
077    if (swigCPtr != 0) {
078      if (swigCMemOwn) {
079        swigCMemOwn = false;
080        libsbmlJNI.delete_XMLNamespaces(swigCPtr);
081      }
082      swigCPtr = 0;
083    }
084  }
085
086  /**
087   * Equality comparison method for XMLNamespaces.
088   * <p>
089   * Because the Java methods for libSBML are actually wrappers around code
090   * implemented in C++ and C, certain operations will not behave as
091   * expected.  Equality comparison is one such case.  An instance of a
092   * libSBML object class is actually a <em>proxy object</em>
093   * wrapping the real underlying C/C++ object.  The normal <code>==</code>
094   * equality operator in Java will <em>only compare the Java proxy objects</em>,
095   * not the underlying native object.  The result is almost never what you
096   * want in practical situations.  Unfortunately, Java does not provide a
097   * way to override <code>==</code>.
098   *  <p>
099   * The alternative that must be followed is to use the
100   * <code>equals()</code> method.  The <code>equals</code> method on this
101   * class overrides the default java.lang.Object one, and performs an
102   * intelligent comparison of instances of objects of this class.  The
103   * result is an assessment of whether two libSBML Java objects are truly 
104   * the same underlying native-code objects.
105   *  <p>
106   * The use of this method in practice is the same as the use of any other
107   * Java <code>equals</code> method.  For example,
108   * <em>a</em><code>.equals(</code><em>b</em><code>)</code> returns
109   * <code>true</code> if <em>a</em> and <em>b</em> are references to the
110   * same underlying object.
111   *
112   * @param sb a reference to an object to which the current object
113   * instance will be compared
114   *
115   * @return <code>true</code> if <code>sb</code> refers to the same underlying 
116   * native object as this one, <code>false</code> otherwise
117   */
118  public boolean equals(Object sb)
119  {
120    if ( this == sb ) 
121    {
122      return true;
123    }
124    return swigCPtr == getCPtr((XMLNamespaces)(sb));
125  }
126
127  /**
128   * Returns a hashcode for this XMLNamespaces object.
129   *
130   * @return a hash code usable by Java methods that need them.
131   */
132  public int hashCode()
133  {
134    return (int)(swigCPtr^(swigCPtr>>>32));
135  }
136
137  
138/**
139   * Creates a new empty list of XML namespace declarations.
140   */ public
141 XMLNamespaces() throws org.sbml.libsbml.XMLConstructorException {
142    this(libsbmlJNI.new_XMLNamespaces__SWIG_0(), true);
143  }
144
145  
146/**
147   * Copy constructor; creates a copy of this {@link XMLNamespaces} list.
148   <p>
149   * @param orig the {@link XMLNamespaces} object to copy
150   */ public
151 XMLNamespaces(XMLNamespaces orig) throws org.sbml.libsbml.XMLConstructorException {
152    this(libsbmlJNI.new_XMLNamespaces__SWIG_1(XMLNamespaces.getCPtr(orig), orig), true);
153  }
154
155  
156/**
157   * Creates and returns a deep copy of this {@link XMLNamespaces} object.
158   <p>
159   * @return the (deep) copy of this {@link XMLNamespaces} object.
160   */ public
161 XMLNamespaces cloneObject() {
162    long cPtr = libsbmlJNI.XMLNamespaces_cloneObject(swigCPtr, this);
163    return (cPtr == 0) ? null : new XMLNamespaces(cPtr, true);
164  }
165
166  
167/**
168   * Appends an XML namespace prefix and URI pair to this list of namespace
169   * declarations.
170   <p>
171   * An {@link XMLNamespaces} object stores a list of pairs of namespaces and their
172   * prefixes.  If there is an XML namespace with the given <code>uri</code> prefix
173   * in this list, then its corresponding URI will be overwritten by the
174   * new <code>uri</code> unless the uri represents the core sbml namespace.
175   * Calling programs could use one of the other {@link XMLNamespaces}
176   * methods, such as
177   * {@link XMLNamespaces#hasPrefix(String)} and 
178   * {@link XMLNamespaces#hasURI(String)} to
179   * inquire whether a given prefix and/or URI
180   * is already present in this {@link XMLNamespaces} object.
181   * If the <code>uri</code> represents the sbml namespaces then it will not be
182   * overwritten, as this has potentially serious consequences. If it
183   * is necessary to replace the sbml namespace the namespace should be removed
184   * prior to adding the new namespace.
185   <p>
186   * @param uri a string, the uri for the namespace
187   * @param prefix a string, the prefix for the namespace
188   <p>
189   * <p>
190 * @return integer value indicating success/failure of the
191 * function.   The possible values
192 * returned by this function are:
193   * <ul>
194   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
195   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
196   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
197   *
198   * </ul> <p>
199   * 
200</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd>
201The native C++ implementation of this method defines a default argument
202value. In the documentation generated for different libSBML language
203bindings, you may or may not see corresponding arguments in the method
204declarations. For example, in Java and C#, a default argument is handled by
205declaring two separate methods, with one of them having the argument and
206the other one lacking the argument. However, the libSBML documentation will
207be <em>identical</em> for both methods. Consequently, if you are reading
208this and do not see an argument even though one is described, please look
209for descriptions of other variants of this method near where this one
210appears in the documentation.
211</dd></dl>
212 
213   */ public
214 int add(String uri, String prefix) {
215    return libsbmlJNI.XMLNamespaces_add__SWIG_0(swigCPtr, this, uri, prefix);
216  }
217
218  
219/**
220   * Appends an XML namespace prefix and URI pair to this list of namespace
221   * declarations.
222   <p>
223   * An {@link XMLNamespaces} object stores a list of pairs of namespaces and their
224   * prefixes.  If there is an XML namespace with the given <code>uri</code> prefix
225   * in this list, then its corresponding URI will be overwritten by the
226   * new <code>uri</code> unless the uri represents the core sbml namespace.
227   * Calling programs could use one of the other {@link XMLNamespaces}
228   * methods, such as
229   * {@link XMLNamespaces#hasPrefix(String)} and 
230   * {@link XMLNamespaces#hasURI(String)} to
231   * inquire whether a given prefix and/or URI
232   * is already present in this {@link XMLNamespaces} object.
233   * If the <code>uri</code> represents the sbml namespaces then it will not be
234   * overwritten, as this has potentially serious consequences. If it
235   * is necessary to replace the sbml namespace the namespace should be removed
236   * prior to adding the new namespace.
237   <p>
238   * @param uri a string, the uri for the namespace
239   * @param prefix a string, the prefix for the namespace
240   <p>
241   * <p>
242 * @return integer value indicating success/failure of the
243 * function.   The possible values
244 * returned by this function are:
245   * <ul>
246   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
247   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
248   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
249   *
250   * </ul> <p>
251   * 
252</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd>
253The native C++ implementation of this method defines a default argument
254value. In the documentation generated for different libSBML language
255bindings, you may or may not see corresponding arguments in the method
256declarations. For example, in Java and C#, a default argument is handled by
257declaring two separate methods, with one of them having the argument and
258the other one lacking the argument. However, the libSBML documentation will
259be <em>identical</em> for both methods. Consequently, if you are reading
260this and do not see an argument even though one is described, please look
261for descriptions of other variants of this method near where this one
262appears in the documentation.
263</dd></dl>
264 
265   */ public
266 int add(String uri) {
267    return libsbmlJNI.XMLNamespaces_add__SWIG_1(swigCPtr, this, uri);
268  }
269
270  
271/**
272   * Removes an XML Namespace stored in the given position of this list.
273   <p>
274   * @param index an integer, position of the namespace to remove.
275   <p>
276   * <p>
277 * @return integer value indicating success/failure of the
278 * function.   The possible values
279 * returned by this function are:
280   * <ul>
281   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
282   * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE}
283   * </ul>
284   */ public
285 int remove(int index) {
286    return libsbmlJNI.XMLNamespaces_remove__SWIG_0(swigCPtr, this, index);
287  }
288
289  
290/**
291   * Removes an XML Namespace with the given prefix.
292   <p>
293   * @param prefix a string, prefix of the required namespace.
294   <p>
295   * <p>
296 * @return integer value indicating success/failure of the
297 * function.   The possible values
298 * returned by this function are:
299   * <ul>
300   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
301   * <li> {@link libsbmlConstants#LIBSBML_INDEX_EXCEEDS_SIZE LIBSBML_INDEX_EXCEEDS_SIZE}
302   *
303   * </ul> <p>
304   * @see #remove(int index)
305   */ public
306 int remove(String prefix) {
307    return libsbmlJNI.XMLNamespaces_remove__SWIG_1(swigCPtr, this, prefix);
308  }
309
310  
311/**
312   * Clears (deletes) all XML namespace declarations in this {@link XMLNamespaces}
313   * object.
314   <p>
315   * <p>
316 * @return integer value indicating success/failure of the
317 * function.   The possible values
318 * returned by this function are:
319   * <ul>
320   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
321   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
322   *
323   * </ul> <p>
324   * @see #remove(int index)
325   */ public
326 int clear() {
327    return libsbmlJNI.XMLNamespaces_clear(swigCPtr, this);
328  }
329
330  
331/**
332   * Look up the index of an XML namespace declaration by URI.
333   <p>
334   * An {@link XMLNamespaces} object stores a list of pairs of namespaces and their
335   * prefixes.  If this {@link XMLNamespaces} object contains a pair with the given
336   * URI <code>uri</code>, this method returns its index in the list.
337   <p>
338   * @param uri a string, the URI of the sought-after namespace.
339   <p>
340   * @return the index of the given declaration, or <code>-1</code> if not
341   * present.
342   */ public
343 int getIndex(String uri) {
344    return libsbmlJNI.XMLNamespaces_getIndex(swigCPtr, this, uri);
345  }
346
347  
348/**
349   * Tests whether the given uri is contained in this set of namespaces. 
350   */ public
351 boolean containsUri(String uri) {
352    return libsbmlJNI.XMLNamespaces_containsUri(swigCPtr, this, uri);
353  }
354
355  
356/**
357   * Look up the index of an XML namespace declaration by prefix.
358   <p>
359   * An {@link XMLNamespaces} object stores a list of pairs of namespaces and their
360   * prefixes.  If this {@link XMLNamespaces} object contains a pair with the given
361   * prefix <code>prefix</code>, this method returns its index in the list.
362   <p>
363   * @param prefix a string, the prefix string of the sought-after
364   * namespace
365   <p>
366   * @return the index of the given declaration, or <code>-1</code> if not
367   * present.
368   */ public
369 int getIndexByPrefix(String prefix) {
370    return libsbmlJNI.XMLNamespaces_getIndexByPrefix(swigCPtr, this, prefix);
371  }
372
373  
374/**
375   * Returns the total number of URI-and-prefix pairs stored in this
376   * particular {@link XMLNamespaces} instance.
377   <p>
378   * @return the number of namespaces in this list.
379   */ public
380 int getLength() {
381    return libsbmlJNI.XMLNamespaces_getLength(swigCPtr, this);
382  }
383
384  
385/**
386   * Returns the total number of URI-and-prefix pairs stored in this
387   * particular {@link XMLNamespaces} instance.
388   <p>
389   * @return the number of namespaces in this list.
390   <p>
391   * This function is an alias for getLength introduced for consistency
392   * with other XML classes.
393   */ public
394 int getNumNamespaces() {
395    return libsbmlJNI.XMLNamespaces_getNumNamespaces(swigCPtr, this);
396  }
397
398  
399/**
400   * Look up the prefix of an XML namespace declaration by its position.
401   <p>
402   * An {@link XMLNamespaces} object stores a list of pairs of namespaces and their
403   * prefixes.  This method returns the prefix of the <code>n</code>th
404   * element in that list (if it exists).  Callers should use
405   * {@link XMLAttributes#getLength()} first to find out how many namespaces are
406   * stored in the list.
407   <p>
408   * @param index an integer, position of the sought-after prefix
409   <p>
410   * @return the prefix of an XML namespace declaration in this list (by
411   * position), or an empty string if the <code>index</code> is out of range
412   <p>
413   * @see #getLength()
414   */ public
415 String getPrefix(int index) {
416    return libsbmlJNI.XMLNamespaces_getPrefix__SWIG_0(swigCPtr, this, index);
417  }
418
419  
420/**
421   * Look up the prefix of an XML namespace declaration by its URI.
422   <p>
423   * An {@link XMLNamespaces} object stores a list of pairs of namespaces and their
424   * prefixes.  This method returns the prefix for a pair that has the
425   * given <code>uri</code>.
426   <p>
427   * @param uri a string, the URI of the prefix being sought
428   <p>
429   * @return the prefix of an XML namespace declaration given its URI, or
430   * an empty string if no such <code>uri</code> exists in this {@link XMLNamespaces} object
431   */ public
432 String getPrefix(String uri) {
433    return libsbmlJNI.XMLNamespaces_getPrefix__SWIG_1(swigCPtr, this, uri);
434  }
435
436  
437/**
438   * Look up the URI of an XML namespace declaration by its position.
439   <p>
440   * An {@link XMLNamespaces} object stores a list of pairs of namespaces and their
441   * prefixes.  This method returns the URI of the <code>n</code>th element
442   * in that list (if it exists).  Callers should use
443   * {@link XMLAttributes#getLength()} first to find out how many namespaces are
444   * stored in the list.
445   <p>
446   * @param index an integer, position of the required URI.
447   <p>
448   * @return the URI of an XML namespace declaration in this list (by
449   * position), or an empty string if the <code>index</code> is out of range.
450   <p>
451   * @see #getLength()
452   */ public
453 String getURI(int index) {
454    return libsbmlJNI.XMLNamespaces_getURI__SWIG_0(swigCPtr, this, index);
455  }
456
457  
458/**
459   * Look up the URI of an XML namespace declaration by its prefix.
460   <p>
461   * An {@link XMLNamespaces} object stores a list of pairs of namespaces and their
462   * prefixes.  This method returns the namespace URI for a pair that has
463   * the given <code>prefix</code>.
464   <p>
465   * @param prefix a string, the prefix of the required URI
466   <p>
467   * @return the URI of an XML namespace declaration having the given 
468   * <code>prefix</code>, or an empty string if no such prefix-and-URI pair exists
469   * in this {@link XMLNamespaces} object
470   <p>
471   * 
472</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd>
473The native C++ implementation of this method defines a default argument
474value. In the documentation generated for different libSBML language
475bindings, you may or may not see corresponding arguments in the method
476declarations. For example, in Java and C#, a default argument is handled by
477declaring two separate methods, with one of them having the argument and
478the other one lacking the argument. However, the libSBML documentation will
479be <em>identical</em> for both methods. Consequently, if you are reading
480this and do not see an argument even though one is described, please look
481for descriptions of other variants of this method near where this one
482appears in the documentation.
483</dd></dl>
484 
485   <p>
486   * @see #getURI()
487   */ public
488 String getURI(String prefix) {
489    return libsbmlJNI.XMLNamespaces_getURI__SWIG_1(swigCPtr, this, prefix);
490  }
491
492  
493/**
494   * Look up the URI of an XML namespace declaration by its prefix.
495   <p>
496   * An {@link XMLNamespaces} object stores a list of pairs of namespaces and their
497   * prefixes.  This method returns the namespace URI for a pair that has
498   * the given <code>prefix</code>.
499   <p>
500   * @param prefix a string, the prefix of the required URI
501   <p>
502   * @return the URI of an XML namespace declaration having the given 
503   * <code>prefix</code>, or an empty string if no such prefix-and-URI pair exists
504   * in this {@link XMLNamespaces} object
505   <p>
506   * 
507</dl><dl class="docnote"><dt><b>Documentation note:</b></dt><dd>
508The native C++ implementation of this method defines a default argument
509value. In the documentation generated for different libSBML language
510bindings, you may or may not see corresponding arguments in the method
511declarations. For example, in Java and C#, a default argument is handled by
512declaring two separate methods, with one of them having the argument and
513the other one lacking the argument. However, the libSBML documentation will
514be <em>identical</em> for both methods. Consequently, if you are reading
515this and do not see an argument even though one is described, please look
516for descriptions of other variants of this method near where this one
517appears in the documentation.
518</dd></dl>
519 
520   <p>
521   * @see #getURI()
522   */ public
523 String getURI() {
524    return libsbmlJNI.XMLNamespaces_getURI__SWIG_2(swigCPtr, this);
525  }
526
527  
528/**
529   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
530   * {@link XMLNamespaces} list is empty.
531   <p>
532   * @return <code>true</code> if this {@link XMLNamespaces} list is empty, <code>false</code> otherwise.
533   */ public
534 boolean isEmpty() {
535    return libsbmlJNI.XMLNamespaces_isEmpty(swigCPtr, this);
536  }
537
538  
539/**
540   * Predicate returning <code>true</code> or <code>false</code> depending on whether an XML
541   * Namespace with the given URI is contained in this {@link XMLNamespaces} list.
542   <p>
543   * @param uri a string, the uri for the namespace
544   <p>
545   * @return <code>true</code> if an XML Namespace with the given URI is contained in
546   * this {@link XMLNamespaces} list, <code>false</code> otherwise.
547   */ public
548 boolean hasURI(String uri) {
549    return libsbmlJNI.XMLNamespaces_hasURI(swigCPtr, this, uri);
550  }
551
552  
553/**
554   * Predicate returning <code>true</code> or <code>false</code> depending on whether an XML
555   * Namespace with the given prefix is contained in this {@link XMLNamespaces}
556   * list.
557   <p>
558   * @param prefix a string, the prefix for the namespace
559   <p>
560   * @return <code>true</code> if an XML Namespace with the given URI is contained in
561   * this {@link XMLNamespaces} list, <code>false</code> otherwise.
562   */ public
563 boolean hasPrefix(String prefix) {
564    return libsbmlJNI.XMLNamespaces_hasPrefix(swigCPtr, this, prefix);
565  }
566
567  
568/**
569   * Predicate returning <code>true</code> or <code>false</code> depending on whether an XML
570   * Namespace with the given URI and prefix pair is contained in this
571   * {@link XMLNamespaces} list.
572   <p>
573   * @param uri a string, the URI for the namespace
574   * @param prefix a string, the prefix for the namespace
575   <p>
576   * @return <code>true</code> if an XML Namespace with the given uri/prefix pair is
577   * contained in this {@link XMLNamespaces} list, <code>false</code> otherwise.
578   */ public
579 boolean hasNS(String uri, String prefix) {
580    return libsbmlJNI.XMLNamespaces_hasNS(swigCPtr, this, uri, prefix);
581  }
582
583}