public class

ObjectId

extends Object
implements Serializable Comparable<T>
java.lang.Object
   ↳ org.bson.types.ObjectId

Class Overview

A globally unique identifier for objects.

Consists of 12 bytes, divided as follows:

 
0123456 7891011
timemachine pidinc

Summary

Public Constructors
ObjectId(Date time)
ObjectId(Date time, int inc)
ObjectId(Date time, int machine, int inc)
ObjectId(String s)
Creates a new instance from a string.
ObjectId(String s, boolean babble)
ObjectId(byte[] b)
ObjectId(int time, int machine, int inc)
Creates an ObjectId
ObjectId()
Create a new object id.
Public Methods
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()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Comparable

Public Constructors

public ObjectId (Date time)

public ObjectId (Date time, int inc)

public ObjectId (Date time, int machine, int inc)

public ObjectId (String s)

Creates a new instance from a string.

Parameters
s the string to convert
Throws
IllegalArgumentException if the string is not a valid id

public ObjectId (String s, boolean babble)

public ObjectId (byte[] b)

public ObjectId (int time, int machine, int inc)

Creates an ObjectId

Parameters
time time in seconds
machine machine ID
inc incremental value

public ObjectId ()

Create a new object id.

Public Methods

public static int _flip (int x)

public int _inc ()

public int _machine ()

public int _time ()

public static String babbleToMongod (String b)

public int compareTo (ObjectId id)

public boolean equals (Object o)

public static ObjectId get ()

Gets a new object id.

Returns
  • the new id

public static int getCurrentInc ()

Gets the current value of the auto increment

public static int getGenMachineId ()

Gets the generated machine ID, identifying the machine / process / class loader

public int getInc ()

public int getMachine ()

public long getTime ()

Gets the time of this ID, in milliseconds

public int getTimeSecond ()

Gets the time of this ID, in seconds

public int hashCode ()

public boolean isNew ()

public static boolean isValid (String s)

Checks if a string could be an ObjectId.

Returns
  • whether the string could be an object id

public static ObjectId massageToObjectId (Object o)

Turn an object into an ObjectId, if possible. Strings will be converted into ObjectIds, if possible, and ObjectIds will be cast and returned. Passing in null returns null.

Parameters
o the object to convert
Returns
  • an ObjectId if it can be massaged, null otherwise

public void notNew ()

public byte[] toByteArray ()

public String toString ()

public String toStringBabble ()

public String toStringMongod ()