本文整理匯總了Java中com.sleepycat.je.Cursor.getDatabase方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.getDatabase方法的具體用法?Java Cursor.getDatabase怎麽用?Java Cursor.getDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sleepycat.je.Cursor
的用法示例。
在下文中一共展示了Cursor.getDatabase方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dupCursor
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
* Duplicates a cursor for a given database.
*
* @param writeCursor true to open a write cursor in a CDB environment, and
* ignored for other environments.
*
* @param samePosition is passed through to Cursor.dup().
*
* @return the open cursor.
*
* @throws DatabaseException if a database problem occurs.
*/
Cursor dupCursor(Cursor cursor, boolean writeCursor, boolean samePosition)
throws DatabaseException {
if (cdbMode) {
WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
if (cdbCursorsMap != null) {
Database db = cursor.getDatabase();
CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
if (cdbCursors != null) {
List cursors = writeCursor ? cdbCursors.writeCursors
: cdbCursors.readCursors;
if (cursors.contains(cursor)) {
Cursor newCursor = cursor.dup(samePosition);
cursors.add(newCursor);
return newCursor;
}
}
}
throw new IllegalStateException("cursor to dup not tracked");
} else {
return cursor.dup(samePosition);
}
}
示例2: closeCursor
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
* Closes a cursor.
*
* @param cursor the cursor to close.
*
* @throws DatabaseException if a database problem occurs.
*/
void closeCursor(Cursor cursor)
throws DatabaseException {
if (cursor == null) {
return;
}
if (cdbMode) {
WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
if (cdbCursorsMap != null) {
Database db = cursor.getDatabase();
CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
if (cdbCursors != null) {
if (cdbCursors.readCursors.remove(cursor) ||
cdbCursors.writeCursors.remove(cursor)) {
cursor.close();
return;
}
}
}
throw new IllegalStateException(
"closing CDB cursor that was not known to be open");
} else {
cursor.close();
}
}
示例3: dupCursor
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
* Duplicates a cursor for a given database.
*
* @param writeCursor true to open a write cursor in a CDB environment, and
* ignored for other environments.
*
* @param samePosition is passed through to Cursor.dup().
*
* @return the open cursor.
*
* @throws DatabaseException if a database problem occurs.
*/
Cursor dupCursor(Cursor cursor, boolean writeCursor, boolean samePosition)
throws DatabaseException {
if (cdbMode) {
WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
if (cdbCursorsMap != null) {
Database db = cursor.getDatabase();
CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
if (cdbCursors != null) {
List cursors = writeCursor ? cdbCursors.writeCursors
: cdbCursors.readCursors;
if (cursors.contains(cursor)) {
Cursor newCursor = cursor.dup(samePosition);
cursors.add(newCursor);
return newCursor;
}
}
}
throw new IllegalStateException("Cursor to dup not tracked");
} else {
return cursor.dup(samePosition);
}
}
示例4: closeCursor
import com.sleepycat.je.Cursor; //導入方法依賴的package包/類
/**
* Closes a cursor.
*
* @param cursor the cursor to close.
*
* @throws DatabaseException if a database problem occurs.
*/
void closeCursor(Cursor cursor)
throws DatabaseException {
if (cursor == null) {
return;
}
if (cdbMode) {
WeakHashMap cdbCursorsMap = (WeakHashMap) localCdbCursors.get();
if (cdbCursorsMap != null) {
Database db = cursor.getDatabase();
CdbCursors cdbCursors = (CdbCursors) cdbCursorsMap.get(db);
if (cdbCursors != null) {
if (cdbCursors.readCursors.remove(cursor) ||
cdbCursors.writeCursors.remove(cursor)) {
cursor.close();
return;
}
}
}
throw new IllegalStateException
("Closing CDB cursor that was not known to be open");
} else {
cursor.close();
}
}