org.bson.types
public class ObjectId extends Object implements Comparable<ObjectId>, Serializable
Consists of 12 bytes, divided as follows:
0 1 2 3 4 5 6 7 8 9 10 11 time machine pid inc
Constructor and Description |
---|
ObjectId()
Create a new object id.
|
ObjectId(byte[] b) |
ObjectId(Date time) |
ObjectId(Date time,
int inc) |
ObjectId(Date time,
int machine,
int inc) |
ObjectId(int time,
int machine,
int inc)
Creates an ObjectId
|
ObjectId(String s)
Creates a new instance from a string.
|
ObjectId(String s,
boolean babble) |
Modifier and Type | Method and Description |
---|---|
static int |
_flip(int x) |
int |
_inc() |
int |
_machine() |
int |
_time() |
static String |
babbleToMongod(String b) |
int |
compareTo(ObjectId id) |
boolean |
equals(Object o) |
static ObjectId |
get()
Gets a new object id.
|
static int |
getCurrentInc()
Gets the current value of the auto increment
|
static int |
getGenMachineId()
Gets the generated machine ID, identifying the machine / process / class loader
|
int |
getInc() |
int |
getMachine() |
long |
getTime()
Gets the time of this ID, in milliseconds
|
int |
getTimeSecond()
Gets the time of this ID, in seconds
|
int |
hashCode() |
boolean |
isNew() |
static boolean |
isValid(String s)
Checks if a string could be an
ObjectId . |
static ObjectId |
massageToObjectId(Object o)
Turn an object into an
ObjectId , if possible. |
void |
notNew() |
byte[] |
toByteArray() |
String |
toString() |
String |
toStringBabble() |
String |
toStringMongod() |
public ObjectId(Date time)
public ObjectId(Date time, int inc)
public ObjectId(Date time, int machine, int inc)
public ObjectId(String s)
s
- the string to convertIllegalArgumentException
- if the string is not a valid idpublic ObjectId(String s, boolean babble)
public ObjectId(byte[] b)
public ObjectId(int time, int machine, int inc)
time
- time in secondsmachine
- machine IDinc
- incremental valuepublic ObjectId()
public static ObjectId get()
public static boolean isValid(String s)
ObjectId
.public static ObjectId massageToObjectId(Object o)
ObjectId
, if possible.
Strings will be converted into ObjectId
s, if possible, and ObjectId
s will
be cast and returned. Passing in null
returns null
.o
- the object to convertObjectId
if it can be massaged, null otherwisepublic String toStringBabble()
public String toStringMongod()
public byte[] toByteArray()
public int compareTo(ObjectId id)
compareTo
in interface Comparable<ObjectId>
public int getMachine()
public long getTime()
public int getTimeSecond()
public int getInc()
public int _time()
public int _machine()
public int _inc()
public boolean isNew()
public void notNew()
public static int getGenMachineId()
public static int getCurrentInc()
public static int _flip(int x)