jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1331135 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: NodeDelegate.java NodeImpl.java PropertyDelegate.java nodetype/NodeTypeImpl.java nodetype/NodeTypeManagerImpl.java
Date Thu, 26 Apr 2012 22:36:30 GMT
Author: mduerig
Date: Thu Apr 26 22:36:30 2012
New Revision: 1331135

URL: http://svn.apache.org/viewvc?rev=1331135&view=rev
Log:
cleanup
- add @Override
- make methods static where possible
- make instance field final where possible
- use foreach
- removed redundant exceptions in implementations

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1331135&r1=1331134&r2=1331135&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Thu Apr 26 22:36:30 2012
@@ -79,6 +79,7 @@ public class NodeDelegate extends ItemDe
         return Paths.getDepth(getPath());
     }
 
+    @Override
     String getName() {
         return getTree().getName();
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1331135&r1=1331134&r2=1331135&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Thu Apr 26 22:36:30 2012
@@ -16,13 +16,20 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import static org.apache.jackrabbit.oak.util.Iterators.filter;
-
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.List;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
+import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.Tree.Status;
+import org.apache.jackrabbit.oak.jcr.util.ItemNameMatcher;
+import org.apache.jackrabbit.oak.jcr.util.LogUtil;
+import org.apache.jackrabbit.oak.jcr.util.ValueConverter;
+import org.apache.jackrabbit.oak.util.Function1;
+import org.apache.jackrabbit.oak.util.Iterators;
+import org.apache.jackrabbit.oak.util.Predicate;
+import org.apache.jackrabbit.value.ValueHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.Binary;
 import javax.jcr.Item;
@@ -44,21 +51,13 @@ import javax.jcr.nodetype.NodeTypeManage
 import javax.jcr.version.OnParentVersionAction;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
 
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
-import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.Tree.Status;
-import org.apache.jackrabbit.oak.jcr.util.ItemNameMatcher;
-import org.apache.jackrabbit.oak.jcr.util.LogUtil;
-import org.apache.jackrabbit.oak.jcr.util.ValueConverter;
-import org.apache.jackrabbit.oak.util.Function1;
-import org.apache.jackrabbit.oak.util.Iterators;
-import org.apache.jackrabbit.oak.util.Predicate;
-import org.apache.jackrabbit.value.ValueHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.apache.jackrabbit.oak.util.Iterators.filter;
 
 /**
  * {@code NodeImpl}...
@@ -895,8 +894,7 @@ public class NodeImpl extends ItemImpl i
 
     //------------------------------------------------------------< private >---
 
-
-    private Iterator<Node> nodeIterator(Iterator<NodeDelegate> childNodes) {
+    private static Iterator<Node> nodeIterator(Iterator<NodeDelegate> childNodes)
{
         return Iterators.map(childNodes, new Function1<NodeDelegate, Node>() {
             @Override
             public Node apply(NodeDelegate state) {
@@ -905,7 +903,7 @@ public class NodeImpl extends ItemImpl i
         });
     }
 
-    private Iterator<Property> propertyIterator(
+    private static Iterator<Property> propertyIterator(
             Iterator<PropertyDelegate> properties) {
         return Iterators.map(properties,
                 new Function1<PropertyDelegate, Property>() {
@@ -934,7 +932,7 @@ public class NodeImpl extends ItemImpl i
         return pd == null ? null : new PropertyImpl(pd);
     }
 
-    private int getTargetType(Value value, int type) {
+    private static int getTargetType(Value value, int type) {
         if (value == null) {
             return PropertyType.STRING; // TODO: review again. rather use
                                         // property definition
@@ -943,7 +941,7 @@ public class NodeImpl extends ItemImpl i
         }
     }
 
-    private int getTargetType(Value[] values, int type) {
+    private static int getTargetType(Value[] values, int type) {
         if (values == null || values.length == 0) {
             return PropertyType.STRING; // TODO: review again. rather use
                                         // property definition

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1331135&r1=1331134&r2=1331135&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
Thu Apr 26 22:36:30 2012
@@ -16,19 +16,18 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import java.util.List;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.nodetype.PropertyDefinition;
-
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.namepath.Paths;
 
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
+import java.util.List;
+
 public class PropertyDelegate extends ItemDelegate {
 
     private final SessionContext<SessionImpl> sessionContext;
@@ -151,10 +150,12 @@ public class PropertyDelegate extends It
         return getParentContentTree().getPropertyStatus(getName());
     }
     
+    @Override
     String getName() {
         return getPropertyState().getName();
     }
 
+    @Override
     String getPath() {
         return '/' + getParentContentTree().getPath() + '/' + getName();
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java?rev=1331135&r1=1331134&r2=1331135&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeImpl.java
Thu Apr 26 22:36:30 2012
@@ -16,16 +16,8 @@
  */
 package org.apache.jackrabbit.oak.jcr.nodetype;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
+import org.apache.jackrabbit.oak.namepath.NameMapper;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -36,9 +28,16 @@ import javax.jcr.nodetype.NodeTypeIterat
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.version.OnParentVersionAction;
-
-import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
-import org.apache.jackrabbit.oak.namepath.NameMapper;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 class NodeTypeImpl implements NodeType {
 
@@ -60,7 +59,7 @@ class NodeTypeImpl implements NodeType {
 
     private final String[] declaredSuperTypeNames;
 
-    private boolean isAbstract;
+    private final boolean isAbstract;
 
     private final boolean mixin;
 
@@ -99,7 +98,7 @@ class NodeTypeImpl implements NodeType {
         }
 
         String defs = matcher.group(9);
-        if (defs != null && defs.length() > 0) {
+        if (defs != null && !defs.isEmpty()) {
             for (String line : defs.split("\n")) {
                 matcher = DEF_PATTERN.matcher(line);
                 if (!matcher.matches()) {
@@ -282,9 +281,9 @@ class NodeTypeImpl implements NodeType {
         try {
             Collection<NodeType> types =
                     new ArrayList<NodeType>(declaredSuperTypeNames.length);
-            for (int i = 0; i < declaredSuperTypeNames.length; i++) {
+            for (String declaredSuperTypeName : declaredSuperTypeNames) {
                 types.add(manager.getNodeType(
-                        mapper.getJcrName(declaredSuperTypeNames[i])));
+                        mapper.getJcrName(declaredSuperTypeName)));
             }
             return new NodeTypeIteratorAdapter(types);
         } catch (RepositoryException e) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java?rev=1331135&r1=1331134&r2=1331135&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeManagerImpl.java
Thu Apr 26 22:36:30 2012
@@ -16,31 +16,28 @@
  */
 package org.apache.jackrabbit.oak.jcr.nodetype;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
+import org.apache.jackrabbit.oak.namepath.NameMapper;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeDefinitionTemplate;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeDefinition;
-import javax.jcr.nodetype.NodeTypeExistsException;
 import javax.jcr.nodetype.NodeTypeIterator;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeTypeTemplate;
 import javax.jcr.nodetype.PropertyDefinitionTemplate;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
-import org.apache.jackrabbit.oak.namepath.NameMapper;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class NodeTypeManagerImpl implements NodeTypeManager {
 
@@ -80,8 +77,7 @@ public class NodeTypeManagerImpl impleme
     }
 
     @Override
-    public NodeType getNodeType(String name)
-            throws NoSuchNodeTypeException, RepositoryException {
+    public NodeType getNodeType(String name) throws RepositoryException {
         NodeType type = types.get(mapper.getOakName(name));
         if (type == null) {
             throw new NoSuchNodeTypeException("Unknown node type: " + name);
@@ -117,55 +113,52 @@ public class NodeTypeManagerImpl impleme
     }
 
     @Override
-    public NodeTypeTemplate createNodeTypeTemplate()
-            throws UnsupportedRepositoryOperationException, RepositoryException {
+    public NodeTypeTemplate createNodeTypeTemplate() throws RepositoryException {
         throw new UnsupportedRepositoryOperationException();
     }
 
     @Override
     public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd)
-            throws UnsupportedRepositoryOperationException, RepositoryException {
+            throws RepositoryException {
+
         throw new UnsupportedRepositoryOperationException();
     }
 
     @Override
     public NodeDefinitionTemplate createNodeDefinitionTemplate()
-            throws UnsupportedRepositoryOperationException, RepositoryException {
+            throws RepositoryException {
+
         throw new UnsupportedRepositoryOperationException();
     }
 
     @Override
     public PropertyDefinitionTemplate createPropertyDefinitionTemplate()
-            throws UnsupportedRepositoryOperationException, RepositoryException {
+            throws RepositoryException {
+
         throw new UnsupportedRepositoryOperationException();
     }
 
     @Override
     public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate)
-            throws InvalidNodeTypeDefinitionException, NodeTypeExistsException,
-            UnsupportedRepositoryOperationException, RepositoryException {
+            throws RepositoryException {
+
         throw new UnsupportedRepositoryOperationException();
     }
 
     @Override
     public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds,
-            boolean allowUpdate) throws InvalidNodeTypeDefinitionException,
-            NodeTypeExistsException, UnsupportedRepositoryOperationException,
-            RepositoryException {
+            boolean allowUpdate) throws RepositoryException {
+
         throw new UnsupportedRepositoryOperationException();
     }
 
     @Override
-    public void unregisterNodeType(String name)
-            throws UnsupportedRepositoryOperationException,
-            NoSuchNodeTypeException, RepositoryException {
+    public void unregisterNodeType(String name) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException();
     }
 
     @Override
-    public void unregisterNodeTypes(String[] names)
-            throws UnsupportedRepositoryOperationException,
-            NoSuchNodeTypeException, RepositoryException {
+    public void unregisterNodeTypes(String[] names) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException();
     }
 



Mime
View raw message