Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

LockOperation.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2002-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: LockOperation.java,v 12.1 2005/06/16 20:23:02 bostic Exp $
00008  */
00009 
00010 package com.sleepycat.db;
00011 
00012 import com.sleepycat.db.internal.DbConstants;
00013 
00014 public final class LockOperation {
00015     public static final LockOperation GET =
00016         new LockOperation("GET", DbConstants.DB_LOCK_GET);
00017     public static final LockOperation GET_TIMEOUT =
00018         new LockOperation("GET_TIMEOUT", DbConstants.DB_LOCK_GET_TIMEOUT);
00019     public static final LockOperation PUT =
00020         new LockOperation("PUT", DbConstants.DB_LOCK_PUT);
00021     public static final LockOperation PUT_ALL =
00022         new LockOperation("PUT_ALL", DbConstants.DB_LOCK_PUT_ALL);
00023     public static final LockOperation PUT_OBJ =
00024         new LockOperation("PUT_OBJ", DbConstants.DB_LOCK_PUT_OBJ);
00025     public static final LockOperation TIMEOUT =
00026         new LockOperation("TIMEOUT", DbConstants.DB_LOCK_TIMEOUT);
00027 
00028     /* package */
00029     static LockOperation fromFlag(int flag) {
00030         switch (flag) {
00031         case DbConstants.DB_LOCK_GET:
00032             return GET;
00033         case DbConstants.DB_LOCK_GET_TIMEOUT:
00034             return GET_TIMEOUT;
00035         case DbConstants.DB_LOCK_PUT:
00036             return PUT;
00037         case DbConstants.DB_LOCK_PUT_ALL:
00038             return PUT_ALL;
00039         case DbConstants.DB_LOCK_PUT_OBJ:
00040             return PUT_OBJ;
00041         case DbConstants.DB_LOCK_TIMEOUT:
00042             return TIMEOUT;
00043         default:
00044             throw new IllegalArgumentException(
00045                 "Unknown lock operation: " + flag);
00046         }
00047     }
00048 
00049     private final String operationName;
00050     private final int flag;
00051 
00052     private LockOperation(final String operationName, final int flag) {
00053         this.operationName = operationName;
00054         this.flag = flag;
00055     }
00056 
00057     public String toString() {
00058         return "LockOperation." + operationName;
00059     }
00060 
00061     /* package */
00062     int getFlag() {
00063         return flag;
00064     }
00065 }

Generated on Sun Dec 25 12:14:33 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2