jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1156531 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/datastore/ main/java/org/apache/jackrabbit/mk/json/ main/java/org/apache/jackrabbit/mk/mem/ main/java/org/apache/jackrabbit/mk/util/ test/java/org/apache/...
Date Thu, 11 Aug 2011 08:16:27 GMT
Author: thomasm
Date: Thu Aug 11 08:16:27 2011
New Revision: 1156531

URL: http://svn.apache.org/viewvc?rev=1156531&view=rev
Log:
Fix issues found by CodePro Analytix

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/datastore/DbStore.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopBuilder.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DbStoreTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/Profiler.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/datastore/DbStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/datastore/DbStore.java?rev=1156531&r1=1156530&r2=1156531&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/datastore/DbStore.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/datastore/DbStore.java
Thu Aug 11 08:16:27 2011
@@ -61,6 +61,7 @@ public class DbStore {
 
     private static final int TYPE_DATA = 0;
     private static final int TYPE_HASH = 1;
+    private static final int TYPE_HASH_COMPRESSED = 2;
 
     /**
      * The minimum size of a block. Smaller blocks are stored (the data store id

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopBuilder.java?rev=1156531&r1=1156530&r2=1156531&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopBuilder.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopBuilder.java
Thu Aug 11 08:16:27 2011
@@ -110,7 +110,7 @@ public class JsopBuilder {
      * @return this
      */
     public JsopBuilder endArray() {
-        buff.append("]");
+        buff.append(']');
         needComma = true;
         return this;
     }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java?rev=1156531&r1=1156530&r2=1156531&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
Thu Aug 11 08:16:27 2011
@@ -274,8 +274,8 @@ public class MemoryKernelImpl implements
     }
 
     public String getNodes(String path, String revisionId, int depth, long offset, int count)
{
-        if (!path.startsWith("/")) {
-            throw new IllegalArgumentException("not a root path: " + path);
+        if (!PathUtils.isAbsolute(path)) {
+            throw new IllegalArgumentException("not an absolute path: " + path);
         }
         path = path.substring(1);
         long revId = parseRevisionId(revisionId);
@@ -291,8 +291,8 @@ public class MemoryKernelImpl implements
 
     public boolean nodeExists(String path, String revisionId) {
         // TODO use a bloom filter
-        if (!path.startsWith("/")) {
-            throw new IllegalArgumentException("not a root path: " + path);
+        if (!PathUtils.isAbsolute(path)) {
+            throw new IllegalArgumentException("not an absolute path: " + path);
         }
         path = path.substring(1);
         long revId = parseRevisionId(revisionId);

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java?rev=1156531&r1=1156530&r2=1156531&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
Thu Aug 11 08:16:27 2011
@@ -46,6 +46,10 @@ public class PathUtils {
     public static boolean denotesRoot(String path) {
         assertValid(path);
 
+        return denotesRootPath(path);
+    }
+
+    private static boolean denotesRootPath(String path) {
         return "/".equals(path);
     }
 
@@ -58,7 +62,11 @@ public class PathUtils {
     public static boolean isAbsolute(String path) {
         assertValid(path);
 
-        return path.startsWith("/");
+        return isAbsolutePath(path);
+    }
+
+    private static boolean isAbsolutePath(String path) {
+        return path.length() > 0 && path.charAt(0) == '/';
     }
 
     /**
@@ -73,14 +81,14 @@ public class PathUtils {
     public static String getParentPath(String path) {
         assertValid(path);
 
-        if (path.length() == 0 || path.equals("/")) {
+        if (path.length() == 0 || denotesRootPath(path)) {
             return path;
         }
         int end = path.length() - 1;
         int pos = getPreviousSlash(path, end);
         if (pos > 0) {
             return path.substring(0, pos);
-        } else if (pos < 0 && !path.startsWith("/")) {
+        } else if (pos < 0 && !isAbsolutePath(path)) {
             return "";
         }
         return path.length() > 0 ? "/" : path;
@@ -96,7 +104,7 @@ public class PathUtils {
     public static String getName(String path) {
         assertValid(path);
 
-        if (path.length() == 0 || path.equals("/")) {
+        if (path.length() == 0 || denotesRootPath(path)) {
             return "";
         }
         int end = path.length() - 1;
@@ -118,8 +126,8 @@ public class PathUtils {
         assertValid(path);
 
         int count = 1, i = 0;
-        if (path.startsWith("/")) {
-            if (path.equals("/")) {
+        if (isAbsolutePath(path)) {
+            if (denotesRootPath(path)) {
                 return 0;
             }
             i++;
@@ -145,7 +153,7 @@ public class PathUtils {
 
         if (path.length() == 0) {
             return EMPTY_ARRAY;
-        } else if (path.startsWith("/")) {
+        } else if (isAbsolutePath(path)) {
             if (path.length() == 1) {
                 return EMPTY_ARRAY;
             }
@@ -177,7 +185,7 @@ public class PathUtils {
         assertValid(parentPath);
         assertValid(relativePath);
 
-        if (relativePath.startsWith("/")) {
+        if (isAbsolutePath(relativePath)) {
             throw new IllegalArgumentException("Cannot append absolute path " + relativePath);
         } else if (relativePath.length() == 0) {
             return parentPath;
@@ -186,7 +194,7 @@ public class PathUtils {
         StringBuilder buff = new StringBuilder(
                 parentLen + 1 + relativePath.length());
         buff.append(parentPath);
-        if (parentLen > 0 && !parentPath.endsWith("/")) {
+        if (parentLen > 0 && !denotesRootPath(parentPath)) {
             buff.append('/');
         }
         buff.append(relativePath);
@@ -210,7 +218,7 @@ public class PathUtils {
             return "";
         }
 
-        String prefix = parentPath.equals("/")
+        String prefix = denotesRootPath(parentPath)
             ? parentPath
             : parentPath + '/';
 
@@ -260,9 +268,9 @@ public class PathUtils {
      * @param path the path
      */
     public static void validate(String path) {
-        if (path.length() == 0 || "/".equals(path)) {
+        if (path.length() == 0 || denotesRootPath(path)) {
             return;
-        } else if (path.endsWith("/")) {
+        } else if (path.charAt(path.length() - 1) == '/') {
             throw new IllegalArgumentException("Path may not end with '/': " + path);
         }
         char last = 0;

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DbStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DbStoreTest.java?rev=1156531&r1=1156530&r2=1156531&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DbStoreTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DbStoreTest.java
Thu Aug 11 08:16:27 2011
@@ -71,10 +71,6 @@ public class DbStoreTest extends TestCas
             int expectedLen = r.nextInt(maxLength);
             byte[] expectedData = new byte[expectedLen];
             r.nextBytes(expectedData);
-            if (expectedLen != store.getBlobLength(s[i])) {
-                System.out.println("?");
-                assertEquals(expectedLen, store.getBlobLength(s[i++]));
-            }
             assertEquals(expectedLen, store.getBlobLength(s[i++]));
 
             String id = s[i++];

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/Profiler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/Profiler.java?rev=1156531&r1=1156530&r2=1156531&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/Profiler.java (original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/Profiler.java Thu
Aug 11 08:16:27 2011
@@ -62,8 +62,7 @@ public class Profiler implements Runnabl
      * Start collecting profiling data.
      */
     public void startCollecting() {
-        thread = new Thread(this);
-        thread.setName("Profiler");
+        thread = new Thread(this, "Profiler");
         thread.setDaemon(true);
         thread.start();
     }



Mime
View raw message