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

package org.xapian;

public class Database {
  private transient long swigCPtr;
  protected transient boolean swigCMemOwn;

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

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

  protected static long swigRelease(Database obj) {
    long ptr = 0;
    if (obj != null) {
      if (!obj.swigCMemOwn)
        throw new RuntimeException("Cannot release ownership as memory is not owned");
      ptr = obj.swigCPtr;
      obj.swigCMemOwn = false;
      obj.delete();
    }
    return ptr;
  }

  @SuppressWarnings({"deprecation", "removal"})
  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        XapianJNI.delete_Database(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public void addDatabase(Database other) {
    XapianJNI.Database_addDatabase(swigCPtr, this, Database.getCPtr(other), other);
  }

  public long size() {
    return XapianJNI.Database_size(swigCPtr, this);
  }

  public Database() {
    this(XapianJNI.new_Database__SWIG_0(), true);
  }

  public Database(String path, int flags) {
    this(XapianJNI.new_Database__SWIG_1(path, flags), true);
  }

  public Database(String path) {
    this(XapianJNI.new_Database__SWIG_2(path), true);
  }

  public Database(int fd, int flags) {
    this(XapianJNI.new_Database__SWIG_3(fd, flags), true);
  }

  public Database(int fd) {
    this(XapianJNI.new_Database__SWIG_4(fd), true);
  }

  public boolean reopen() {
    return XapianJNI.Database_reopen(swigCPtr, this);
  }

  public void close() {
    XapianJNI.Database_close(swigCPtr, this);
  }

  public String toString() {
    return XapianJNI.Database_toString(swigCPtr, this);
  }

  public PostingIterator postListBegin(String term) {
    return new PostingIterator(XapianJNI.Database_postListBegin(swigCPtr, this, term), true);
  }

  public PostingIterator postListEnd(String arg0) {
    return new PostingIterator(XapianJNI.Database_postListEnd(swigCPtr, this, arg0), true);
  }

  public TermIterator termListBegin(long did) {
    return new TermIterator(XapianJNI.Database_termListBegin(swigCPtr, this, did), true);
  }

  public TermIterator termListEnd(long arg0) {
    return new TermIterator(XapianJNI.Database_termListEnd(swigCPtr, this, arg0), true);
  }

  public boolean hasPositions() {
    return XapianJNI.Database_hasPositions(swigCPtr, this);
  }

  public PositionIterator positionListBegin(long did, String term) {
    return new PositionIterator(XapianJNI.Database_positionListBegin(swigCPtr, this, did, term), true);
  }

  public PositionIterator positionListEnd(long arg0, String arg1) {
    return new PositionIterator(XapianJNI.Database_positionListEnd(swigCPtr, this, arg0, arg1), true);
  }

  public TermIterator allTermsBegin(String prefix) {
    return new TermIterator(XapianJNI.Database_allTermsBegin__SWIG_0(swigCPtr, this, prefix), true);
  }

  public TermIterator allTermsBegin() {
    return new TermIterator(XapianJNI.Database_allTermsBegin__SWIG_1(swigCPtr, this), true);
  }

  public TermIterator allTermsEnd(String arg0) {
    return new TermIterator(XapianJNI.Database_allTermsEnd__SWIG_0(swigCPtr, this, arg0), true);
  }

  public TermIterator allTermsEnd() {
    return new TermIterator(XapianJNI.Database_allTermsEnd__SWIG_1(swigCPtr, this), true);
  }

  public long getDocCount() {
    return XapianJNI.Database_getDocCount(swigCPtr, this);
  }

  public long getLastDocId() {
    return XapianJNI.Database_getLastDocId(swigCPtr, this);
  }

  public double getAverageLength() {
    return XapianJNI.Database_getAverageLength(swigCPtr, this);
  }

  public double getAvLength() {
    return XapianJNI.Database_getAvLength(swigCPtr, this);
  }

  public long getTotalLength() {
    return XapianJNI.Database_getTotalLength(swigCPtr, this);
  }

  public long getTermFreq(String term) {
    return XapianJNI.Database_getTermFreq(swigCPtr, this, term);
  }

  public boolean termExists(String term) {
    return XapianJNI.Database_termExists(swigCPtr, this, term);
  }

  public long getCollectionFreq(String term) {
    return XapianJNI.Database_getCollectionFreq(swigCPtr, this, term);
  }

  public long getValueFreq(int slot) {
    return XapianJNI.Database_getValueFreq(swigCPtr, this, slot);
  }

  public byte[] getValueLowerBound(int slot) {
    return XapianJNI.Database_getValueLowerBound(swigCPtr, this, slot);
  }

  public byte[] getValueUpperBound(int slot) {
    return XapianJNI.Database_getValueUpperBound(swigCPtr, this, slot);
  }

  public long getDoclengthLowerBound() {
    return XapianJNI.Database_getDoclengthLowerBound(swigCPtr, this);
  }

  public long getDoclengthUpperBound() {
    return XapianJNI.Database_getDoclengthUpperBound(swigCPtr, this);
  }

  public long getWdfUpperBound(String term) {
    return XapianJNI.Database_getWdfUpperBound(swigCPtr, this, term);
  }

  public long getUniqueTermsLowerBound() {
    return XapianJNI.Database_getUniqueTermsLowerBound(swigCPtr, this);
  }

  public long getUniqueTermsUpperBound() {
    return XapianJNI.Database_getUniqueTermsUpperBound(swigCPtr, this);
  }

  public ValueIterator valuestreamBegin(int slot) {
    return new ValueIterator(XapianJNI.Database_valuestreamBegin(swigCPtr, this, slot), true);
  }

  public ValueIterator valuestreamEnd(int arg0) {
    return new ValueIterator(XapianJNI.Database_valuestreamEnd(swigCPtr, this, arg0), true);
  }

  public long getDocLength(long did) {
    return XapianJNI.Database_getDocLength(swigCPtr, this, did);
  }

  public long getUniqueTerms(long did) {
    return XapianJNI.Database_getUniqueTerms(swigCPtr, this, did);
  }

  public long getWdfdocmax(long did) {
    return XapianJNI.Database_getWdfdocmax(swigCPtr, this, did);
  }

  public void keepAlive() {
    XapianJNI.Database_keepAlive(swigCPtr, this);
  }

  public Document getDocument(long did, long flags) {
    return new Document(XapianJNI.Database_getDocument__SWIG_0(swigCPtr, this, did, flags), true);
  }

  public Document getDocument(long did) {
    return new Document(XapianJNI.Database_getDocument__SWIG_1(swigCPtr, this, did), true);
  }

  public String getSpellingSuggestion(String word, long max_edit_distance) {
    return XapianJNI.Database_getSpellingSuggestion__SWIG_0(swigCPtr, this, word, max_edit_distance);
  }

  public String getSpellingSuggestion(String word) {
    return XapianJNI.Database_getSpellingSuggestion__SWIG_1(swigCPtr, this, word);
  }

  public TermIterator spellingsBegin() {
    return new TermIterator(XapianJNI.Database_spellingsBegin(swigCPtr, this), true);
  }

  public TermIterator spellingsEnd() {
    return new TermIterator(XapianJNI.Database_spellingsEnd(swigCPtr, this), true);
  }

  public TermIterator synonymsBegin(String term) {
    return new TermIterator(XapianJNI.Database_synonymsBegin(swigCPtr, this, term), true);
  }

  public TermIterator synonymsEnd(String arg0) {
    return new TermIterator(XapianJNI.Database_synonymsEnd(swigCPtr, this, arg0), true);
  }

  public TermIterator synonymKeysBegin(String prefix) {
    return new TermIterator(XapianJNI.Database_synonymKeysBegin__SWIG_0(swigCPtr, this, prefix), true);
  }

  public TermIterator synonymKeysBegin() {
    return new TermIterator(XapianJNI.Database_synonymKeysBegin__SWIG_1(swigCPtr, this), true);
  }

  public TermIterator synonymKeysEnd(String arg0) {
    return new TermIterator(XapianJNI.Database_synonymKeysEnd__SWIG_0(swigCPtr, this, arg0), true);
  }

  public TermIterator synonymKeysEnd() {
    return new TermIterator(XapianJNI.Database_synonymKeysEnd__SWIG_1(swigCPtr, this), true);
  }

  public String getMetadata(String key) {
    return XapianJNI.Database_getMetadata(swigCPtr, this, key);
  }

  public TermIterator metadataKeysBegin(String prefix) {
    return new TermIterator(XapianJNI.Database_metadataKeysBegin__SWIG_0(swigCPtr, this, prefix), true);
  }

  public TermIterator metadataKeysBegin() {
    return new TermIterator(XapianJNI.Database_metadataKeysBegin__SWIG_1(swigCPtr, this), true);
  }

  public TermIterator metadataKeysEnd(String arg0) {
    return new TermIterator(XapianJNI.Database_metadataKeysEnd__SWIG_0(swigCPtr, this, arg0), true);
  }

  public TermIterator metadataKeysEnd() {
    return new TermIterator(XapianJNI.Database_metadataKeysEnd__SWIG_1(swigCPtr, this), true);
  }

  public String getUuid() {
    return XapianJNI.Database_getUuid(swigCPtr, this);
  }

  public boolean locked() {
    return XapianJNI.Database_locked(swigCPtr, this);
  }

  public WritableDatabase lock(int flags) {
    return new WritableDatabase(XapianJNI.Database_lock__SWIG_0(swigCPtr, this, flags), true);
  }

  public WritableDatabase lock() {
    return new WritableDatabase(XapianJNI.Database_lock__SWIG_1(swigCPtr, this), true);
  }

  public Database unlock() {
    return new Database(XapianJNI.Database_unlock(swigCPtr, this), true);
  }

  public long getRevision() {
    return XapianJNI.Database_getRevision(swigCPtr, this);
  }

  public static long check(String path, int opts) {
    return XapianJNI.Database_check__SWIG_0(path, opts);
  }

  public static long check(String path) {
    return XapianJNI.Database_check__SWIG_1(path);
  }

  public static long check(int fd, int opts) {
    return XapianJNI.Database_check__SWIG_2(fd, opts);
  }

  public static long check(int fd) {
    return XapianJNI.Database_check__SWIG_3(fd);
  }

  public void compact(String output, long flags, int block_size) {
    XapianJNI.Database_compact__SWIG_0(swigCPtr, this, output, flags, block_size);
  }

  public void compact(String output, long flags) {
    XapianJNI.Database_compact__SWIG_1(swigCPtr, this, output, flags);
  }

  public void compact(String output) {
    XapianJNI.Database_compact__SWIG_2(swigCPtr, this, output);
  }

  public void compact(int fd, long flags, int block_size) {
    XapianJNI.Database_compact__SWIG_3(swigCPtr, this, fd, flags, block_size);
  }

  public void compact(int fd, long flags) {
    XapianJNI.Database_compact__SWIG_4(swigCPtr, this, fd, flags);
  }

  public void compact(int fd) {
    XapianJNI.Database_compact__SWIG_5(swigCPtr, this, fd);
  }

  public void compact(String output, long flags, int block_size, Compactor compactor) {
    XapianJNI.Database_compact__SWIG_6(swigCPtr, this, output, flags, block_size, Compactor.getCPtr(compactor), compactor);
  }

  public void compact(int fd, long flags, int block_size, Compactor compactor) {
    XapianJNI.Database_compact__SWIG_7(swigCPtr, this, fd, flags, block_size, Compactor.getCPtr(compactor), compactor);
  }

  public String reconstructText(long did, long length, String prefix, long start_pos, long end_pos) {
    return XapianJNI.Database_reconstructText__SWIG_0(swigCPtr, this, did, length, prefix, start_pos, end_pos);
  }

  public String reconstructText(long did, long length, String prefix, long start_pos) {
    return XapianJNI.Database_reconstructText__SWIG_1(swigCPtr, this, did, length, prefix, start_pos);
  }

  public String reconstructText(long did, long length, String prefix) {
    return XapianJNI.Database_reconstructText__SWIG_2(swigCPtr, this, did, length, prefix);
  }

  public String reconstructText(long did, long length) {
    return XapianJNI.Database_reconstructText__SWIG_3(swigCPtr, this, did, length);
  }

  public String reconstructText(long did) {
    return XapianJNI.Database_reconstructText__SWIG_4(swigCPtr, this, did);
  }

}
