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

LockDetectMode.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: LockDetectMode.java,v 12.1 2005/06/16 20:23:01 bostic Exp $
00008  */
00009 
00010 package com.sleepycat.db;
00011 
00012 import com.sleepycat.db.internal.DbConstants;
00013 
00014 public final class LockDetectMode {
00015     public static final LockDetectMode NONE =
00016         new LockDetectMode("NONE", 0);
00017 
00018     public static final LockDetectMode DEFAULT =
00019         new LockDetectMode("DEFAULT", DbConstants.DB_LOCK_DEFAULT);
00020 
00021     public static final LockDetectMode EXPIRE =
00022         new LockDetectMode("EXPIRE", DbConstants.DB_LOCK_EXPIRE);
00023 
00024     public static final LockDetectMode MAXLOCKS =
00025         new LockDetectMode("MAXLOCKS", DbConstants.DB_LOCK_MAXLOCKS);
00026 
00027     public static final LockDetectMode MAXWRITE =
00028         new LockDetectMode("MAXWRITE", DbConstants.DB_LOCK_MAXWRITE);
00029 
00030     public static final LockDetectMode MINLOCKS =
00031         new LockDetectMode("MINLOCKS", DbConstants.DB_LOCK_MINLOCKS);
00032 
00033     public static final LockDetectMode MINWRITE =
00034         new LockDetectMode("MINWRITE", DbConstants.DB_LOCK_MINWRITE);
00035 
00036     public static final LockDetectMode OLDEST =
00037         new LockDetectMode("OLDEST", DbConstants.DB_LOCK_OLDEST);
00038 
00039     public static final LockDetectMode RANDOM =
00040         new LockDetectMode("RANDOM", DbConstants.DB_LOCK_RANDOM);
00041 
00042     public static final LockDetectMode YOUNGEST =
00043         new LockDetectMode("YOUNGEST", DbConstants.DB_LOCK_YOUNGEST);
00044 
00045     /* package */
00046     static LockDetectMode fromFlag(int flag) {
00047         switch (flag) {
00048         case 0:
00049             return NONE;
00050         case DbConstants.DB_LOCK_DEFAULT:
00051             return DEFAULT;
00052         case DbConstants.DB_LOCK_EXPIRE:
00053             return EXPIRE;
00054         case DbConstants.DB_LOCK_MAXLOCKS:
00055             return MAXLOCKS;
00056         case DbConstants.DB_LOCK_MAXWRITE:
00057             return MAXWRITE;
00058         case DbConstants.DB_LOCK_MINLOCKS:
00059             return MINLOCKS;
00060         case DbConstants.DB_LOCK_MINWRITE:
00061             return MINWRITE;
00062         case DbConstants.DB_LOCK_OLDEST:
00063             return OLDEST;
00064         case DbConstants.DB_LOCK_RANDOM:
00065             return RANDOM;
00066         case DbConstants.DB_LOCK_YOUNGEST:
00067             return YOUNGEST;
00068         default:
00069             throw new IllegalArgumentException(
00070                 "Unknown lock detect mode: " + flag);
00071         }
00072     }
00073 
00074     private String modeName;
00075     private int flag;
00076 
00077     private LockDetectMode(final String modeName, final int flag) {
00078         this.modeName = modeName;
00079         this.flag = flag;
00080     }
00081 
00082     /* package */
00083     int getFlag() {
00084         return flag;
00085     }
00086 
00087     public String toString() {
00088         return "LockDetectMode." + modeName;
00089     }
00090 }

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