public class ObjectId extends Object implements Comparable<ObjectId>, Serializable
| Constructor and Description |
|---|
ObjectId()
Create a new object id.
|
ObjectId(byte[] b)
Constructs an ObjectId given its 12-byte binary representation.
|
ObjectId(Date time) |
ObjectId(Date time,
int inc) |
ObjectId(Date time,
int machine,
int inc) |
ObjectId(int time,
int machine,
int inc)
Deprecated.
ObjectId's constructed this way do not conform to
the ObjectId specification.
createFromLegacyFormat(int, int, int) instead. |
ObjectId(String s)
Creates a new instance from a string.
|
ObjectId(String s,
boolean babble)
Deprecated.
'babble' format is deprecated. Please use
ObjectId(String) instead. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(ObjectId id) |
static ObjectId |
createFromLegacyFormat(int time,
int machine,
int inc)
Creates an ObjectId using time, machine and inc values.
|
boolean |
equals(Object o) |
static ObjectId |
get()
Gets a new object id.
|
static int |
getCurrentCounter() |
static int |
getCurrentInc() |
Date |
getDate()
Gets the timestamp as a
Date instance. |
static int |
getGenMachineId() |
int |
getTimestamp()
Gets the timestamp (number of seconds since the Unix epoch).
|
int |
hashCode() |
static boolean |
isValid(String s)
Checks if a string could be an
ObjectId. |
static ObjectId |
massageToObjectId(Object o)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
byte[] |
toByteArray() |
String |
toHexString()
Converts this instance into a 24-byte hexadecimal string representation.
|
String |
toString() |
String |
toStringMongod()
Deprecated.
Please use
toHexString() instead. |
static void |
validate(String msg,
String s) |
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 id@Deprecated public ObjectId(String s, boolean babble)
ObjectId(String) instead.ObjectId from a string.s - the string representation of ObjectId. Can contains only [0-9]|[a-f]|[A-F] characters.babble - if true - convert to 'babble' objectId formatpublic ObjectId(byte[] b)
b - a byte array of length 12@Deprecated public ObjectId(int time, int machine, int inc)
ObjectId's constructed this way do not conform to
the ObjectId specification.
createFromLegacyFormat(int, int, int) instead.time - time in secondsmachine - machine IDinc - incremental valuecreateFromLegacyFormat(int, int, int)public ObjectId()
public static ObjectId get()
public static ObjectId createFromLegacyFormat(int time, int machine, int inc)
NOTE: This will not break any application that use ObjectIds. The 12-byte representation will be round-trippable from old to new driver releases.
time - time in secondsmachine - machine IDinc - incremental valuepublic static boolean isValid(String s)
ObjectId.s - The object string@Deprecated public static ObjectId massageToObjectId(Object o)
ObjectId, if possible.
Strings will be converted into ObjectIds, if possible, and ObjectIds will
be cast and returned. Passing in null returns null.o - the object to convertObjectId if it can be massaged, null otherwisepublic String toHexString()
@Deprecated public String toStringMongod()
toHexString() instead.public byte[] toByteArray()
public int compareTo(ObjectId id)
compareTo in interface Comparable<ObjectId>public int getTimestamp()
public Date getDate()
Date instance.public static int getGenMachineId()
public static int getCurrentCounter()
public static int getCurrentInc()
Copyright © 2015. All rights reserved.