jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r816660 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state: AbstractItemStateFactory.java SessionItemStateManager.java WorkspaceItemStateFactory.java
Date Fri, 18 Sep 2009 14:56:11 GMT
Author: reschke
Date: Fri Sep 18 14:56:10 2009
New Revision: 816660

URL: http://svn.apache.org/viewvc?rev=816660&view=rev
Log:
JCR-2087: parametrize generic types

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java?rev=816660&r1=816659&r2=816660&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java
Fri Sep 18 14:56:10 2009
@@ -29,7 +29,7 @@
 
     private static Logger log = LoggerFactory.getLogger(AbstractItemStateFactory.class);
 
-    private final Set creationListeners = new HashSet();
+    private final Set<ItemStateCreationListener> creationListeners = new HashSet<ItemStateCreationListener>();
 
     //---------------------------------------------------< ItemStateFactory >---
     /**
@@ -59,7 +59,7 @@
      */
     private ItemStateCreationListener[] getListeners() {
         synchronized (creationListeners) {
-            return (ItemStateCreationListener[]) creationListeners.toArray(new ItemStateCreationListener[creationListeners.size()]);
+            return creationListeners.toArray(new ItemStateCreationListener[creationListeners.size()]);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java?rev=816660&r1=816659&r2=816660&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
Fri Sep 18 14:56:10 2009
@@ -246,7 +246,7 @@
         NodeState parent = operation.getParentState();
         ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
         QNodeDefinition def = defProvider.getQNodeDefinition(parent.getAllNodeTypeNames(),
operation.getNodeName(), operation.getNodeTypeName());
-        List newStates = addNodeState(parent, operation.getNodeName(), operation.getNodeTypeName(),
operation.getUuid(), def, options);
+        List<ItemState> newStates = addNodeState(parent, operation.getNodeName(), operation.getNodeTypeName(),
operation.getUuid(), def, options);
         operation.addedState(newStates);
 
         transientStateMgr.addOperation(operation);
@@ -454,7 +454,7 @@
         return transientStateMgr.createNewPropertyState(propertyName, parent, pDef, values,
propertyType);
     }
 
-    private List addNodeState(NodeState parent, Name nodeName, Name nodeTypeName,
+    private List<ItemState> addNodeState(NodeState parent, Name nodeName, Name nodeTypeName,
                               String uuid, QNodeDefinition definition, int options)
             throws RepositoryException, ConstraintViolationException, AccessDeniedException,
             UnsupportedRepositoryOperationException, NoSuchNodeTypeException,
@@ -478,7 +478,7 @@
             }
         }
 
-        List addedStates = new ArrayList();
+        List<ItemState> addedStates = new ArrayList<ItemState>();
 
         // create new nodeState. NOTE, that the uniqueID is not added to the
         // state for consistency between 'addNode' and importXML

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=816660&r1=816659&r2=816660&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Fri Sep 18 14:56:10 2009
@@ -23,6 +23,7 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Collections;
+import java.util.Set;
 
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
@@ -33,6 +34,7 @@
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry;
 import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider;
+import org.apache.jackrabbit.spi.ChildInfo;
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.spi.ItemInfo;
 import org.apache.jackrabbit.spi.Name;
