jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1364573 - in /jackrabbit/oak/trunk/oak-commons/src: main/java/org/apache/jackrabbit/oak/commons/PathUtils.java test/java/org/apache/jackrabbit/oak/commons/PathTest.java
Date Mon, 23 Jul 2012 10:40:39 GMT
Author: thomasm
Date: Mon Jul 23 10:40:38 2012
New Revision: 1364573

URL: http://svn.apache.org/viewvc?rev=1364573&view=rev
Log:
OAK-202 Simplify the code when possible

Modified:
    jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
    jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java

Modified: jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java?rev=1364573&r1=1364572&r2=1364573&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
Mon Jul 23 10:40:38 2012
@@ -181,22 +181,16 @@ public class PathUtils {
                     if (pos >= path.length()) {
                         return false;
                     }
-                    else {
-                        int i = path.indexOf('/', pos);
-                        if (i < 0) {
-                            next = path.substring(pos);
-                            pos = path.length();
-                        }
-                        else {
-                            next = path.substring(pos, i);
-                            pos = i + 1;
-                        }
-                        return true;
+                    int i = path.indexOf('/', pos);
+                    if (i < 0) {
+                        next = path.substring(pos);
+                        pos = path.length();
+                    } else {
+                        next = path.substring(pos, i);
+                        pos = i + 1;
                     }
                 }
-                else {
-                    return true;
-                }
+                return true;
             }
 
             @Override
@@ -206,9 +200,7 @@ public class PathUtils {
                     this.next = null;
                     return next;
                 }
-                else {
-                    throw new NoSuchElementException();
-                }
+                throw new NoSuchElementException();
             }
 
             @Override

Modified: jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java?rev=1364573&r1=1364572&r2=1364573&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java
(original)
+++ jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PathTest.java
Mon Jul 23 10:40:38 2012
@@ -19,6 +19,9 @@ package org.apache.jackrabbit.oak.common
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
+/**
+ * Test the PathUtils class.
+ */
 public class PathTest extends TestCase {
     static boolean assertsEnabled;
 
@@ -54,7 +57,7 @@ public class PathTest extends TestCase {
         test("x", "y");
     }
 
-    private int getElementCount(String path) {
+    private static int getElementCount(String path) {
         int count = 0;
         for (String p : PathUtils.elements(path)) {
             assertFalse(PathUtils.isAbsolute(p));
@@ -63,7 +66,7 @@ public class PathTest extends TestCase {
         return count;
     }
 
-    private String getElement(String path, int index) {
+    private static String getElement(String path, int index) {
         int count = 0;
         for (String p : PathUtils.elements(path)) {
             if (index == count++) {
@@ -74,7 +77,7 @@ public class PathTest extends TestCase {
         return "";
     }
 
-    private void test(String parent, String child) {
+    private static void test(String parent, String child) {
 
         // split
         assertEquals(0, getElementCount(""));



Mime
View raw message