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

DatabaseType.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: DatabaseType.java,v 12.1 2005/06/16 20:23:00 bostic Exp $
00008  */
00009 
00010 package com.sleepycat.db;
00011 
00012 import com.sleepycat.db.internal.DbConstants;
00013 
00014 public final class DatabaseType {
00015     public static final DatabaseType BTREE =
00016         new DatabaseType("BTREE", DbConstants.DB_BTREE);
00017 
00018     public static final DatabaseType HASH =
00019         new DatabaseType("HASH", DbConstants.DB_HASH);
00020 
00021     public static final DatabaseType QUEUE =
00022         new DatabaseType("QUEUE", DbConstants.DB_QUEUE);
00023 
00024     public static final DatabaseType RECNO =
00025         new DatabaseType("RECNO", DbConstants.DB_RECNO);
00026 
00027     public static final DatabaseType UNKNOWN =
00028         new DatabaseType("UNKNOWN", DbConstants.DB_UNKNOWN);
00029 
00030     /* package */
00031     static DatabaseType fromInt(int type) {
00032         switch(type) {
00033         case DbConstants.DB_BTREE:
00034             return BTREE;
00035         case DbConstants.DB_HASH:
00036             return HASH;
00037         case DbConstants.DB_QUEUE:
00038             return QUEUE;
00039         case DbConstants.DB_RECNO:
00040             return DatabaseType.RECNO;
00041         case DbConstants.DB_UNKNOWN:
00042             return DatabaseType.UNKNOWN;
00043         default:
00044             throw new IllegalArgumentException(
00045                 "Unknown database type: " + type);
00046         }
00047     }
00048 
00049     private String statusName;
00050     private int id;
00051 
00052     private DatabaseType(final String statusName, final int id) {
00053         this.statusName = statusName;
00054         this.id = id;
00055     }
00056 
00057     /* package */
00058     int getId() {
00059         return id;
00060     }
00061 
00062     public String toString() {
00063         return "DatabaseType." + statusName;
00064     }
00065 }

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