001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 2.0.11
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 * 
013 * Representation of a qualified XML name.
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.  This class is not prescribed by
018the SBML specifications, although it is used to implement features
019defined in SBML.
020</p>
021
022 * <p>
023 * A 'triple' in the libSBML XML layer encapsulates the notion of qualified
024 * name, meaning an element name or an attribute name with an optional
025 * namespace qualifier.  An {@link XMLTriple} instance carries up to three data items:
026 * <p>
027 * <ul>
028 * <p>
029 * <li> The name of the attribute or element; that is, the attribute name
030 * as it appears in an XML document or data stream;
031 * <p>
032 * <li> The XML namespace prefix (if any) of the attribute.  For example,
033 * in the following fragment of XML, the namespace prefix is the string
034 * <code>mysim</code> and it appears on both the element
035 * <code>someelement</code> and the attribute <code>attribA</code>.  When
036 * both the element and the attribute are stored as {@link XMLTriple} objects,
037 * their <i>prefix</i> is <code>mysim</code>.
038 * <div class='fragment'><pre>
039&lt;mysim:someelement mysim:attribA='value' /&gt;
040</pre></div>
041 * <p>
042 * <li> The XML namespace URI with which the prefix is associated.  In
043 * XML, every namespace used must be declared and mapped to a URI.
044 * <p>
045 * </ul>
046 * <p>
047 * {@link XMLTriple} objects are the lowest-level data item in the XML layer
048 * of libSBML.  Other objects such as {@link XMLToken} make use of {@link XMLTriple}
049 * objects.
050 */
051
052public class XMLTriple {
053   private long swigCPtr;
054   protected boolean swigCMemOwn;
055
056   protected XMLTriple(long cPtr, boolean cMemoryOwn)
057   {
058     swigCMemOwn = cMemoryOwn;
059     swigCPtr    = cPtr;
060   }
061
062   protected static long getCPtr(XMLTriple obj)
063   {
064     return (obj == null) ? 0 : obj.swigCPtr;
065   }
066
067   protected static long getCPtrAndDisown (XMLTriple obj)
068   {
069     long ptr = 0;
070
071     if (obj != null)
072     {
073       ptr             = obj.swigCPtr;
074       obj.swigCMemOwn = false;
075     }
076
077     return ptr;
078   }
079
080  protected void finalize() {
081    delete();
082  }
083
084  public synchronized void delete() {
085    if (swigCPtr != 0) {
086      if (swigCMemOwn) {
087        swigCMemOwn = false;
088        libsbmlJNI.delete_XMLTriple(swigCPtr);
089      }
090      swigCPtr = 0;
091    }
092  }
093
094  /**
095   * Equality comparison method for XMLTriple.
096   * <p>
097   * Because the Java methods for libSBML are actually wrappers around code
098   * implemented in C++ and C, certain operations will not behave as
099   * expected.  Equality comparison is one such case.  An instance of a
100   * libSBML object class is actually a <em>proxy object</em>
101   * wrapping the real underlying C/C++ object.  The normal <code>==</code>
102   * equality operator in Java will <em>only compare the Java proxy objects</em>,
103   * not the underlying native object.  The result is almost never what you
104   * want in practical situations.  Unfortunately, Java does not provide a
105   * way to override <code>==</code>.
106   *  <p>
107   * The alternative that must be followed is to use the
108   * <code>equals()</code> method.  The <code>equals</code> method on this
109   * class overrides the default java.lang.Object one, and performs an
110   * intelligent comparison of instances of objects of this class.  The
111   * result is an assessment of whether two libSBML Java objects are truly 
112   * the same underlying native-code objects.
113   *  <p>
114   * The use of this method in practice is the same as the use of any other
115   * Java <code>equals</code> method.  For example,
116   * <em>a</em><code>.equals(</code><em>b</em><code>)</code> returns
117   * <code>true</code> if <em>a</em> and <em>b</em> are references to the
118   * same underlying object.
119   *
120   * @param sb a reference to an object to which the current object
121   * instance will be compared
122   *
123   * @return <code>true</code> if <code>sb</code> refers to the same underlying 
124   * native object as this one, <code>false</code> otherwise
125   */
126  public boolean equals(Object sb)
127  {
128    if ( this == sb ) 
129    {
130      return true;
131    }
132    return swigCPtr == getCPtr((XMLTriple)(sb));
133  }
134
135  /**
136   * Returns a hashcode for this XMLTriple object.
137   *
138   * @return a hash code usable by Java methods that need them.
139   */
140  public int hashCode()
141  {
142    return (int)(swigCPtr^(swigCPtr>>>32));
143  }
144
145  
146/**
147   * Creates a new, empty {@link XMLTriple}.
148   */ public
149 XMLTriple() {
150    this(libsbmlJNI.new_XMLTriple__SWIG_0(), true);
151  }
152
153  
154/**
155   * Creates a new {@link XMLTriple} with the given <code>name</code>, <code>uri</code> and and 
156   * <code>prefix</code>.
157   * <p>
158   * @param name a string, name for the {@link XMLTriple}.
159   * @param uri a string, URI of the {@link XMLTriple}.
160   * @param prefix a string, prefix for the URI of the {@link XMLTriple},
161   * <p>
162   * @throws XMLConstructorException 
163   * Thrown if the argument <code>orig</code> is <code>null.</code>
164   */ public
165 XMLTriple(String name, String uri, String prefix) {
166    this(libsbmlJNI.new_XMLTriple__SWIG_1(name, uri, prefix), true);
167  }
168
169  
170/**
171   * Creates a new {@link XMLTriple} by splitting the given <code>triplet</code> on the
172   * separator character <code>sepchar</code>.
173   * <p>
174   * Triplet may be in one of the following formats:
175   * <ul>
176   * <li> name
177   * <li> URI sepchar name
178   * <li> URI sepchar name sepchar prefix
179   * </ul>
180   * @param triplet a string representing the triplet as above
181   * @param sepchar a character, the sepchar used in the triplet
182   * <p>
183   * @throws XMLConstructorException 
184   * Thrown if the argument <code>orig</code> is <code>null.</code>
185   * <p>
186   * <!-- Don't remove the leading </dl> below. It's a hack for javadoc. -->
187</dl><dl class='docnote'><dt><b>Documentation note:</b></dt><dd>
188The native C++ implementation of this method defines a default argument
189value. In the documentation generated for different libSBML language
190bindings, you may or may not see corresponding arguments in the method
191declarations. For example, in Java and C#, a default argument is handled by
192declaring two separate methods, with one of them having the argument and
193the other one lacking the argument. However, the libSBML documentation will
194be <em>identical</em> for both methods. Consequently, if you are reading
195this and do not see an argument even though one is described, please look
196for descriptions of other variants of this method near where this one
197appears in the documentation.
198</dd></dl>
199 
200   */ public
201 XMLTriple(String triplet, char sepchar) {
202    this(libsbmlJNI.new_XMLTriple__SWIG_2(triplet, sepchar), true);
203  }
204
205  
206/**
207   * Creates a new {@link XMLTriple} by splitting the given <code>triplet</code> on the
208   * separator character <code>sepchar</code>.
209   * <p>
210   * Triplet may be in one of the following formats:
211   * <ul>
212   * <li> name
213   * <li> URI sepchar name
214   * <li> URI sepchar name sepchar prefix
215   * </ul>
216   * @param triplet a string representing the triplet as above
217   * @param sepchar a character, the sepchar used in the triplet
218   * <p>
219   * @throws XMLConstructorException 
220   * Thrown if the argument <code>orig</code> is <code>null.</code>
221   * <p>
222   * <!-- Don't remove the leading </dl> below. It's a hack for javadoc. -->
223</dl><dl class='docnote'><dt><b>Documentation note:</b></dt><dd>
224The native C++ implementation of this method defines a default argument
225value. In the documentation generated for different libSBML language
226bindings, you may or may not see corresponding arguments in the method
227declarations. For example, in Java and C#, a default argument is handled by
228declaring two separate methods, with one of them having the argument and
229the other one lacking the argument. However, the libSBML documentation will
230be <em>identical</em> for both methods. Consequently, if you are reading
231this and do not see an argument even though one is described, please look
232for descriptions of other variants of this method near where this one
233appears in the documentation.
234</dd></dl>
235 
236   */ public
237 XMLTriple(String triplet) {
238    this(libsbmlJNI.new_XMLTriple__SWIG_3(triplet), true);
239  }
240
241  
242/**
243   * Copy constructor; creates a copy of this {@link XMLTriple} set.
244   * <p>
245   * @param orig the {@link XMLTriple} object to copy.
246   * <p>
247   * @throws XMLConstructorException 
248   * Thrown if the argument <code>orig</code> is <code>null.</code>
249   */ public
250 XMLTriple(XMLTriple orig) {
251    this(libsbmlJNI.new_XMLTriple__SWIG_4(XMLTriple.getCPtr(orig), orig), true);
252  }
253
254  
255/**
256   * Creates and returns a deep copy of this {@link XMLTriple} set.
257   * <p>
258   * @return a (deep) copy of this {@link XMLTriple} set.
259   */ public
260 XMLTriple cloneObject() {
261    long cPtr = libsbmlJNI.XMLTriple_cloneObject(swigCPtr, this);
262    return (cPtr == 0) ? null : new XMLTriple(cPtr, true);
263  }
264
265  
266/**
267   * Returns the <em>name</em> portion of this {@link XMLTriple}.
268   * <p>
269   * @return a string, the name from this {@link XMLTriple}.
270   */ public
271 String getName() {
272    return libsbmlJNI.XMLTriple_getName(swigCPtr, this);
273  }
274
275  
276/**
277   * Returns the <em>prefix</em> portion of this {@link XMLTriple}.
278   * <p>
279   * @return a string, the <em>prefix</em> portion of this {@link XMLTriple}.
280   */ public
281 String getPrefix() {
282    return libsbmlJNI.XMLTriple_getPrefix(swigCPtr, this);
283  }
284
285  
286/**
287   * Returns the <em>URI</em> portion of this {@link XMLTriple}.
288   * <p>
289   * @return URI a string, the <em>prefix</em> portion of this {@link XMLTriple}.
290   */ public
291 String getURI() {
292    return libsbmlJNI.XMLTriple_getURI(swigCPtr, this);
293  }
294
295  
296/**
297   * Returns the prefixed name from this {@link XMLTriple}.
298   * <p>
299   * @return a string, the prefixed name from this {@link XMLTriple}.
300   */ public
301 String getPrefixedName() {
302    return libsbmlJNI.XMLTriple_getPrefixedName(swigCPtr, this);
303  }
304
305  
306/**
307   * Predicate returning <code>true</code> or <code>false</code> depending on whether 
308   * this {@link XMLTriple} is empty.
309   * <p>
310   * @return <code>true</code> if this {@link XMLTriple} is empty, <code>false</code> otherwise.
311   */ public
312 boolean isEmpty() {
313    return libsbmlJNI.XMLTriple_isEmpty(swigCPtr, this);
314  }
315
316}