public class Reply extends AbstractMessage
struct {
MsgHeader header; // standard message header
int32 responseFlags; // bit vector - see details below
int64 cursorID; // cursor id if client needs to do get more's
int32 startingFrom; // where in the cursor this reply is starting
int32 numberReturned; // number of documents in the reply
document* documents; // documents
}
Modifier and Type | Field and Description |
---|---|
static int |
AWAIT_CAPABLE_BIT
Bit for the await capable flag.
|
static int |
CURSOR_NOT_FOUND_BIT
Bit for the cursor not found flag.
|
static int |
QUERY_FAILURE_BIT
Bit for the query failure flag.
|
static int |
SHARD_CONFIG_STALE_BIT
Bit for the shard configuration stale flag.
|
HEADER_SIZE, myCollectionName, myDatabaseName
Constructor and Description |
---|
Reply(Header header,
BsonInputStream in)
Creates a new Reply.
|
Reply(int responseToId,
long cursorId,
int cursorOffset,
List<Document> results,
boolean awaitCapable,
boolean cursorNotFound,
boolean queryFailed,
boolean shardConfigStale)
Creates a new Reply.
|
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.
|
long |
getCursorId()
Returns the id of the cursor if the user needs to do a get_more to get
the complete results.
|
int |
getCursorOffset()
Returns the offset (index) of the first document returned from the
cursor.
|
String |
getOperationName()
Returns a short name for the operation.
|
int |
getResponseToId()
Returns the id of the request this response is for.
|
List<Document> |
getResults()
Returns the query results.
|
int |
hashCode()
Computes a reasonable hash code.
|
boolean |
isAwaitCapable()
Returns true if the server is await capable for tailable cursors.
|
boolean |
isCursorNotFound()
Returns true if the cursor in the get_more message was not
found.
|
boolean |
isQueryFailed()
Returns true if the query failed.
|
boolean |
isShardConfigStale()
Returns true if the shard configuration is stale.
|
int |
size()
Returns the total size of the message on the wire.
|
void |
validateSize(int maxDocumentSize)
Validates that the documents with the message do not exceed the maximum
document size specified.
|
void |
write(int messageId,
BsonOutputStream out)
Writes the message from the stream.
|
void |
write(int messageId,
BufferingBsonOutputStream out)
Writes the message from the stream.
|
finishHeader, getCollectionName, getDatabaseName, getReadPreference, getRequiredVersionRange, init, writeHeader, writeHeader
public static final int AWAIT_CAPABLE_BIT
public static final int CURSOR_NOT_FOUND_BIT
public static final int QUERY_FAILURE_BIT
public static final int SHARD_CONFIG_STALE_BIT
public Reply(Header header, BsonInputStream in) throws IOException
header
- The header from the reply message.in
- Stream to read the reply message from.IOException
- On a failure to read the reply.public Reply(int responseToId, long cursorId, int cursorOffset, List<Document> results, boolean awaitCapable, boolean cursorNotFound, boolean queryFailed, boolean shardConfigStale)
responseToId
- The id of the request this response is for.cursorId
- The id of the cursor if the user needs to do a get_more to get
the complete results.cursorOffset
- The offset (index) of the first document returned from the
cursor.results
- The returned documents.awaitCapable
- If true, indicates the server is await capable for tailable
cursors.cursorNotFound
- If true, indicates that the cursor in the get_more
message was not found.queryFailed
- If true, indicates that the query failed.shardConfigStale
- If true, indicates (to a MongoS?) that its shard configuration
is stale.public boolean equals(Object object)
equals
in class AbstractMessage
object
- The object to compare to.Object.equals(java.lang.Object)
public long getCursorId()
public int getCursorOffset()
public String getOperationName()
Overridden to return the name of the operation: "REPLY".
public int getResponseToId()
public int hashCode()
hashCode
in class AbstractMessage
public boolean isAwaitCapable()
public boolean isCursorNotFound()
public boolean isQueryFailed()
public boolean isShardConfigStale()
public int size()
Overridden to return the size of the Query
.
public void validateSize(int maxDocumentSize) throws DocumentToLargeException
Overrridden to be a no-op since we normally only receive a reply and don't care about the size.
maxDocumentSize
- The maximum document size to validate against.DocumentToLargeException
- If one of the documents in the message is too large or the
documents in aggregate are too large.public void write(int messageId, BsonOutputStream out) throws IOException
Overridden to write the reply message.
messageId
- The id to be assigned to the message.out
- The sink for data written.IOException
- On an error writing to the stream.Message.write(int, BsonOutputStream)
public void write(int messageId, BufferingBsonOutputStream out) throws IOException
Overridden to write the reply message.
messageId
- The id to be assigned to the message.out
- The sink for data written.IOException
- On an error writing to the stream.Message.write(int, BsonOutputStream)
Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.