forked from mongodb/mongo-java-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBSONType.java
More file actions
130 lines (121 loc) · 2.63 KB
/
Copy pathBSONType.java
File metadata and controls
130 lines (121 loc) · 2.63 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* Copyright (c) 2008-2014 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mongodb;
enum BSONType {
/**
* Not a real BSON type. Used to signal the end of a document.
*/
END_OF_DOCUMENT(0x00), // no values of this type exist it marks the end of a document
/**
* A BSON double.
*/
DOUBLE(0x01),
/**
* A BSON string.
*/
STRING(0x02),
/**
* A BSON document.
*/
DOCUMENT(0x03),
/**
* A BSON array.
*/
ARRAY(0x04),
/**
* BSON binary data.
*/
BINARY(0x05),
/**
* A BSON undefined value.
*/
UNDEFINED(0x06),
/**
* A BSON ObjectId.
*/
OBJECT_ID(0x07),
/**
* A BSON bool.
*/
BOOLEAN(0x08),
/**
* A BSON DateTime.
*/
DATE_TIME(0x09),
/**
* A BSON null value.
*/
NULL(0x0a),
/**
* A BSON regular expression.
*/
REGULAR_EXPRESSION(0x0b),
/**
* A BSON regular expression.
*/
DB_POINTER(0x0c),
/**
* BSON JavaScript code.
*/
JAVASCRIPT(0x0d),
/**
* A BSON symbol.
*/
SYMBOL(0x0e),
/**
* BSON JavaScript code with a scope (a set of variables with values).
*/
JAVASCRIPT_WITH_SCOPE(0x0f),
/**
* A BSON 32-bit integer.
*/
INT32(0x10),
/**
* A BSON timestamp.
*/
TIMESTAMP(0x11),
/**
* A BSON 64-bit integer.
*/
INT64(0x12),
/**
* A BSON MinKey value.
*/
MIN_KEY(0xff),
/**
* A BSON MaxKey value.
*/
MAX_KEY(0x7f);
private static final BSONType[] LOOKUP_TABLE = new BSONType[MIN_KEY.getValue() + 1];
private final int value;
static {
for (final BSONType cur : BSONType.values()) {
LOOKUP_TABLE[cur.getValue()] = cur;
}
}
BSONType(final int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static BSONType findByValue(final int value) {
return LOOKUP_TABLE[value & 0xFF];
}
public boolean isContainer() {
return this == DOCUMENT || this == ARRAY;
}
}