public class ObjectId extends java.lang.Object implements java.lang.Comparable<ObjectId>, java.io.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(java.util.Date time) |
ObjectId(java.util.Date time,
int inc) |
ObjectId(java.util.Date time,
int machine,
int inc) |
ObjectId(int time,
int machine,
int inc)
Creates an ObjectId
|
ObjectId(java.lang.String s)
Creates a new instance from a string.
|
ObjectId(java.lang.String s,
boolean babble) |
Modifier and Type | Method and Description |
---|---|
static int |
_flip(int x) |
int |
_inc() |
int |
_machine() |
int |
_time() |
static java.lang.String |
babbleToMongod(java.lang.String b) |
int |
compareTo(ObjectId id) |
boolean |
equals(java.lang.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(java.lang.String s)
Checks if a string could be an
ObjectId . |
static ObjectId |
massageToObjectId(java.lang.Object o)
Turn an object into an
ObjectId , if possible. |
void |
notNew() |
byte[] |
toByteArray() |
java.lang.String |
toString() |
java.lang.String |
toStringBabble() |
java.lang.String |
toStringMongod() |
public ObjectId(java.util.Date time)
public ObjectId(java.util.Date time, int inc)
public ObjectId(java.util.Date time, int machine, int inc)
public ObjectId(java.lang.String s)
s
- the string to convertjava.lang.IllegalArgumentException
- if the string is not a valid idpublic ObjectId(java.lang.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(java.lang.String s)
ObjectId
.public static ObjectId massageToObjectId(java.lang.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 int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toStringBabble()
public java.lang.String toStringMongod()
public byte[] toByteArray()
public static java.lang.String babbleToMongod(java.lang.String b)
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(ObjectId id)
compareTo
in interface java.lang.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)