// Path: src/main/java/jmockmongo/wire/MessageDecoder.java
// static final String readCString(ChannelBuffer buffer) {
// 	// find the terminating zero-byte
// 	int length = buffer.bytesBefore((byte) 0);
// 	byte[] bytes = new byte[length];
// 	buffer.readBytes(bytes);
// 	// also skip the terminator
// 	buffer.readByte();
// 	try {
// 		return new String(bytes, "UTF-8");
// 	} catch (java.io.UnsupportedEncodingException uee) {
// 		throw new BSONException("impossible", uee);
// 	}
// }
// 
// Path: src/main/java/jmockmongo/wire/MessageDecoder.java
// static final BSONObject readDocument(ChannelBuffer buffer, byte[] fourBytes) {
// 	int length = readInt32(buffer, fourBytes);
// 	byte[] bson = new byte[length];
// 	buffer.readBytes(bson, 4, length - 4);
// 	System.arraycopy(fourBytes, 0, bson, 0, 4);
// 	return BSON.decode(bson);
// 
// }
// 
// Path: src/main/java/jmockmongo/wire/MessageDecoder.java
// static final int readInt32(ChannelBuffer buffer, byte[] fourBytes) {
// 	buffer.readBytes(fourBytes);
// 	return Bits.readInt(fourBytes);
// }


import static jmockmongo.wire.MessageDecoder.readCString;
import static jmockmongo.wire.MessageDecoder.readDocument;
import static jmockmongo.wire.MessageDecoder.readInt32;
import org.bson.BSONObject;
import org.jboss.netty.buffer.ChannelBuffer;
/**
 * Copyright (c) 2012, Thilo Planz. All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the Apache License, Version 2.0
 * as published by the Apache Software Foundation (the "License").
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 * You should have received a copy of the License along with this program.
 * If not, see <http://www.apache.org/licenses/LICENSE-2.0>.
 */

package jmockmongo.wire;



public class UpdateMessage extends Message {

	static final int OP_CODE_UPDATE = 2001;

	// 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
	// }

	private final String fullCollectionName;

	String getFullCollectionName() {
		return fullCollectionName;
	}

	private final int flags;

	private BSONObject selector;

	private BSONObject update;

	UpdateMessage(ChannelBuffer data) {
// Path: src/main/java/jmockmongo/wire/MessageDecoder.java
// static final String readCString(ChannelBuffer buffer) {
// 	// find the terminating zero-byte
// 	int length = buffer.bytesBefore((byte) 0);
// 	byte[] bytes = new byte[length];
// 	buffer.readBytes(bytes);
// 	// also skip the terminator
// 	buffer.readByte();
// 	try {
// 		return new String(bytes, "UTF-8");
// 	} catch (java.io.UnsupportedEncodingException uee) {
// 		throw new BSONException("impossible", uee);
// 	}
// }
// 
// Path: src/main/java/jmockmongo/wire/MessageDecoder.java
// static final BSONObject readDocument(ChannelBuffer buffer, byte[] fourBytes) {
// 	int length = readInt32(buffer, fourBytes);
// 	byte[] bson = new byte[length];
// 	buffer.readBytes(bson, 4, length - 4);
// 	System.arraycopy(fourBytes, 0, bson, 0, 4);
// 	return BSON.decode(bson);
// 
// }
// 
// Path: src/main/java/jmockmongo/wire/MessageDecoder.java
// static final int readInt32(ChannelBuffer buffer, byte[] fourBytes) {
// 	buffer.readBytes(fourBytes);
// 	return Bits.readInt(fourBytes);
// }


// Path: src/main/java/jmockmongo/wire/UpdateMessage.java
import static jmockmongo.wire.MessageDecoder.readCString;
import static jmockmongo.wire.MessageDecoder.readDocument;
import static jmockmongo.wire.MessageDecoder.readInt32;
import org.bson.BSONObject;
import org.jboss.netty.buffer.ChannelBuffer;

/**
 * Copyright (c) 2012, Thilo Planz. All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the Apache License, Version 2.0
 * as published by the Apache Software Foundation (the "License").
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 * You should have received a copy of the License along with this program.
 * If not, see <http://www.apache.org/licenses/LICENSE-2.0>.
 */

package jmockmongo.wire;



public class UpdateMessage extends Message {

	static final int OP_CODE_UPDATE = 2001;

	// 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
	// }

	private final String fullCollectionName;

	String getFullCollectionName() {
		return fullCollectionName;
	}

	private final int flags;

	private BSONObject selector;

	private BSONObject update;

	UpdateMessage(ChannelBuffer data) {
		super(data, OP_CODE_UPDATE);