package org.couchbase.mock.memcached.protocol;
import java.net.ProtocolException;
import java.nio.ByteBuffer;
public static BinaryCommand (ByteBuffer header) throws ProtocolException {
header.rewind();
if (header.get() != (byte)0x80) {
throw new ProtocolException("Illegal magic");
}
CommandCode cc = CommandCode.valueOf(header.get());
header.rewind();
switch (cc) {
case ADD:
case ADDQ:
case APPEND:
case APPENDQ:
case PREPEND:
case PREPENDQ:
case SET:
case SETQ:
case REPLACE:
case REPLACEQ:
return new BinaryStoreCommand(header);
case INCREMENT:
case INCREMENTQ:
case DECREMENT:
case DECREMENTQ:
return new BinaryArithmeticCommand(header);
case GET:
case GETQ:
case GETK:
case GETKQ:
case GAT:
case GATQ:
case TOUCH:
return new BinaryGetCommand(header);
default:
return new BinaryCommand(header);
}
}
}
}