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

namespace clucene.net {

using System;
using System.Runtime.InteropServices;

public class IndexReader : IDisposable {
  private HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal IndexReader(IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(IndexReader obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~IndexReader() {
    Dispose();
  }

  public virtual void Dispose() {
    if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
      swigCMemOwn = false;
      libCLcsharpPINVOKE.delete_IndexReader(swigCPtr);
    }
    swigCPtr = new HandleRef(null, IntPtr.Zero);
    GC.SuppressFinalize(this);
  }

  public virtual void commit() {
    libCLcsharpPINVOKE.IndexReader_commit(swigCPtr);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public void undeleteAll() {
    libCLcsharpPINVOKE.IndexReader_undeleteAll(swigCPtr);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public virtual string[] getFieldNames() { return new _CL_p_p_charArray(libCLcsharpPINVOKE.IndexReader_getFieldNames__SWIG_0(swigCPtr),true).toArray(); }

  public virtual string[] getFieldNames(bool indexed) { return new _CL_p_p_charArray(libCLcsharpPINVOKE.IndexReader_getFieldNames__SWIG_1(swigCPtr, indexed),true).toArray(); }

  public virtual string[] getIndexedFieldNames(bool storedTermVector) { return new _CL_p_p_charArray(libCLcsharpPINVOKE.IndexReader_getIndexedFieldNames(swigCPtr, storedTermVector),true).toArray(); }

  public virtual byte[] norms(string field) { return new _CL_p_uint8_tArray(libCLcsharpPINVOKE.IndexReader_norms(swigCPtr, field),true).toArray(); }

  public void setNorm(int doc, string field, float value) {
    libCLcsharpPINVOKE.IndexReader_setNorm__SWIG_0(swigCPtr, doc, field, value);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public void setNorm(int doc, string field, byte value) {
    libCLcsharpPINVOKE.IndexReader_setNorm__SWIG_1(swigCPtr, doc, field, value);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public static IndexReader open(string path) {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_open__SWIG_0(path);
    IndexReader ret = (cPtr == IntPtr.Zero) ? null : new IndexReader(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static IndexReader open(Directory directory, bool closeDirectory) {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_open__SWIG_1(Directory.getCPtr(directory), closeDirectory);
    IndexReader ret = (cPtr == IntPtr.Zero) ? null : new IndexReader(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static IndexReader open(Directory directory) {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_open__SWIG_2(Directory.getCPtr(directory));
    IndexReader ret = (cPtr == IntPtr.Zero) ? null : new IndexReader(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static long lastModified(string directory) {
    long ret = libCLcsharpPINVOKE.IndexReader_lastModified__SWIG_0(directory);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static long lastModified(Directory directory) {
    long ret = libCLcsharpPINVOKE.IndexReader_lastModified__SWIG_1(Directory.getCPtr(directory));
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static long getCurrentVersion(Directory directory) {
    long ret = libCLcsharpPINVOKE.IndexReader_getCurrentVersion__SWIG_0(Directory.getCPtr(directory));
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static long getCurrentVersion(string directory) {
    long ret = libCLcsharpPINVOKE.IndexReader_getCurrentVersion__SWIG_1(directory);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual TermFreqVector[] getTermFreqVectors(int docNumber) { return new _CL_p_p_lucene__index__TermFreqVectorArray(libCLcsharpPINVOKE.IndexReader_getTermFreqVectors(swigCPtr, docNumber),true).toArray(); }

  public virtual TermFreqVector getTermFreqVector(int docNumber, string field) {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_getTermFreqVector(swigCPtr, docNumber, field);
    TermFreqVector ret = (cPtr == IntPtr.Zero) ? null : new TermFreqVector(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static bool indexExists(string directory) {
    bool ret = libCLcsharpPINVOKE.IndexReader_indexExists__SWIG_0(directory);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static bool indexExists(Directory directory) {
    bool ret = libCLcsharpPINVOKE.IndexReader_indexExists__SWIG_1(Directory.getCPtr(directory));
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual int numDocs() {
    int ret = libCLcsharpPINVOKE.IndexReader_numDocs(swigCPtr);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual int maxDoc() {
    int ret = libCLcsharpPINVOKE.IndexReader_maxDoc(swigCPtr);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual Document document(int n) {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_document(swigCPtr, n);
    Document ret = (cPtr == IntPtr.Zero) ? null : new Document(cPtr, false);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual bool isDeleted(int n) {
    bool ret = libCLcsharpPINVOKE.IndexReader_isDeleted(swigCPtr, n);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual bool hasDeletions() {
    bool ret = libCLcsharpPINVOKE.IndexReader_hasDeletions(swigCPtr);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual TermEnum terms() {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_terms__SWIG_0(swigCPtr);
    TermEnum ret = (cPtr == IntPtr.Zero) ? null : new TermEnum(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual TermEnum terms(Term t) {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_terms__SWIG_1(swigCPtr, Term.getCPtr(t));
    TermEnum ret = (cPtr == IntPtr.Zero) ? null : new TermEnum(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual int docFreq(Term t) {
    int ret = libCLcsharpPINVOKE.IndexReader_docFreq(swigCPtr, Term.getCPtr(t));
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual TermPositions termPositions() {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_termPositions__SWIG_0(swigCPtr);
    TermPositions ret = (cPtr == IntPtr.Zero) ? null : new TermPositions(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public TermPositions termPositions(Term term) {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_termPositions__SWIG_1(swigCPtr, Term.getCPtr(term));
    TermPositions ret = (cPtr == IntPtr.Zero) ? null : new TermPositions(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual TermDocs termDocs() {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_termDocs__SWIG_0(swigCPtr);
    TermDocs ret = (cPtr == IntPtr.Zero) ? null : new TermDocs(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public TermDocs termDocs(Term term) {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_termDocs__SWIG_1(swigCPtr, Term.getCPtr(term));
    TermDocs ret = (cPtr == IntPtr.Zero) ? null : new TermDocs(cPtr, true);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void Delete(int docNum) {
    libCLcsharpPINVOKE.IndexReader_Delete__SWIG_0(swigCPtr, docNum);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public int Delete(Term term) {
    int ret = libCLcsharpPINVOKE.IndexReader_Delete__SWIG_1(swigCPtr, Term.getCPtr(term));
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void close() {
    libCLcsharpPINVOKE.IndexReader_close(swigCPtr);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public static bool isLocked(Directory directory) {
    bool ret = libCLcsharpPINVOKE.IndexReader_isLocked__SWIG_0(Directory.getCPtr(directory));
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static bool isLocked(string directory) {
    bool ret = libCLcsharpPINVOKE.IndexReader_isLocked__SWIG_1(directory);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public static void unlock(Directory directory) {
    libCLcsharpPINVOKE.IndexReader_unlock__SWIG_0(Directory.getCPtr(directory));
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public static void unlock(string path) {
    libCLcsharpPINVOKE.IndexReader_unlock__SWIG_1(path);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
  }

  public Directory getDirectory() {
    IntPtr cPtr = libCLcsharpPINVOKE.IndexReader_getDirectory(swigCPtr);
    Directory ret = (cPtr == IntPtr.Zero) ? null : new Directory(cPtr, false);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
