/* ----------------------------------------------------------------------------
 * 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 ValueWeightPostingSource extends ValuePostingSource {
  private transient long swigCPtr;

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

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

  protected static long swigRelease(ValueWeightPostingSource 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_ValueWeightPostingSource(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  protected void swigDirectorDisconnect() {
    swigCMemOwn = false;
    delete();
  }

  public void swigReleaseOwnership() {
    swigCMemOwn = false;
    XapianJNI.ValueWeightPostingSource_change_ownership(this, swigCPtr, false);
  }

  public void swigTakeOwnership() {
    swigCMemOwn = true;
    XapianJNI.ValueWeightPostingSource_change_ownership(this, swigCPtr, true);
  }

  public ValueWeightPostingSource(int slot_) {
    this(XapianJNI.new_ValueWeightPostingSource(slot_), true);
    XapianJNI.ValueWeightPostingSource_director_connect(this, swigCPtr, true, true);
  }

  public double getWeight() {
    return (getClass() == ValueWeightPostingSource.class) ? XapianJNI.ValueWeightPostingSource_getWeight(swigCPtr, this) : XapianJNI.ValueWeightPostingSource_getWeightSwigExplicitValueWeightPostingSource(swigCPtr, this);
  }

  public String name() {
    return (getClass() == ValueWeightPostingSource.class) ? XapianJNI.ValueWeightPostingSource_name(swigCPtr, this) : XapianJNI.ValueWeightPostingSource_nameSwigExplicitValueWeightPostingSource(swigCPtr, this);
  }

  public void init(Database db_) {
    if (getClass() == ValueWeightPostingSource.class) XapianJNI.ValueWeightPostingSource_init(swigCPtr, this, Database.getCPtr(db_), db_); else XapianJNI.ValueWeightPostingSource_initSwigExplicitValueWeightPostingSource(swigCPtr, this, Database.getCPtr(db_), db_);
  }

  public String toString() {
    return (getClass() == ValueWeightPostingSource.class) ? XapianJNI.ValueWeightPostingSource_toString(swigCPtr, this) : XapianJNI.ValueWeightPostingSource_toStringSwigExplicitValueWeightPostingSource(swigCPtr, this);
  }

}
