/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.38
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package org.sbml.libsbml;

/** 
 * Class providing a unified interface to different XML parsers.
 * <p>
 * @deprecated libSBML internal 
 */

public class XMLParser {
   private long swigCPtr;
   protected boolean swigCMemOwn;

   protected XMLParser(long cPtr, boolean cMemoryOwn)
   {
     swigCMemOwn = cMemoryOwn;
     swigCPtr    = cPtr;
   }

   protected static long getCPtr(XMLParser obj)
   {
     return (obj == null) ? 0 : obj.swigCPtr;
   }

   protected static long getCPtrAndDisown (XMLParser obj)
   {
     long ptr = 0;

     if (obj != null)
     {
       ptr             = obj.swigCPtr;
       obj.swigCMemOwn = false;
     }

     return ptr;
   }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      libsbmlJNI.delete_XMLParser(swigCPtr);
    }
    swigCPtr = 0;
  }

  
  /**
   * Creates a new XMLParser.  The parser will notify the given XMLHandler
   * of parse events and errors.
   * <p>
   * The library parameter indicates the underlying XML library to use if
   * the XML compatibility layer has been linked against multiple XML
   * libraries.  It may be one of: 'expat' (default), 'libxml', or
   * 'xerces'.
   * <p>
   * If the XML compatibility layer has been linked against only a single
   * XML library, the library parameter is ignored.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   */
 public static XMLParser create(XMLHandler handler, String library) {
    long cPtr = libsbmlJNI.XMLParser_create__SWIG_0(XMLHandler.getCPtr(handler), handler, library);
    return (cPtr == 0) ? null : new XMLParser(cPtr, false);
  }

  
  /**
   * Creates a new XMLParser.  The parser will notify the given XMLHandler
   * of parse events and errors.
   * <p>
   * The library parameter indicates the underlying XML library to use if
   * the XML compatibility layer has been linked against multiple XML
   * libraries.  It may be one of: 'expat' (default), 'libxml', or
   * 'xerces'.
   * <p>
   * If the XML compatibility layer has been linked against only a single
   * XML library, the library parameter is ignored.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   */
 public static XMLParser create(XMLHandler handler) {
    long cPtr = libsbmlJNI.XMLParser_create__SWIG_1(XMLHandler.getCPtr(handler), handler);
    return (cPtr == 0) ? null : new XMLParser(cPtr, false);
  }

  
  /**
   * Parses XML content in one fell swoop.
   * <p>
   * If isFile is true (default), content is treated as a filename from
   * which to read the XML content.  Otherwise, content is treated as a
   * null-terminated buffer containing XML data and is read directly.
   * <p>
   * @return true if the parse was successful, false otherwise.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   */
 public boolean parse(String content, boolean isFile) {
    return libsbmlJNI.XMLParser_parse__SWIG_0(swigCPtr, this, content, isFile);
  }

  
  /**
   * Parses XML content in one fell swoop.
   * <p>
   * If isFile is true (default), content is treated as a filename from
   * which to read the XML content.  Otherwise, content is treated as a
   * null-terminated buffer containing XML data and is read directly.
   * <p>
   * @return true if the parse was successful, false otherwise.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   */
 public boolean parse(String content) {
    return libsbmlJNI.XMLParser_parse__SWIG_1(swigCPtr, this, content);
  }

  
  /**
   * Begins a progressive parse of XML content.  This parses the first
   * chunk of the XML content and returns.  Successive chunks are parsed by
   * calling parseNext().
   * <p>
   * A chunk differs slightly depending on the underlying XML parser.  For
   * Xerces and libXML chunks correspond to XML elements.  For Expat, a
   * chunk is the size of its internal buffer.
   * <p>
   * If isFile is true (default), content is treated as a filename from
   * which to read the XML content.  Otherwise, content is treated as a
   * null-terminated buffer containing XML data and is read directly.
   * <p>
   * @return true if the first step of the progressive parse was
   * successful, false otherwise.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   */
 public boolean parseFirst(String content, boolean isFile) {
    return libsbmlJNI.XMLParser_parseFirst__SWIG_0(swigCPtr, this, content, isFile);
  }

  
  /**
   * Begins a progressive parse of XML content.  This parses the first
   * chunk of the XML content and returns.  Successive chunks are parsed by
   * calling parseNext().
   * <p>
   * A chunk differs slightly depending on the underlying XML parser.  For
   * Xerces and libXML chunks correspond to XML elements.  For Expat, a
   * chunk is the size of its internal buffer.
   * <p>
   * If isFile is true (default), content is treated as a filename from
   * which to read the XML content.  Otherwise, content is treated as a
   * null-terminated buffer containing XML data and is read directly.
   * <p>
   * @return true if the first step of the progressive parse was
   * successful, false otherwise.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   */
 public boolean parseFirst(String content) {
    return libsbmlJNI.XMLParser_parseFirst__SWIG_1(swigCPtr, this, content);
  }

  
  /**
   * Parses the next chunk of XML content.
   * <p>
   * @return true if the next step of the progressive parse was successful,
   * false otherwise or when at EOF.
   */
 public boolean parseNext() {
    return libsbmlJNI.XMLParser_parseNext(swigCPtr, this);
  }

  
  /**
   * Resets the progressive parser.  Call between the last call to
   * parseNext() and the next call to parseFirst().
   */
 public void parseReset() {
    libsbmlJNI.XMLParser_parseReset(swigCPtr, this);
  }

  
  /**
   * @return the current column position of the parser.
   */
 public long getColumn() {
    return libsbmlJNI.XMLParser_getColumn(swigCPtr, this);
  }

  
  /**
   * @return the current line position of the parser.
   */
 public long getLine() {
    return libsbmlJNI.XMLParser_getLine(swigCPtr, this);
  }

  
  /**
   * @return an XMLErrorLog which can be used to log XML parse errors and
   * other validation errors (and messages).
   */
 public XMLErrorLog getErrorLog() {
    long cPtr = libsbmlJNI.XMLParser_getErrorLog(swigCPtr, this);
    return (cPtr == 0) ? null : new XMLErrorLog(cPtr, false);
  }

  
  /**
   * Sets the XMLErrorLog this parser will use to log errors.
   */
 public void setErrorLog(XMLErrorLog log) {
    libsbmlJNI.XMLParser_setErrorLog(swigCPtr, this, XMLErrorLog.getCPtr(log), log);
  }

}
