jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r915837 - in /jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons: NodeInfoImpl.java SerializableBatch.java SessionInfoImpl.java name/PathBuilder.java name/PathFactoryImpl.java
Date Wed, 24 Feb 2010 15:55:34 GMT
Author: angela
Date: Wed Feb 24 15:55:34 2010
New Revision: 915837

URL: http://svn.apache.org/viewvc?rev=915837&view=rev
Log:
- add missing @Override annotation
- parametrize generic types
- remove unnecessary unboxing

Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SessionInfoImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathBuilder.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathFactoryImpl.java

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java?rev=915837&r1=915836&r2=915837&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java
Wed Feb 24 15:55:34 2010
@@ -58,17 +58,17 @@
     /**
      * The list of {@link PropertyId}s that reference this node info.
      */
-    private final List references;
+    private final List<PropertyId> references;
 
     /**
      * The list of {@link PropertyId}s of this node info.
      */
-    private final List propertyIds;
+    private final List<PropertyId> propertyIds;
 
     /**
      * The list of {@link ChildInfo}s of this node info.
      */
-    private final List childInfos;
+    private final List<ChildInfo> childInfos;
 
     /**
      * Creates a new serializable <code>NodeInfo</code> for the given
@@ -81,27 +81,26 @@
         if (nodeInfo instanceof Serializable) {
             return nodeInfo;
         } else {
-            PropertyId[] refs = nodeInfo.getReferences();
-            List serRefs = new ArrayList();
-            for (int i = 0; i < refs.length; i++) {
-                NodeId parentId = refs[i].getParentId();
+            List<PropertyId> serRefs = new ArrayList<PropertyId>();
+            for (PropertyId ref : nodeInfo.getReferences()) {
+                NodeId parentId = ref.getParentId();
                 parentId = idFactory.createNodeId(
                         parentId.getUniqueID(), parentId.getPath());
-                serRefs.add(idFactory.createPropertyId(parentId, refs[i].getName()));
+                serRefs.add(idFactory.createPropertyId(parentId, ref.getName()));
             }
             NodeId nodeId = nodeInfo.getId();
             nodeId = idFactory.createNodeId(nodeId.getUniqueID(), nodeId.getPath());
-            final Iterator propIds = nodeInfo.getPropertyIds();
-            final Iterator childInfos = nodeInfo.getChildInfos();
+            final Iterator<PropertyId> propIds = nodeInfo.getPropertyIds();
+            final Iterator<ChildInfo> childInfos = nodeInfo.getChildInfos();
             return new NodeInfoImpl(nodeInfo.getPath(), nodeId,
                     nodeInfo.getIndex(), nodeInfo.getNodetype(),
                     nodeInfo.getMixins(), serRefs.iterator(),
-                    new Iterator() {
+                    new Iterator<PropertyId>() {
                         public boolean hasNext() {
                             return propIds.hasNext();
                         }
-                        public Object next() {
-                            PropertyId propId = (PropertyId) propIds.next();
+                        public PropertyId next() {
+                            PropertyId propId = propIds.next();
                             NodeId parentId = propId.getParentId();
                             idFactory.createNodeId(
                                     parentId.getUniqueID(), parentId.getPath());
@@ -113,12 +112,12 @@
                         }
                     },
                     ((childInfos == null) ? null :
-                    new Iterator() {
+                    new Iterator<ChildInfo>() {
                         public boolean hasNext() {
                             return childInfos.hasNext();
                         }
-                        public Object next() {
-                            ChildInfo cInfo = (ChildInfo) childInfos.next();
+                        public ChildInfo next() {
+                            ChildInfo cInfo = childInfos.next();
                             if (cInfo instanceof Serializable) {
                                 return cInfo;
                             } else {
@@ -146,13 +145,13 @@
      * @param references      the references to this node.
      * @param propertyIds     the properties of this node.
      * @param childInfos      the child infos of this node or <code>null</code>.
-     * @deprecated Use {@link #NodeInfoImpl(Name, Path, NodeId, int, Name, Name[], Iterator,
Iterator)}
+     * @deprecated Use {@link #NodeInfoImpl(Path, NodeId, int, Name, Name[], Iterator, Iterator,
Iterator)}
      * instead. The parentId is not used any more.
      */
     public NodeInfoImpl(NodeId parentId, Name name, Path path, NodeId id,
                         int index, Name primaryTypeName, Name[] mixinNames,
-                        Iterator references, Iterator propertyIds,
-                        Iterator childInfos) {
+                        Iterator<PropertyId> references, Iterator<PropertyId>
propertyIds,
+                        Iterator<ChildInfo> childInfos) {
          this(path, id, index, primaryTypeName, mixinNames, references, propertyIds, childInfos);
     }
 
