/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 3.0.9
 *
 * 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 WritableDatabase extends Database {
  private transient long swigCPtr;

  protected WritableDatabase(long cPtr, boolean cMemoryOwn) {
    super(XapianJNI.WritableDatabase_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

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

  protected void finalize() {
    delete();
  }

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

  public WritableDatabase() {
    this(XapianJNI.new_WritableDatabase__SWIG_0(), true);
  }

  public WritableDatabase(String path, int flags, int block_size) {
    this(XapianJNI.new_WritableDatabase__SWIG_1(path, flags, block_size), true);
  }

  public WritableDatabase(String path, int flags) {
    this(XapianJNI.new_WritableDatabase__SWIG_2(path, flags), true);
  }

  public WritableDatabase(String path) {
    this(XapianJNI.new_WritableDatabase__SWIG_3(path), true);
  }

  public void commit() {
    XapianJNI.WritableDatabase_commit(swigCPtr, this);
  }

  public void flush() {
    XapianJNI.WritableDatabase_flush(swigCPtr, this);
  }

  public void beginTransaction(boolean flushed) {
    XapianJNI.WritableDatabase_beginTransaction__SWIG_0(swigCPtr, this, flushed);
  }

  public void beginTransaction() {
    XapianJNI.WritableDatabase_beginTransaction__SWIG_1(swigCPtr, this);
  }

  public void commitTransaction() {
    XapianJNI.WritableDatabase_commitTransaction(swigCPtr, this);
  }

  public void cancelTransaction() {
    XapianJNI.WritableDatabase_cancelTransaction(swigCPtr, this);
  }

  public long addDocument(Document document) {
    return XapianJNI.WritableDatabase_addDocument(swigCPtr, this, Document.getCPtr(document), document);
  }

  public void deleteDocument(long did) {
    XapianJNI.WritableDatabase_deleteDocument__SWIG_0(swigCPtr, this, did);
  }

  public void deleteDocument(String unique_term) {
    XapianJNI.WritableDatabase_deleteDocument__SWIG_1(swigCPtr, this, unique_term);
  }

  public void replaceDocument(long did, Document document) {
    XapianJNI.WritableDatabase_replaceDocument__SWIG_0(swigCPtr, this, did, Document.getCPtr(document), document);
  }

  public long replaceDocument(String unique_term, Document document) {
    return XapianJNI.WritableDatabase_replaceDocument__SWIG_1(swigCPtr, this, unique_term, Document.getCPtr(document), document);
  }

  public void addSpelling(String word, long freqinc) {
    XapianJNI.WritableDatabase_addSpelling__SWIG_0(swigCPtr, this, word, freqinc);
  }

  public void addSpelling(String word) {
    XapianJNI.WritableDatabase_addSpelling__SWIG_1(swigCPtr, this, word);
  }

  public void removeSpelling(String word, long freqdec) {
    XapianJNI.WritableDatabase_removeSpelling__SWIG_0(swigCPtr, this, word, freqdec);
  }

  public void removeSpelling(String word) {
    XapianJNI.WritableDatabase_removeSpelling__SWIG_1(swigCPtr, this, word);
  }

  public void addSynonym(String term, String synonym) {
    XapianJNI.WritableDatabase_addSynonym(swigCPtr, this, term, synonym);
  }

  public void removeSynonym(String term, String synonym) {
    XapianJNI.WritableDatabase_removeSynonym(swigCPtr, this, term, synonym);
  }

  public void clearSynonyms(String term) {
    XapianJNI.WritableDatabase_clearSynonyms(swigCPtr, this, term);
  }

  public void setMetadata(String key, String value) {
    XapianJNI.WritableDatabase_setMetadata(swigCPtr, this, key, value);
  }

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

}
