summaryrefslogtreecommitdiff
path: root/lang/csharp/src/DatabaseType.cs
blob: bcee9344a0e02497d2e7b65ee74ef457f59a4389 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2009, 2015 Oracle and/or its affiliates.  All rights reserved.
 *
 */
using System;
using System.Collections.Generic;
using System.Text;
using BerkeleyDB.Internal;

namespace BerkeleyDB {
    /// <summary>
    /// A class representing the supported Berkeley DB access methods.
    /// </summary>
    public class DatabaseType {
        /// <summary>
        /// BTree access method
        /// </summary>
        public static readonly DatabaseType BTREE
            = new DatabaseType(DBTYPE.DB_BTREE);
        /// <summary>
        /// Hash access method
        /// </summary>
        public static readonly DatabaseType HASH
            = new DatabaseType(DBTYPE.DB_HASH);
        /// <summary>
        /// Heap access method
        /// </summary>
        public static readonly DatabaseType HEAP
            = new DatabaseType(DBTYPE.DB_HEAP);
        /// <summary>
        /// Recno access method
        /// </summary>
        public static readonly DatabaseType RECNO
            = new DatabaseType(DBTYPE.DB_RECNO);
        /// <summary>
        /// Queue access method
        /// </summary>
        public static readonly DatabaseType QUEUE
            = new DatabaseType(DBTYPE.DB_QUEUE);
        /// <summary>
        /// Unknown access method
        /// </summary>
        public static readonly DatabaseType UNKNOWN
            = new DatabaseType(DBTYPE.DB_UNKNOWN);

        private BerkeleyDB.Internal.DBTYPE dbtype;

        private DatabaseType(BerkeleyDB.Internal.DBTYPE type) {
            dbtype = type;
        }

        internal BerkeleyDB.Internal.DBTYPE getDBTYPE() {
            return dbtype;
        }

        /// <summary>
        /// Convert this instance of DatabaseType to its string representation.
        /// </summary>
        /// <returns>A string representation of this instance.</returns>
        public override string ToString() {
            switch (dbtype) {
                case DBTYPE.DB_BTREE:
                    return "BTree";
                case DBTYPE.DB_HASH:
                    return "Hash";
                case DBTYPE.DB_HEAP:
                    return "Heap";
                case DBTYPE.DB_QUEUE:
                    return "Queue";
                case DBTYPE.DB_RECNO:
                    return "Recno";
                default:
                    return "Unknown";
            }
        }

    }
}