Add copyTo(ByteBuffer) to AnyObjectId

Change-Id: I3572f6113db883002f9c3a5ecc1bcc8370105c98
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2010-07-30 08:51:11 -07:00
parent 8878d301ac
commit d1ebc4aa00
1 changed files with 10 additions and 0 deletions

View File

@ -339,6 +339,16 @@ public void copyTo(byte[] b, int o) {
formatHexByte(b, o + 32, w5);
}
/**
* Copy this ObjectId to a ByteBuffer in hex format.
*
* @param b
* the buffer to copy to.
*/
public void copyTo(ByteBuffer b) {
b.put(toHexByteArray());
}
private byte[] toHexByteArray() {
final byte[] dst = new byte[Constants.OBJECT_ID_STRING_LENGTH];
formatHexByte(dst, 0, w1);