jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cko...@apache.org
Subject svn commit: r1745116 - /jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java
Date Mon, 23 May 2016 07:09:29 GMT
Author: ckoell
Date: Mon May 23 07:09:29 2016
New Revision: 1745116

URL: http://svn.apache.org/viewvc?rev=1745116&view=rev
Log:
JCR-3982 Implement toString in TransactionContext (XidWrapper)

Modified:
    jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java

Modified: jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java?rev=1745116&r1=1745115&r2=1745116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-data/src/main/java/org/apache/jackrabbit/data/core/TransactionContext.java
Mon May 23 07:09:29 2016
@@ -353,6 +353,9 @@ public class TransactionContext {
      * that handles hashCode and equals in a proper way.
      */
     private static class XidWrapper {
+        
+    	private static final char[] HEX = "0123456789abcdef".toCharArray();
+        
     	private byte[] gtid;
     	
     	public XidWrapper(byte[] gtid) {
@@ -371,6 +374,27 @@ public class TransactionContext {
         public int hashCode() {
             return Arrays.hashCode(gtid);
         }
+
+        @Override
+        public String toString() {
+            return encodeHexString(gtid);
+        }
+
+        /**
+         * Returns the hex encoding of the given bytes.
+         *
+         * @param value value to be encoded
+         * @return encoded value
+         */
+        private static String encodeHexString(byte[] value) {
+            char[] buffer = new char[value.length * 2];
+            for (int i = 0; i < value.length; i++) {
+                buffer[2 * i] = HEX[(value[i] >> 4) & 0x0f];
+                buffer[2 * i + 1] = HEX[value[i] & 0x0f];
+            }
+            return new String(buffer);
+        }
+
     }
 
 }



Mime
View raw message