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

OperationStatus.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: OperationStatus.java,v 12.1 2005/06/16 20:23:03 bostic Exp $
00008  */
00009 
00010 package com.sleepycat.db;
00011 
00012 import com.sleepycat.db.internal.DbConstants;
00013 import com.sleepycat.db.internal.DbEnv;
00014 
00015 public final class OperationStatus {
00016     public static final OperationStatus SUCCESS =
00017         new OperationStatus("SUCCESS", 0);
00018     public static final OperationStatus KEYEXIST =
00019         new OperationStatus("KEYEXIST", DbConstants.DB_KEYEXIST);
00020     public static final OperationStatus KEYEMPTY =
00021         new OperationStatus("KEYEMPTY", DbConstants.DB_KEYEMPTY);
00022     public static final OperationStatus NOTFOUND =
00023         new OperationStatus("NOTFOUND", DbConstants.DB_NOTFOUND);
00024 
00025     /* package */
00026     static OperationStatus fromInt(final int errCode) {
00027         switch(errCode) {
00028         case 0:
00029             return SUCCESS;
00030         case DbConstants.DB_KEYEXIST:
00031             return KEYEXIST;
00032         case DbConstants.DB_KEYEMPTY:
00033             return KEYEMPTY;
00034         case DbConstants.DB_NOTFOUND:
00035             return NOTFOUND;
00036         default:
00037             throw new IllegalArgumentException(
00038                 "Unknown error code: " + DbEnv.strerror(errCode));
00039         }
00040     }
00041 
00042     /* For toString */
00043     private String statusName;
00044     private int errCode;
00045 
00046     private OperationStatus(final String statusName, int errCode) {
00047         this.statusName = statusName;
00048         this.errCode = errCode;
00049     }
00050 
00051     public String toString() {
00052         return "OperationStatus." + statusName;
00053     }
00054 }

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