1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2002,2008 Oracle. All rights reserved. 5 * 6 * $Id: DatabaseType.java,v 12.7 2008/01/17 05:04:53 mjc Exp $ 7 */ 8 9package com.sleepycat.db; 10 11import com.sleepycat.db.internal.DbConstants; 12 13/** Database types. */ 14public final class DatabaseType { 15 /** 16 The database is a Btree. The Btree format is a representation of a 17 sorted, balanced tree structure. 18 */ 19 public static final DatabaseType BTREE = 20 new DatabaseType("BTREE", DbConstants.DB_BTREE); 21 22 /** 23 The database is a Hash. The Hash format is an extensible, dynamic 24 hashing scheme. 25 */ 26 public static final DatabaseType HASH = 27 new DatabaseType("HASH", DbConstants.DB_HASH); 28 29 /** 30 The database is a Queue. The Queue format supports fast access to 31 fixed-length records accessed sequentially or by logical record 32 number. 33 */ 34 public static final DatabaseType QUEUE = 35 new DatabaseType("QUEUE", DbConstants.DB_QUEUE); 36 37 /** 38 The database is a Recno. The Recno format supports fixed- or 39 variable-length records, accessed sequentially or by logical 40 record number, and optionally backed by a flat text file. 41 */ 42 public static final DatabaseType RECNO = 43 new DatabaseType("RECNO", DbConstants.DB_RECNO); 44 45 /** 46 The database type is unknown. 47 */ 48 public static final DatabaseType UNKNOWN = 49 new DatabaseType("UNKNOWN", DbConstants.DB_UNKNOWN); 50 51 /* package */ 52 static DatabaseType fromInt(int type) { 53 switch(type) { 54 case DbConstants.DB_BTREE: 55 return BTREE; 56 case DbConstants.DB_HASH: 57 return HASH; 58 case DbConstants.DB_QUEUE: 59 return QUEUE; 60 case DbConstants.DB_RECNO: 61 return DatabaseType.RECNO; 62 case DbConstants.DB_UNKNOWN: 63 return DatabaseType.UNKNOWN; 64 default: 65 throw new IllegalArgumentException( 66 "Unknown database type: " + type); 67 } 68 } 69 70 private String statusName; 71 private int id; 72 73 private DatabaseType(final String statusName, final int id) { 74 this.statusName = statusName; 75 this.id = id; 76 } 77 78 /* package */ 79 int getId() { 80 return id; 81 } 82 83 /** {@inheritDoc} */ 84 public String toString() { 85 return "DatabaseType." + statusName; 86 } 87} 88