@@ -168,25 +167,26 @@
      * @param propertyIds     the properties of this node.
      */
     public NodeInfoImpl(Path path, NodeId id, int index, Name primaryTypeName,
-                        Name[] mixinNames, Iterator references, Iterator propertyIds,
-                        Iterator childInfos) {
+                        Name[] mixinNames, Iterator<PropertyId> references,
+                        Iterator<PropertyId> propertyIds,
+                        Iterator<ChildInfo> childInfos) {
         super(path, true);
         this.id = id;
         this.index = index;
         this.primaryTypeName = primaryTypeName;
         this.mixinNames = mixinNames;
-        this.references = new ArrayList();
+        this.references = new ArrayList<PropertyId>();
         while (references.hasNext()) {
             this.references.add(references.next());
         }
-        this.propertyIds = new ArrayList();
+        this.propertyIds = new ArrayList<PropertyId>();
         while (propertyIds.hasNext()) {
             this.propertyIds.add(propertyIds.next());
         }
         if (childInfos == null) {
             this.childInfos = null;
         } else {
-            this.childInfos = new ArrayList();
+            this.childInfos = new ArrayList<ChildInfo>();
             while (childInfos.hasNext()) {
                 this.childInfos.add(childInfos.next());
             }
@@ -229,20 +229,20 @@
      * {@inheritDoc}
      */
     public PropertyId[] getReferences() {
-        return (PropertyId[]) references.toArray(new PropertyId[references.size()]);
+        return references.toArray(new PropertyId[references.size()]);
     }
 
     /**
      * {@inheritDoc}
      */
-    public Iterator getPropertyIds() {
+    public Iterator<PropertyId> getPropertyIds() {
         return propertyIds.iterator();
     }
 
     /**
      * {@inheritDoc}
      */
-    public Iterator getChildInfos() {
+    public Iterator<ChildInfo> getChildInfos() {
         return (childInfos == null) ? null : childInfos.iterator();
     }
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java?rev=915837&r1=915836&r2=915837&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java
Wed Feb 24 15:55:34 2010
@@ -36,7 +36,6 @@
 import java.io.Serializable;
 import java.util.List;
 import java.util.ArrayList;
-import java.util.Iterator;
 
 /**
  * <code>SerializableBatch</code> implements a serializable SPI Batch, which
@@ -46,7 +45,7 @@
  */
 public class SerializableBatch implements Batch, Serializable {
 
-    private List recording = new ArrayList();
+    private List<Operation> recording = new ArrayList<Operation>();
 
     private final ItemId itemId;
 
@@ -75,8 +74,8 @@
      * @param batch the target batch.
      */
     public void replay(Batch batch) throws PathNotFoundException, ItemNotFoundException,
NoSuchNodeTypeException, ValueFormatException, VersionException, LockException, ConstraintViolationException,
AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
-        for (Iterator it = recording.iterator(); it.hasNext(); ) {
-            ((Operation) it.next()).replay(batch);
+        for (Operation operation : recording) {
+            operation.replay(batch);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SessionInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SessionInfoImpl.java?rev=915837&r1=915836&r2=915837&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SessionInfoImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/SessionInfoImpl.java
Wed Feb 24 15:55:34 2010
@@ -48,7 +48,7 @@
     /**
      * The list of lock tokens.
      */
-    private List lockTokens = new ArrayList();
+    private List<String> lockTokens = new ArrayList<String>();
 
     /**
      * Default constructor
@@ -95,7 +95,7 @@
      * {@inheritDoc}
      */
     public String[] getLockTokens() {
-        return (String[]) lockTokens.toArray(new String[lockTokens.size()]);
+        return lockTokens.toArray(new String[lockTokens.size()]);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathBuilder.java?rev=915837&r1=915836&r2=915837&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathBuilder.java
Wed Feb 24 15:55:34 2010
@@ -43,7 +43,7 @@
     /**
      * the list of path elements of the constructed path
      */
-    private final LinkedList queue;
+    private final LinkedList<Path.Element> queue;
 
     /**
      * Creates a new PathBuilder to create a Path using the
@@ -62,7 +62,7 @@
      */
     public PathBuilder(PathFactory factory) {
         this.factory = (factory != null) ? factory : PathFactoryImpl.getInstance();
-        queue = new LinkedList();
+        queue = new LinkedList<Path.Element>();
     }
 
     /**
@@ -100,8 +100,8 @@
      * @param elements
      */
     public void addAll(Path.Element[] elements) {
-        for (int i = 0; i < elements.length; i++) {
-            addLast(elements[i]);
+        for (Path.Element element : elements) {
+            addLast(element);
         }
     }
 
@@ -171,7 +171,7 @@
         if (queue.size() == 0) {
             throw new MalformedPathException("empty path");
         }
-        Path.Element[] elements = (Path.Element[]) queue.toArray(new Path.Element[queue.size()]);
+        Path.Element[] elements = queue.toArray(new Path.Element[queue.size()]);
         return factory.create(elements);
     }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathFactoryImpl.java?rev=915837&r1=915836&r2=915837&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathFactoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathFactoryImpl.java
Wed Feb 24 15:55:34 2010
@@ -71,7 +71,7 @@
             throw new IllegalArgumentException(
                     "relPath is not a relative path: " + relPath);
         }
-        List l = new ArrayList();
+        List<Path.Element> l = new ArrayList<Path.Element>();
         l.addAll(Arrays.asList(parent.getElements()));
         l.addAll(Arrays.asList(relPath.getElements()));
 
@@ -88,7 +88,7 @@
      * @see PathFactory#create(Path, Name, boolean)
      */
     public Path create(Path parent, Name name, boolean normalize) throws RepositoryException
{
-        List elements = new ArrayList();
+        List<Path.Element> elements = new ArrayList<Path.Element>();
         elements.addAll(Arrays.asList(parent.getElements()));
         elements.add(createElement(name));
 
@@ -105,7 +105,7 @@
      * @see PathFactory#create(Path, Name, int, boolean)
      */
     public Path create(Path parent, Name name, int index, boolean normalize) throws IllegalArgumentException,
RepositoryException {
-        List elements = new ArrayList();
+        List<Path.Element> elements = new ArrayList<Path.Element>();
         elements.addAll(Arrays.asList(parent.getElements()));
         elements.add(createElement(name, index));
 
@@ -155,7 +155,7 @@
         // split into path elements
         int lastPos = 0;
         int pos = pathString.indexOf(Path.DELIMITER);
-        ArrayList list = new ArrayList();
+        ArrayList<Path.Element> list = new ArrayList<Path.Element>();
         while (lastPos >= 0) {
             Path.Element elem;
             if (pos >= 0) {
@@ -244,7 +244,7 @@
             throw new IllegalArgumentException("invalid PathElement literal: " + elementString
+ " (missing ']')");
         }
         try {
-            int index = Integer.valueOf(elementString.substring(pos + 1, pos1)).intValue();
+            int index = Integer.valueOf(elementString.substring(pos + 1, pos1));
             if (index < 1) {
                 throw new IllegalArgumentException("invalid PathElement literal: " + elementString
+ " (index is 1-based)");
             }
@@ -365,16 +365,15 @@
                 throw new RepositoryException(
                         "Identifier-based path cannot be normalized: " + this);
             }
-            LinkedList queue = new LinkedList();
+            LinkedList<Path.Element> queue = new LinkedList<Path.Element>();
             Path.Element last = PARENT_ELEMENT;
-            for (int i = 0; i < elements.length; i++) {
-                Path.Element elem = elements[i];
+            for (Element elem : elements) {
                 if (elem.denotesParent() && !last.denotesParent()) {
                     queue.removeLast();
                     if (queue.isEmpty()) {
                         last = PARENT_ELEMENT;
                     } else {
-                        last = (Path.Element) queue.getLast();
+                        last = queue.getLast();
                     }
                 } else if (!elem.denotesCurrent()) {
                     last = elem;
@@ -385,7 +384,7 @@
                 return CURRENT_PATH;
             }
             boolean isNormalized = true;
-            return new PathImpl((Path.Element[]) queue.toArray(new Element[queue.size()]),
isNormalized);
+            return new PathImpl(queue.toArray(new Element[queue.size()]), isNormalized);
         }
 
         /**
@@ -445,7 +444,7 @@
                 }
                 lengthCommon++;
             }
-            List l = new ArrayList();
+            List<Path.Element> l = new ArrayList<Path.Element>();
             if (lengthCommon < elems0.length) {
                 /**
                  * the common path fragment is an ancestor of this path;
@@ -524,10 +523,10 @@
                         "Cannot determine depth of an identifier based path: " + this);
             }
             int depth = ROOT_DEPTH;
-            for (int i = 0; i < elements.length; i++) {
-                if (elements[i].denotesParent()) {
+            for (Element element : elements) {
+                if (element.denotesParent()) {
                     depth--;
-                } else if (elements[i].denotesName()) {
+                } else if (element.denotesName()) {
                     // don't count root/current element.
                     depth++;
                 }
@@ -645,6 +644,7 @@
          *
          * @return the internal string representation of this <code>Path</code>.
          */
+        @Override
         public String toString() {
             // Path is immutable, we can store the string representation
             if (string == null) {
@@ -668,13 +668,14 @@
          * @return a hash code value for this path.
          * @see Object#hashCode()
          */
+        @Override
         public int hashCode() {
             // Path is immutable, we can store the computed hash code value
             int h = hash;
             if (h == 0) {
                 h = 17;
-                for (int i = 0; i < elements.length; i++) {
-                    h = 37 * h + elements[i].hashCode();
+                for (Element element : elements) {
+                    h = 37 * h + element.hashCode();
                 }
                 hash = h;
             }
@@ -687,6 +688,7 @@
          * @param obj the object to be compared for equality with this path.
          * @return <tt>true</tt> if the specified object is equal to this path.
          */
+        @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
@@ -826,6 +828,7 @@
          * @return string representation of the path element
          * @see Object#toString()
          */
+        @Override
         public String toString() {
             StringBuffer sb = new StringBuffer();
             // name
@@ -845,6 +848,7 @@
          * @return hash code
          * @see Object#hashCode()
          */
+        @Override
         public int hashCode() {
             int h = 17;
             h = 37 * h + getNormalizedIndex();
@@ -861,6 +865,7 @@
          * @return <code>true</code> if the path elements are equal
          * @see Object#equals(Object)
          */
+        @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
@@ -903,6 +908,7 @@
          * @return true if this is the {@link #ROOT root element}.
          * @see Path.Element#denotesRoot()
          */
+        @Override
         public boolean denotesRoot() {
             return type == ROOT;
         }
@@ -911,6 +917,7 @@
          * @return true if this is the {@link #PARENT parent element}.
          * @see Path.Element#denotesParent()
          */
+        @Override
         public boolean denotesParent() {
             return type == PARENT;
         }
@@ -919,6 +926,7 @@
          * @return true if this is the {@link #CURRENT current element}.
          * @see Path.Element#denotesCurrent()
          */
+        @Override
         public boolean denotesCurrent() {
             return type == CURRENT;
         }
@@ -927,6 +935,7 @@
          * @return Always returns false.
          * @see Path.Element#denotesName()
          */
+        @Override
         public boolean denotesName() {
             return false;
         }
@@ -951,6 +960,7 @@
          * @return Always returns true.
          * @see Path.Element#denotesIdentifier()
          */
+        @Override
         public boolean denotesIdentifier() {
             return true;
         }
@@ -959,6 +969,7 @@
          * @return Always returns false.
          * @see Path.Element#denotesName()
          */
+        @Override
         public boolean denotesName() {
             return false;
         }
@@ -971,6 +982,7 @@
          * @return string representation of the path element
          * @see Object#toString()
          */
+        @Override
         public String toString() {
             StringBuffer sb = new StringBuffer();
             sb.append('[');
@@ -985,6 +997,7 @@
          * @return hash code
          * @see Object#hashCode()
          */
+        @Override
         public int hashCode() {
             int h = 37 * 17 + identifier.hashCode();
             return h;
@@ -999,6 +1012,7 @@
          * @return <code>true</code> if the path elements are equal
          * @see Object#equals(Object)
          */
+        @Override
         public boolean equals(Object obj) {
             if (this == obj) {
                 return true;
@@ -1035,8 +1049,8 @@
          * @throws IllegalArgumentException if the given elements array is null
          * or has a length less than 1;
          */
-        private Builder(List elemList) {
-            this((Path.Element[]) elemList.toArray(new Path.Element[elemList.size()]));
+        private Builder(List<Path.Element> elemList) {
+            this(elemList.toArray(new Path.Element[elemList.size()]));
         }
 
         /**



Mime
View raw message