/* ----------------------------------------------------------------------------
 * 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 Searchable : IDisposable {
  private HandleRef swigCPtr;
  protected bool swigCMemOwn;

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

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

  ~Searchable() {
    Dispose();
  }

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

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

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

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

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

  public virtual Explanation explain(Query query, int doc) {
    IntPtr cPtr = libCLcsharpPINVOKE.Searchable_explain(swigCPtr, Query.getCPtr(query), doc);
    Explanation ret = (cPtr == IntPtr.Zero) ? null : new Explanation(cPtr, false);
    if (libCLcsharpPINVOKE.SWIGPendingException.Pending) throw libCLcsharpPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
