jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1364664 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/lucene/ plugins/memory/ plugins/type/ spi/security/user/
Date Mon, 23 Jul 2012 14:53:01 GMT
Author: mduerig
Date: Mon Jul 23 14:53:01 2012
New Revision: 1364664

URL: http://svn.apache.org/viewvc?rev=1364664&view=rev
Log:
OAK-202 Simplify the code when possible
redundant field initialisation, missing @Override, use .isEmpty

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/OakDirectory.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/PasswordUtility.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java?rev=1364664&r1=1364663&r2=1364664&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
Mon Jul 23 14:53:01 2012
@@ -16,10 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.lucene;
 
-import static org.apache.jackrabbit.oak.plugins.lucene.FieldFactory.newPathField;
-import static org.apache.jackrabbit.oak.plugins.lucene.FieldFactory.newPropertyField;
-import static org.apache.jackrabbit.oak.plugins.lucene.TermFactory.newPathTerm;
-
 import java.io.IOException;
 
 import javax.jcr.PropertyType;
@@ -41,6 +37,10 @@ import org.apache.lucene.util.Version;
 import org.apache.tika.Tika;
 import org.apache.tika.exception.TikaException;
 
+import static org.apache.jackrabbit.oak.plugins.lucene.FieldFactory.newPathField;
+import static org.apache.jackrabbit.oak.plugins.lucene.FieldFactory.newPropertyField;
+import static org.apache.jackrabbit.oak.plugins.lucene.TermFactory.newPathTerm;
+
 public class LuceneEditor implements CommitEditor {
 
     private static final Tika TIKA = new Tika();
@@ -86,9 +86,9 @@ public class LuceneEditor implements Com
 
         private final String path;
 
-        private boolean modified = false;
+        private boolean modified;
 
-        private IOException exception = null;
+        private IOException exception;
 
         public LuceneDiff(IndexWriter writer, String path) {
             this.writer = writer;
@@ -173,7 +173,7 @@ public class LuceneEditor implements Com
             }
         }
 
-        private Document makeDocument(
+        private static Document makeDocument(
                 String path, NodeState state) {
             Document document = new Document();
             document.add(newPathField(path));
@@ -186,7 +186,7 @@ public class LuceneEditor implements Com
             return document;
         }
 
-        private String parseStringValue(CoreValue value) {
+        private static String parseStringValue(CoreValue value) {
             String string;
             if (value.getType() != PropertyType.BINARY) {
                 string = value.getString();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/OakDirectory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/OakDirectory.java?rev=1364664&r1=1364663&r2=1364664&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/OakDirectory.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/OakDirectory.java
Mon Jul 23 14:53:01 2012
@@ -284,6 +284,6 @@ class OakDirectory extends Directory {
             // do nothing
         }
 
-    };
+    }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java?rev=1364664&r1=1364663&r2=1364664&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java
Mon Jul 23 14:53:01 2012
@@ -16,11 +16,11 @@
  */
 package org.apache.jackrabbit.oak.plugins.memory;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStateBuilder;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
@@ -28,12 +28,11 @@ import com.google.common.base.Predicates
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStateBuilder;
 
 /**
  * Basic in-memory node state builder.
@@ -59,7 +58,7 @@ public class MemoryNodeStateBuilder impl
      * previous {@link #getNodeState()} call, and thus should not be
      * modified unless first explicitly {@link #unfreeze() unfrozen}.
      */
-    private boolean frozen = false;
+    private boolean frozen;
 
     /**
      * Creates a new in-memory node state builder.
@@ -150,6 +149,7 @@ public class MemoryNodeStateBuilder impl
         return count;
     }
 
+    @Override
     public boolean hasChildNode(String name) {
         NodeStateBuilder builder = builders.get(name);
         if (builder != null) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java?rev=1364664&r1=1364663&r2=1364664&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeDefinitionTemplateImpl.java
Mon Jul 23 14:53:01 2012
@@ -36,9 +36,9 @@ class NodeDefinitionTemplateImpl
     private static final Logger log =
             LoggerFactory.getLogger(NodeDefinitionTemplateImpl.class);
 
-    private String defaultPrimaryTypeName = null;
+    private String defaultPrimaryTypeName;
 
-    private String[] requiredPrimaryTypeNames = null;
+    private String[] requiredPrimaryTypeNames;
 
     protected NodeType getNodeType(String name) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java?rev=1364664&r1=1364663&r2=1364664&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/NodeTypeTemplateImpl.java
Mon Jul 23 14:53:01 2012
@@ -42,7 +42,7 @@ class NodeTypeTemplateImpl
 
     private final ValueFactory factory;
 
-    private String primaryItemName = null;
+    private String primaryItemName;
 
     private String[] superTypeNames = new String[0];
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java?rev=1364664&r1=1364663&r2=1364664&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/PropertyDefinitionTemplateImpl.java
Mon Jul 23 14:53:01 2012
@@ -29,9 +29,9 @@ class PropertyDefinitionTemplateImpl
         extends AbstractPropertyDefinitionBuilder<NodeTypeTemplate>
         implements PropertyDefinitionTemplate {
 
-    private String[] valueConstraints = null;
+    private String[] valueConstraints;
 
-    private Value[] defaultValues = null;
+    private Value[] defaultValues;
 
     protected Value createValue(String value) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/PasswordUtility.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/PasswordUtility.java?rev=1364664&r1=1364663&r2=1364664&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/PasswordUtility.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/PasswordUtility.java
Mon Jul 23 14:53:01 2012
@@ -139,7 +139,7 @@ public class PasswordUtility {
     private static String generateHash(String pwd, String algorithm, String salt, int iterations)
throws NoSuchAlgorithmException, UnsupportedEncodingException {
         StringBuilder passwordHash = new StringBuilder();
         passwordHash.append('{').append(algorithm).append('}');
-        if (salt != null && salt.length() > 0) {
+        if (salt != null && !salt.isEmpty()) {
             StringBuilder data = new StringBuilder();
             data.append(salt).append(pwd);
 
@@ -197,7 +197,7 @@ public class PasswordUtility {
      * or if the extracted string isn't a supported algorithm.
      */
     private static String extractAlgorithm(String hashedPwd) {
-        if (hashedPwd != null && !"".equals(hashedPwd)) {
+        if (hashedPwd != null && !hashedPwd.isEmpty()) {
             int end = hashedPwd.indexOf('}');
             if (hashedPwd.charAt(0) == '{' && end > 0 && end < hashedPwd.length()-1)
{
                 String algorithm = hashedPwd.substring(1, end);



Mime
View raw message