@@ -88,7 +90,7 @@
             throws ItemNotFoundException, RepositoryException {
         // build new node state from server information
         try {
-            Iterator infos = service.getItemInfos(sessionInfo, nodeId);
+            Iterator<? extends ItemInfo> infos = service.getItemInfos(sessionInfo,
nodeId);
             NodeState nodeState = createItemStates(nodeId, infos, entry, false);
 
             if (nodeState == null) {
@@ -106,7 +108,7 @@
      */
     public NodeState createDeepNodeState(NodeId nodeId, NodeEntry anyParent) throws ItemNotFoundException,
RepositoryException {
         try {
-            Iterator infos = service.getItemInfos(sessionInfo, nodeId);
+            Iterator<? extends ItemInfo> infos = service.getItemInfos(sessionInfo,
nodeId);
             return createItemStates(nodeId, infos, anyParent, true);
         } catch (PathNotFoundException e) {
             throw new ItemNotFoundException(e.getMessage());
@@ -152,7 +154,7 @@
      * @see ItemStateFactory#getChildNodeInfos(NodeId)
      * @param nodeId
      */
-    public Iterator getChildNodeInfos(NodeId nodeId)
+    public Iterator<ChildInfo> getChildNodeInfos(NodeId nodeId)
             throws ItemNotFoundException, RepositoryException {
         return service.getChildInfos(sessionInfo, nodeId);
     }
@@ -167,7 +169,8 @@
         if (entry.getUniqueID() == null
                 || !entry.hasPropertyEntry(NameConstants.JCR_UUID)) {
             // for sure not referenceable
-            return Collections.EMPTY_SET.iterator();
+            Set<PropertyId> t = Collections.emptySet();
+            return t.iterator();
         }
 
         // nodestate has a unique ID and is potentially mix:referenceable
@@ -176,7 +179,8 @@
             return service.getReferences(sessionInfo, entry.getWorkspaceId(), propertyName,
weak);
         } catch (RepositoryException e) {
             log.debug("Unable to determine references to {}", nodeState);
-            return Collections.EMPTY_SET.iterator();
+            Set<PropertyId> t = Collections.emptySet();
+            return t.iterator();
         }
     }
 
@@ -191,7 +195,7 @@
      * @throws ItemNotFoundException
      * @throws RepositoryException
      */
-    private synchronized NodeState createItemStates(NodeId nodeId, Iterator itemInfos,
+    private synchronized NodeState createItemStates(NodeId nodeId, Iterator<? extends
ItemInfo> itemInfos,
                                                     NodeEntry entry, boolean isDeep)
             throws ItemNotFoundException, RepositoryException {
         NodeState nodeState;
@@ -222,7 +226,7 @@
         // optimization results in about 25% speed up.
         NodeEntry approxParentEntry = nodeState.getNodeEntry();
         while (infos.hasNext()) {
-            ItemInfo info = (ItemInfo) infos.next();
+            ItemInfo info = infos.next();
             if (info.denotesNode()) {
                 approxParentEntry = createDeepNodeState((NodeInfo) info, approxParentEntry,
infos).getNodeEntry();
             } else {
@@ -263,9 +267,9 @@
         }
 
         // update NodeEntry from the information present in the NodeInfo (prop entries)
-        List propNames = new ArrayList();
-        for (Iterator it = info.getPropertyIds(); it.hasNext(); ) {
-            PropertyId pId = (PropertyId) it.next();
+        List<Name> propNames = new ArrayList<Name>();
+        for (Iterator<PropertyId> it = info.getPropertyIds(); it.hasNext(); ) {
+            PropertyId pId = it.next();
             Name propertyName = pId.getName();
             propNames.add(propertyName);
         }
@@ -278,7 +282,7 @@
 
         // unless the child-info are omitted by the SPI impl -> make sure
         // the childentries the nodeentry are initialized or updated.
-        Iterator childInfos = info.getChildInfos();
+        Iterator<ChildInfo> childInfos = info.getChildInfos();
         if (childInfos != null) {
             entry.setNodeEntries(childInfos);
         }
@@ -448,7 +452,7 @@
                                                          Name name, int index,
                                                          ItemInfos infos) throws RepositoryException
{
         if (infos != null) {
-            Iterator childInfos = infos.getChildInfos(parentEntry.getWorkspaceId());
+            Iterator<ChildInfo> childInfos = infos.getChildInfos(parentEntry.getWorkspaceId());
             if (childInfos != null) {
                 parentEntry.setNodeEntries(childInfos);
             }
@@ -531,13 +535,13 @@
     /**
      * Iterator
      */
-    private class ItemInfos implements Iterator {
+    private class ItemInfos implements Iterator<ItemInfo> {
 
-        private final List prefetchQueue = new ArrayList();
-        private final Map nodeInfos = new HashMap();
-        private final Iterator infos;
+        private final List<ItemInfo> prefetchQueue = new ArrayList<ItemInfo>();
+        private final Map<NodeId, NodeInfo> nodeInfos = new HashMap<NodeId, NodeInfo>();
+        private final Iterator<? extends ItemInfo> infos;
 
-        private ItemInfos(Iterator infos) {
+        private ItemInfos(Iterator<? extends ItemInfo> infos) {
             super();
             this.infos = infos;
         }
@@ -557,11 +561,11 @@
         /**
          * @see Iterator#next()
          */
-        public Object next() {
+        public ItemInfo next() {
             if (prefetchQueue.isEmpty()) {
                 throw new NoSuchElementException();
             } else {
-                Object next = prefetchQueue.remove(0);
+                ItemInfo next = prefetchQueue.remove(0);
                 if (next instanceof NodeInfo) {
                     nodeInfos.remove(((NodeInfo) next).getId());
                 }
@@ -584,10 +588,10 @@
          * has not been read yet, has already been processed (childInfo is up
          * to date) or does not provide child infos.
          */
-        private Iterator getChildInfos(NodeId parentId) {
-            NodeInfo nodeInfo = (NodeInfo) nodeInfos.get(parentId);
+        private Iterator<ChildInfo> getChildInfos(NodeId parentId) {
+            NodeInfo nodeInfo = nodeInfos.get(parentId);
             while (nodeInfo == null && prefetch()) {
-                nodeInfo = (NodeInfo) nodeInfos.get(parentId);
+                nodeInfo = nodeInfos.get(parentId);
             }
             return nodeInfo == null? null : nodeInfo.getChildInfos();
         }
@@ -597,7 +601,7 @@
          */
         private boolean prefetch() {
             if (infos.hasNext()) {
-                ItemInfo info = (ItemInfo) infos.next();
+                ItemInfo info = infos.next();
                 prefetchQueue.add(info);
                 if (info.denotesNode()) {
                     NodeInfo nodeInfo = (NodeInfo) info;



Mime
View raw message