jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1129523 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/SimpleRevisionStore.java
Date Tue, 31 May 2011 07:42:32 GMT
Author: thomasm
Date: Tue May 31 07:42:32 2011
New Revision: 1129523

URL: http://svn.apache.org/viewvc?rev=1129523&view=rev
Log:
String utilities for byte array to hex conversion.

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/SimpleRevisionStore.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/SimpleRevisionStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/SimpleRevisionStore.java?rev=1129523&r1=1129522&r2=1129523&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/SimpleRevisionStore.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/SimpleRevisionStore.java
Tue May 31 07:42:32 2011
@@ -22,17 +22,15 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.nio.channels.Channels;
 import java.security.DigestOutputStream;
 import java.security.MessageDigest;
+import org.apache.jackrabbit.mk.util.StringUtils;
 
 /**
  *
  */
 public class SimpleRevisionStore implements RevisionStore {
 
-    private static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
-
     boolean initialized;
     File dataDir;
     PersistentId headRev;
@@ -119,7 +117,7 @@ public class SimpleRevisionStore impleme
                 in.close();
             }
 
-            String id = toHex(digest.digest());
+            String id = StringUtils.convertBytesToHex(digest.digest());
             File dst = getFile(id);
             if (dst.exists()) {
                 // already exists
@@ -156,7 +154,7 @@ public class SimpleRevisionStore impleme
         } finally {
             in.close();
         }
-        return toHex(digest.digest());
+        return StringUtils.convertBytesToHex(digest.digest());
     }
 
     private File getFile(String id) {
@@ -166,12 +164,4 @@ public class SimpleRevisionStore impleme
         return new File(dataDir, buf.toString());
     }
 
-    static String toHex(byte[] bytes) {
-        char[] chars = new char[2 * bytes.length];
-        for (int i = 0; i < bytes.length; i++) {
-            chars[2 * i] = HEX_CHARS[(bytes[i] & 0xF0) >>> 4];
-            chars[2 * i + 1] = HEX_CHARS[bytes[i] & 0x0F];
-        }
-        return new String(chars);
-    }
 }



Mime
View raw message