summaryrefslogtreecommitdiff
path: root/lang/java/src/com/sleepycat/db/internal/DbTxn.java
blob: 0815f7edcb7f375ee4dae6c019fe3c5b4df79fe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.12
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package com.sleepycat.db.internal;

import com.sleepycat.db.*;
import java.util.Comparator;

public class DbTxn {
  private long swigCPtr;
  protected boolean swigCMemOwn;

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

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

  /* package */ synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        throw new UnsupportedOperationException("C++ destructor does not have public access");
      }
      swigCPtr = 0;
    }
  }

	public byte[] commitToken;
	public void abort() throws DatabaseException {
		try {
			abort0();
		} finally {
			swigCPtr = 0;
		}
	}

	public void commit(int flags) throws DatabaseException {
		try {
			db_javaJNI.DbTxn_commit(swigCPtr, this, flags);
		} finally {
			swigCPtr = 0;
		}
	}

	public void discard(int flags) throws DatabaseException {
		try {
			discard0(flags);
		} finally {
			swigCPtr = 0;
		}
	}

	/*
	 * We override Object.equals because it is possible for the Java API to
	 * create multiple DbTxns that reference the same underlying object.
	 * This can happen for example during DbEnv.txn_recover().
	 */
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;

		if (obj != null && (obj instanceof DbTxn)) {
			DbTxn that = (DbTxn)obj;
			return (this.swigCPtr == that.swigCPtr);
		}
		return false;
	}

	/*
	 * We must override Object.hashCode whenever we override
	 * Object.equals() to enforce the maxim that equal objects have the
	 * same hashcode.
	 */
	public int hashCode()
	{
		return ((int)swigCPtr ^ (int)(swigCPtr >> 32));
	}

  /* package */ void abort0() { db_javaJNI.DbTxn_abort0(swigCPtr, this); }

  /* package */ void discard0(int flags) { db_javaJNI.DbTxn_discard0(swigCPtr, this, flags); }

  public String get_name() throws com.sleepycat.db.DatabaseException {
    return db_javaJNI.DbTxn_get_name(swigCPtr, this);
  }

  public int get_priority() throws com.sleepycat.db.DatabaseException { return db_javaJNI.DbTxn_get_priority(swigCPtr, this); }

  public int id() throws com.sleepycat.db.DatabaseException { return db_javaJNI.DbTxn_id(swigCPtr, this); }

  public void prepare(byte[] gid) throws com.sleepycat.db.DatabaseException { db_javaJNI.DbTxn_prepare(swigCPtr, this, gid); }

  public void set_timeout(long timeout, int flags) throws com.sleepycat.db.DatabaseException { db_javaJNI.DbTxn_set_timeout(swigCPtr, this, timeout, flags); }

  public void set_name(String name) throws com.sleepycat.db.DatabaseException { db_javaJNI.DbTxn_set_name(swigCPtr, this, name); }

  public void set_priority(int priority) throws com.sleepycat.db.DatabaseException { db_javaJNI.DbTxn_set_priority(swigCPtr, this, priority); }

}