diff src/com/tmate/hgkit/ll/Nodeid.java @ 9:d6d2a630f4a6

Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 25 Dec 2010 04:45:59 +0100
parents dbd663faec1f
children df8c67f3006a
line wrap: on
line diff
--- a/src/com/tmate/hgkit/ll/Nodeid.java	Thu Dec 23 01:31:40 2010 +0100
+++ b/src/com/tmate/hgkit/ll/Nodeid.java	Sat Dec 25 04:45:59 2010 +0100
@@ -3,8 +3,6 @@
  */
 package com.tmate.hgkit.ll;
 
-import java.math.BigInteger;
-import java.util.Formatter;
 
 /**
  * @see mercurial/node.py
@@ -24,15 +22,13 @@
 
 	@Override
 	public String toString() {
-		// FIXME temp impl.
-		// BEWARE, if binaryData[0] > 0x80, BigInteger treats it as negative  
-		return new BigInteger(binaryData).toString();
+		return new DigestHelper().toHexString(binaryData, 0, 20);
 	}
 
 	// binascii.unhexlify()
 	public static Nodeid fromAscii(byte[] asciiRepresentation, int offset, int length) {
 		assert length % 2 == 0; // Python's binascii.hexlify convert each byte into 2 digits
-		byte[] data = new byte[length / 2]; // XXX use known size instead? nodeid is always 20 bytes
+		byte[] data = new byte[length >>> 1]; // XXX use known size instead? nodeid is always 20 bytes
 		for (int i = 0, j = offset; i < data.length; i++) {
 			int hiNibble = Character.digit(asciiRepresentation[j++], 16);
 			int lowNibble = Character.digit(asciiRepresentation[j++], 16);