From: Shawn O. Pearce Date: Fri, 30 Jul 2010 15:51:11 +0000 (-0700) Subject: Add copyTo(ByteBuffer) to AnyObjectId X-Git-Tag: v0.9.1~102 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F15%2F1215%2F3;p=jgit.git Add copyTo(ByteBuffer) to AnyObjectId Change-Id: I3572f6113db883002f9c3a5ecc1bcc8370105c98 Signed-off-by: Shawn O. Pearce --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java index e2060a0afa..c6cb433aa4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java @@ -339,6 +339,16 @@ public abstract class AnyObjectId implements Comparable { 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);