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