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.
|
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.
|
void |
validateSize(SizeOfVisitor visitor,
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.
|
getCollectionName, getDatabaseName, getReadPreference, init, 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 Document getQuery()
public Document getUpdate()
public int hashCode()
hashCode
in class AbstractMessage
public boolean isMultiUpdate()
public boolean isUpsert()
public void validateSize(SizeOfVisitor visitor, int maxDocumentSize) throws DocumentToLargeException
Overridden to ensure the inserted documents are not too large in aggregate.
visitor
- The SizeOfVisitor
to compute the size of the document.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)
Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.