public abstract class AbstractMessage extends Object implements Message
Modifier and Type | Field and Description |
---|---|
static int |
HEADER_SIZE
The size of a message header.
|
protected String |
myCollectionName
The name of the collection to operate on.
|
protected String |
myDatabaseName
The name of the database to operate on.
|
Constructor and Description |
---|
AbstractMessage()
Create a new AbstractMessage.
|
AbstractMessage(String databaseName,
String collectionName,
ReadPreference readPreference)
Create a new AbstractMessage.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object object)
Determines if the passed object is of this same type as this object and
if so that its fields are equal.
|
String |
getCollectionName()
Returns the name of the collection.
|
String |
getDatabaseName()
Returns the name of the database.
|
ReadPreference |
getReadPreference()
Provides the details on which servers are eligible to receive the
message.
|
int |
hashCode()
Computes a reasonable hash code.
|
protected void |
init(String name)
Initializes the database and collection name from the full database name.
|
protected void |
writeHeader(BsonOutputStream stream,
int requestId,
int responseTo,
Operation op,
int length)
Writes the MsgHeader to the stream.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
validateSize, write
public static final int HEADER_SIZE
protected String myCollectionName
protected String myDatabaseName
public AbstractMessage()
public AbstractMessage(String databaseName, String collectionName, ReadPreference readPreference)
databaseName
- The name of the database.collectionName
- The name of the collection.readPreference
- The preferences for which servers to send the message.public boolean equals(Object object)
equals
in class Object
object
- The object to compare to.Object.equals(java.lang.Object)
public String getCollectionName()
public String getDatabaseName()
getDatabaseName
in interface Message
public ReadPreference getReadPreference()
Returns the message's read preference.
getReadPreference
in interface Message
ReadPreference
for which servers should be sent the
request.public int hashCode()
protected void init(String name)
name
- The full database name.protected void writeHeader(BsonOutputStream stream, int requestId, int responseTo, Operation op, int length)
struct MsgHeader {
int32 messageLength; // total message size, including this
int32 requestID; // identifier for this message
int32 responseTo; // requestID from the original request
// (used in reponses from db)
int32 opCode; // request type - see table below
}
stream
- The stream to write to.requestId
- The requestID from above.responseTo
- The responseTo from above.op
- The operation for the opCode field.length
- The length of the message including the header.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.