public class Update extends AbstractMessage
struct OP_UPDATE {
MsgHeader header; // standard message header
int32 ZERO; // 0 - reserved for future use
cstring fullCollectionName; // "dbname.collectionname"
int32 flags; // bit vector. see below
document selector; // the query to select the document
document update; // specification of the update to perform
}
Modifier and Type | Field and Description |
---|---|
static int |
MULTIUPDATE_FLAG_BIT
Flag bit for a multi-update.
|
static int |
UPSERT_FLAG_BIT
Flag bit for an upsert.
|
HEADER_SIZE, myCollectionName, myDatabaseName
Constructor and Description |
---|
Update(BsonInputStream in)
Creates a new Update.
|
Update(String databaseName,
String collectionName,
Document query,
Document update,
boolean multiUpdate,
boolean upsert)
Creates a new Update.
|
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 |
getOperationName()
Returns a short name for the operation.
|
Document |
getQuery()
Returns the query to select the document to update.
|
Document |
getUpdate()
Returns the updates to apply to the selected document(s).
|
int |
hashCode()
Computes a reasonable hash code.
|
boolean |
isMultiUpdate()
Returns true if all documents matching the query should be updated,
otherwise only the first document should be updated.
|
boolean |
isUpsert()
Returns true if the document should be inserted if none match the query
criteria.
|
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 MULTIUPDATE_FLAG_BIT
public static final int UPSERT_FLAG_BIT
public Update(BsonInputStream in) throws IOException
in
- The input stream to read the update message from.IOException
- On an error reading the update message.public Update(String databaseName, String collectionName, Document query, Document update, boolean multiUpdate, boolean upsert)
databaseName
- The name of the database.collectionName
- The name of the collection.query
- The query to select the document to update.update
- The updates to apply to the selected document(s).multiUpdate
- If true then all documents matching the query should be
updated, otherwise only the first document should be updated.upsert
- If true then a document should be inserted if none match the
query criteria.public boolean equals(Object object)
equals
in class AbstractMessage
object
- The object to compare to.Object.equals(java.lang.Object)
public String getOperationName()
Overridden to return the name of the operation: "UPDATE".
public Document getQuery()
public Document getUpdate()
public int hashCode()
hashCode
in class AbstractMessage
public boolean isMultiUpdate()
public boolean isUpsert()
public int size()
Overridden to return the size of the Query
.
public void validateSize(int maxDocumentSize) throws DocumentToLargeException
Overridden to ensure the inserted documents are not too large in aggregate.
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 update 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 update 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.