jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r816719 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ hierarchy/ operation/
Date Fri, 18 Sep 2009 17:27:33 GMT
Author: reschke
Date: Fri Sep 18 17:27:32 2009
New Revision: 816719

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

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
Fri Sep 18 17:27:32 2009
@@ -25,7 +25,6 @@
 import javax.jcr.Item;
 import javax.jcr.RepositoryException;
 import java.util.Map;
-import java.util.Iterator;
 import java.io.PrintStream;
 
 /**
@@ -35,7 +34,7 @@
 
     private static Logger log = LoggerFactory.getLogger(ItemCacheImpl.class);
 
-    private final Map cache;
+    private final Map<ItemState, Item> cache;
 
     ItemCacheImpl(int maxSize) {
         cache = new LRUMap(maxSize);
@@ -46,7 +45,7 @@
      * @see ItemCache#getItem(ItemState)
      */
     public Item getItem(ItemState state) {
-        return (Item) cache.get(state);
+        return cache.get(state);
     }
 
     /**
@@ -141,10 +140,9 @@
      * @see Dumpable#dump(PrintStream)
      */
     public void dump(PrintStream ps) {
-        Iterator iter = cache.keySet().iterator();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
-            Item item = (Item) cache.get(state);
+        for (Map.Entry<ItemState, Item> entry : cache.entrySet()) {
+            ItemState state = entry.getKey();
+            Item item = entry.getValue();
             if (item.isNode()) {
                 ps.print("Node: ");
             } else {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Fri Sep 18 17:27:32 2009
@@ -69,7 +69,8 @@
     /**
      * Listeners (weak references)
      */
-    protected final Map listeners = Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK,
ReferenceMap.WEAK));
+    protected final Map<ItemLifeCycleListener, ItemLifeCycleListener> listeners =
+        Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
 
     public ItemImpl(SessionImpl session, ItemState state,
                     ItemLifeCycleListener[] listeners) {
@@ -365,7 +366,7 @@
      */
     private void notifyCreated() {
         // copy listeners to array to avoid ConcurrentModificationException
-        ItemLifeCycleListener[] la = (ItemLifeCycleListener[]) listeners.values().toArray(new
ItemLifeCycleListener[listeners.size()]);
+        ItemLifeCycleListener[] la = listeners.values().toArray(new ItemLifeCycleListener[listeners.size()]);
         for (int i = 0; i < la.length; i++) {
             la[i].itemCreated(this);
         }
@@ -376,7 +377,7 @@
      */
     private void notifyUpdated(boolean modified) {
         // copy listeners to array to avoid ConcurrentModificationException
-        ItemLifeCycleListener[] la = (ItemLifeCycleListener[]) listeners.values().toArray(new
ItemLifeCycleListener[listeners.size()]);
+        ItemLifeCycleListener[] la = listeners.values().toArray(new ItemLifeCycleListener[listeners.size()]);
         for (int i = 0; i < la.length; i++) {
             if (la[i] != null) {
                 la[i].itemUpdated(this, modified);
@@ -389,7 +390,7 @@
      */
     private void notifyDestroyed() {
         // copy listeners to array to avoid ConcurrentModificationException
-        ItemLifeCycleListener[] la = (ItemLifeCycleListener[]) listeners.values().toArray(new
ItemLifeCycleListener[listeners.size()]);
+        ItemLifeCycleListener[] la = listeners.values().toArray(new ItemLifeCycleListener[listeners.size()]);
         for (int i = 0; i < la.length; i++) {
             if (la[i] != null) {
                 la[i].itemDestroyed(this);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
Fri Sep 18 17:27:32 2009
@@ -225,11 +225,11 @@
         // check sanity of session
         session.checkIsAlive();
 
-        Iterator iter = parentEntry.getNodeEntries();
+        Iterator<NodeEntry> iter = parentEntry.getNodeEntries();
         while (iter.hasNext()) {
             try {
                 // check read access by accessing the nodeState (implicit validation check)
-                NodeEntry entry = (NodeEntry) iter.next();
+                NodeEntry entry = iter.next();
                 entry.getNodeState();
                 return true;
             } catch (ItemNotFoundException e) {
@@ -248,7 +248,7 @@
         // check sanity of session
         session.checkIsAlive();
 
-        Iterator it = parentEntry.getNodeEntries();
+        Iterator<NodeEntry> it = parentEntry.getNodeEntries();
         return new LazyItemIterator(this, it);
     }
 
@@ -260,10 +260,10 @@
         // check sanity of session
         session.checkIsAlive();
 
-        Iterator iter = parentEntry.getPropertyEntries();
+        Iterator<PropertyEntry> iter = parentEntry.getPropertyEntries();
         while (iter.hasNext()) {
             try {
-                PropertyEntry entry = (PropertyEntry) iter.next();
+                PropertyEntry entry = iter.next();
                 // check read access by accessing the propState (also implicit validation).
                 entry.getPropertyState();
                 return true;
@@ -283,7 +283,7 @@
         // check sanity of session
         session.checkIsAlive();
 
-        Iterator propEntries = parentEntry.getPropertyEntries();
+        Iterator<PropertyEntry> propEntries = parentEntry.getPropertyEntries();
         return new LazyItemIterator(this, propEntries);
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
Fri Sep 18 17:27:32 2009
@@ -214,7 +214,7 @@
         // make sure the workspace exists and is accessible for this session.
         session.checkAccessibleWorkspace(srcWorkspace);
         
-        Iterator failedIds = session.getVersionStateManager().merge((NodeState) n.getItemState(),
srcWorkspace, bestEffort, isShallow);
+        Iterator<NodeId> failedIds = session.getVersionStateManager().merge((NodeState)
n.getItemState(), srcWorkspace, bestEffort, isShallow);
         return new LazyItemIterator(itemManager, session.getHierarchyManager(), failedIds);
     }
 
@@ -322,7 +322,7 @@
     public NodeIterator merge(Node activityNode) throws VersionException, AccessDeniedException,
MergeException, LockException, InvalidItemStateException, RepositoryException {
         session.checkIsAlive();
         NodeImpl activity = getValidActivity(activityNode, "merge");
-        Iterator failedIds = vMgr.mergeActivity((NodeState) activity.getItemState());
+        Iterator<NodeId> failedIds = vMgr.mergeActivity((NodeState) activity.getItemState());
         return new LazyItemIterator(itemManager, session.getHierarchyManager(), failedIds);
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
Fri Sep 18 17:27:32 2009
@@ -60,7 +60,7 @@
     private final ItemManager itemMgr;
 
     /** Iterator over HierarchyEntry elements */
-    private final Iterator iter;
+    private final Iterator<? extends HierarchyEntry> iter;
 
     /**
      * The number of items.
@@ -81,7 +81,7 @@
      * @param itemMgr item manager
      * @param hierarchyEntryIterator Iterator over HierarchyEntries
      */
-    public LazyItemIterator(ItemManager itemMgr, Iterator hierarchyEntryIterator) {
+    public LazyItemIterator(ItemManager itemMgr, Iterator<? extends HierarchyEntry>
hierarchyEntryIterator) {
         this.itemMgr = itemMgr;
         this.iter = hierarchyEntryIterator;
         if (hierarchyEntryIterator instanceof RangeIterator) {
@@ -102,12 +102,12 @@
      * @param itemIds
      */
     public LazyItemIterator(ItemManager itemMgr, HierarchyManager hierarchyMgr,
-                            Iterator itemIds)
+                            Iterator<? extends ItemId> itemIds)
         throws ItemNotFoundException, RepositoryException {
         this.itemMgr = itemMgr;
-        List entries = new ArrayList();
+        List<HierarchyEntry> entries = new ArrayList<HierarchyEntry>();
         while (itemIds.hasNext()) {
-            ItemId id = (ItemId) itemIds.next();
+            ItemId id = itemIds.next();
             HierarchyEntry entry;
             if (id.denotesNode()) {
                 entry = hierarchyMgr.getNodeEntry((NodeId) id);
@@ -125,14 +125,14 @@
 
     /**
      * Prefetches next item.
-     * <p/>
+     * <p>
      * {@link #next} is set to the next available item in this iterator or to
      * <code>null</code> in case there are no more items.
      */
     private Item prefetchNext() {
         Item nextItem = null;
         while (nextItem == null && iter.hasNext()) {
-            HierarchyEntry entry = (HierarchyEntry) iter.next();
+            HierarchyEntry entry = iter.next();
             try {
                 nextItem = itemMgr.getItem(entry);
             } catch (RepositoryException e) {
@@ -182,7 +182,7 @@
 
     /**
      * Returns the number of <code>Item</code>s in this iterator or -1 if the
-     * size is unkown.
+     * size is unknown.
      * </p>
      * Note: The number returned by this method may differ from the number
      * of <code>Item</code>s actually returned by calls to hasNext() / getNextNode().
@@ -216,11 +216,11 @@
         // skip the first (skipNum - 1) items without actually retrieving them
         while (--skipNum > 0) {
             pos++;
-            HierarchyEntry entry = (HierarchyEntry) iter.next();
+            HierarchyEntry entry = iter.next();
             // check if item exists but don't build Item instance.
             while (!itemMgr.itemExists(entry)) {
                 log.debug("Ignoring nonexistent item " + entry);
-                entry = (HierarchyEntry) iter.next();
+                entry = iter.next();
             }
         }
         // prefetch final item (the one to be returned on next())

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
Fri Sep 18 17:27:32 2009
@@ -65,16 +65,16 @@
      * @see javax.jcr.NamespaceRegistry#getPrefixes()
      */
     public String[] getPrefixes() throws RepositoryException {
-        Collection prefixes = storage.getRegisteredNamespaces().keySet();
-        return (String[]) prefixes.toArray(new String[prefixes.size()]);
+        Collection<String> prefixes = storage.getRegisteredNamespaces().keySet();
+        return prefixes.toArray(new String[prefixes.size()]);
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getURIs()
      */
     public String[] getURIs() throws RepositoryException {
-        Collection uris = storage.getRegisteredNamespaces().values();
-        return (String[]) uris.toArray(new String[uris.size()]);
+        Collection<String> uris = storage.getRegisteredNamespaces().values();
+        return uris.toArray(new String[uris.size()]);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
Fri Sep 18 17:27:32 2009
@@ -28,7 +28,7 @@
  */
 public interface NamespaceStorage {
 
-    public Map getRegisteredNamespaces() throws RepositoryException;
+    public Map<String, String> getRegisteredNamespaces() throws RepositoryException;
 
     public String getPrefix(String uri) throws NamespaceException, RepositoryException;
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Fri Sep 18 17:27:32 2009
@@ -712,7 +712,7 @@
 
         // get mixin types present in the jcr:mixintypes property without
         // modifying the NodeState.
-        List mixinValue = getMixinTypes();
+        List<Name> mixinValue = getMixinTypes();
         if (!mixinValue.contains(mixinQName) && !isNodeType(mixinQName)) {
             if (!canAddMixin(mixinQName)) {
                 throw new ConstraintViolationException("Cannot add '" + mixinName + "' mixin
type.");
@@ -720,7 +720,7 @@
 
             mixinValue.add(mixinQName);
             // perform the operation
-            Operation op = SetMixin.create(getNodeState(), (Name[]) mixinValue.toArray(new
Name[mixinValue.size()]));
+            Operation op = SetMixin.create(getNodeState(), mixinValue.toArray(new Name[mixinValue.size()]));
             session.getSessionItemStateManager().execute(op);
         }
     }
@@ -732,7 +732,7 @@
         VersionException, ConstraintViolationException, LockException, RepositoryException
{
         checkIsWritable();
         Name ntName = getQName(mixinName);
-        List mixinValue = getMixinTypes();
+        List<Name> mixinValue = getMixinTypes();
         // remove name of target mixin
         if (!mixinValue.remove(ntName)) {
             throw new NoSuchNodeTypeException("Cannot remove mixin '" + mixinName + "': Nodetype
is not present on this node.");
@@ -763,7 +763,7 @@
         }
 
         // delegate to operation
-        Name[] mixins = (Name[]) mixinValue.toArray(new Name[mixinValue.size()]);
+        Name[] mixins = mixinValue.toArray(new Name[mixinValue.size()]);
         Operation op = SetMixin.create(getNodeState(), mixins);
         session.getSessionItemStateManager().execute(op);
     }
@@ -777,7 +777,7 @@
      *
      * @return mixin names present with the jcr:mixinTypes property.
      */
-    private List getMixinTypes() {
+    private List<Name> getMixinTypes() {
         Name[] mixinValue;
         if (getNodeState().getStatus() == Status.EXISTING) {
             // jcr:mixinTypes must correspond to the mixins present on the nodestate.
@@ -799,7 +799,7 @@
                 mixinValue = new Name[0];
             }
         }
-        List l = new ArrayList();
+        List<Name> l = new ArrayList<Name>();
         l.addAll(Arrays.asList(mixinValue));
         return l;
     }
@@ -812,9 +812,9 @@
      * @throws ConstraintViolationException
      * @throws NoSuchNodeTypeException
      */
-    private EffectiveNodeType getRemainingENT(List remainingMixins)
+    private EffectiveNodeType getRemainingENT(List<Name> remainingMixins)
             throws ConstraintViolationException, NoSuchNodeTypeException {
-        Name[] allRemaining = (Name[]) remainingMixins.toArray(new Name[remainingMixins.size()
+ 1]);
+        Name[] allRemaining = remainingMixins.toArray(new Name[remainingMixins.size() + 1]);
         allRemaining[remainingMixins.size()] = getPrimaryNodeTypeName();
         return session.getEffectiveNodeTypeProvider().getEffectiveNodeType(allRemaining);
     }
@@ -829,7 +829,7 @@
         }
         try {
             // first check if node is writable regarding protection status,
-            // locks, versioning, acces restriction.
+            // locks, versioning, access restriction.
             session.getValidator().checkIsWritable(getNodeState(), ItemStateValidator.CHECK_ALL);
             // then make sure the new mixin would not conflict.
             return canAddMixin(getQName(mixinName));
@@ -1012,7 +1012,7 @@
             }
 
             // if root is common ancestor, corresponding path is same as ours
-            // otherwise access referenceable ancestor and calcuate correspond. path.
+            // otherwise access referenceable ancestor and calculate correspond. path.
             String correspondingPath;
             if (referenceableNode.getDepth() == Path.ROOT_DEPTH) {
                 if (!srcSession.getItemManager().nodeExists(getQPath())) {
@@ -1434,8 +1434,8 @@
         session.getSessionItemStateManager().execute(an);
 
         // finally retrieve the new node
-        List addedStates = ((AddNode) an).getAddedStates();
-        ItemState nState = (ItemState) addedStates.get(0);
+        List<ItemState> addedStates = ((AddNode) an).getAddedStates();
+        ItemState nState = addedStates.get(0);
         return (Node) getItemManager().getItem(nState.getHierarchyEntry());
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Fri Sep 18 17:27:32 2009
@@ -162,7 +162,7 @@
      * List of event listener that are set on this WorkspaceManager to get
      * notifications about local and external changes.
      */
-    private final Set listeners = new HashSet();
+    private final Set<InternalEventListener> listeners = new HashSet<InternalEventListener>();
 
     /**
      * The current subscription for change events if there are listeners.
@@ -306,7 +306,7 @@
      */
     public String[] checkQueryStatement(String statement,
                                         String language,
-                                        Map namespaces)
+                                        Map<String, String> namespaces)
             throws InvalidQueryException, RepositoryException {
         return service.checkQueryStatement(sessionInfo, statement, language, namespaces);
     }
@@ -322,7 +322,7 @@
      * @return
      * @throws RepositoryException
      */
-    public QueryInfo executeQuery(String statement, String language, Map namespaces,
+    public QueryInfo executeQuery(String statement, String language, Map<String, String>
namespaces,
                                   long limit, long offset, Map<String, QValue> boundValues)
throws RepositoryException {
         return service.executeQuery(sessionInfo, statement, language, namespaces, limit,
offset, boundValues);
     }
@@ -430,13 +430,12 @@
      *
      * @param listeners the internal event listeners.
      */
-    private static EventFilter[] getEventFilters(Collection listeners) {
-        List filters = new ArrayList();
-        for (Iterator it = listeners.iterator(); it.hasNext(); ) {
-            InternalEventListener listener = (InternalEventListener) it.next();
+    private static EventFilter[] getEventFilters(Collection<InternalEventListener>
listeners) {
+        List<EventFilter> filters = new ArrayList<EventFilter>();
+        for (InternalEventListener listener : listeners) {
             filters.addAll(listener.getEventFilters());
         }
-        return (EventFilter[]) filters.toArray(new EventFilter[filters.size()]);
+        return filters.toArray(new EventFilter[filters.size()]);
     }
 
     /**
@@ -469,10 +468,10 @@
      */
     private NodeTypeRegistryImpl createNodeTypeRegistry(NamespaceRegistry nsRegistry) {
         NodeTypeStorage ntst = new NodeTypeStorage() {
-            public Iterator getAllDefinitions() throws RepositoryException {
+            public Iterator<QNodeTypeDefinition> getAllDefinitions() throws RepositoryException
{
                 return service.getQNodeTypeDefinitions(sessionInfo);
             }
-            public Iterator getDefinitions(Name[] nodeTypeNames) throws NoSuchNodeTypeException,
RepositoryException {
+            public Iterator<QNodeTypeDefinition> getDefinitions(Name[] nodeTypeNames)
throws NoSuchNodeTypeException, RepositoryException {
                 return service.getQNodeTypeDefinitions(sessionInfo, nodeTypeNames);
             }
             public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs, boolean allowUpdate)
throws RepositoryException {
@@ -681,7 +680,7 @@
 
     //---------------------------------------------------< NamespaceStorage >---
 
-    public Map getRegisteredNamespaces() throws RepositoryException {
+    public Map<String, String> getRegisteredNamespaces() throws RepositoryException
{
         return service.getRegisteredNamespaces(sessionInfo);
     }
 
@@ -730,8 +729,8 @@
             log.debug("received {} event bundles.", new Integer(eventBundles.length));
             for (int i = 0; i < eventBundles.length; i++) {
                 log.debug("IsLocal:  {}", Boolean.valueOf(eventBundles[i].isLocal()));
-                for (Iterator it = eventBundles[i].getEvents(); it.hasNext(); ) {
-                    Event e = (Event) it.next();
+                for (Iterator<Event> it = eventBundles[i].getEvents(); it.hasNext();
) {
+                    Event e = it.next();
                     String type;
                     switch (e.getType()) {
                         case Event.NODE_ADDED:
@@ -802,9 +801,7 @@
             try {
                 ItemState target = changeLog.getTarget();
                 batch = service.createBatch(sessionInfo, target.getId());
-                Iterator it = changeLog.getOperations().iterator();
-                while (it.hasNext()) {
-                    Operation op = (Operation) it.next();
+                for (Operation op : changeLog.getOperations()) {
                     log.debug("executing " + op.getName());
                     op.accept(this);
                 }
@@ -1015,7 +1012,7 @@
          */
         public void visit(Merge operation) throws NoSuchWorkspaceException, AccessDeniedException,
MergeException, LockException, InvalidItemStateException, RepositoryException {
             NodeId nId = operation.getNodeId();
-            Iterator failed;
+            Iterator<NodeId> failed;
             if (operation.isActivityMerge()) {
                 failed = service.mergeActivity(sessionInfo, nId);
             } else {
@@ -1151,7 +1148,7 @@
                         while (listeners.isEmpty()) {
                             listeners.wait();
                         }
-                        iel = (InternalEventListener[]) listeners.toArray(new InternalEventListener[0]);
+                        iel = listeners.toArray(new InternalEventListener[0]);
                         subscr = subscription;
                     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
Fri Sep 18 17:27:32 2009
@@ -137,7 +137,7 @@
         properties = new ChildPropertyEntriesImpl(this, factory);
         childNodeEntries = new ChildNodeEntriesImpl(this, factory, null);
 
-        propertiesInAttic = new HashMap();
+        propertiesInAttic = new HashMap<Name, PropertyEntry>();
         childNodeAttic = new ChildNodeAttic();
 
         factory.notifyEntryCreated(this);
@@ -195,8 +195,8 @@
         // did not cause this entry to be removed -> therefore check status.
         if (recursive && !Status.isTerminal(getStatus())) {
             // recursively reload all entries including props that are in the attic.
-            for (Iterator it = getAllChildEntries(true); it.hasNext();) {
-                HierarchyEntry ce = (HierarchyEntry) it.next();
+            for (Iterator<HierarchyEntry> it = getAllChildEntries(true); it.hasNext();)
{
+                HierarchyEntry ce = it.next();
                 ce.reload(recursive);
             }
         }
@@ -228,8 +228,8 @@
      * @see HierarchyEntry#transientRemove()
      */
     public void transientRemove() throws RepositoryException {
-        for (Iterator it = getAllChildEntries(false); it.hasNext();) {
-            HierarchyEntry ce = (HierarchyEntry) it.next();
+        for (Iterator<HierarchyEntry> it = getAllChildEntries(false); it.hasNext();)
{
+            HierarchyEntry ce = it.next();
             ce.transientRemove();
         }
 
@@ -251,7 +251,7 @@
         super.internalRemove(false);
         boolean staleParent = (getStatus() == Status.STALE_DESTROYED);
         // now remove all child-entries (or mark them accordingly)
-        for (Iterator it = getAllChildEntries(true); it.hasNext();) {
+        for (Iterator<HierarchyEntry> it = getAllChildEntries(true); it.hasNext();)
{
             HierarchyEntryImpl ce = (HierarchyEntryImpl) it.next();
             ce.internalRemove(staleParent);
         }
@@ -263,7 +263,7 @@
         staleParent = (staleParent || (getStatus() == Status.STALE_DESTROYED));
 
         // now remove all child-entries (or mark them accordingly)
-        for (Iterator it = getAllChildEntries(true); it.hasNext();) {
+        for (Iterator<HierarchyEntry> it = getAllChildEntries(true); it.hasNext();)
{
             HierarchyEntryImpl ce = (HierarchyEntryImpl) it.next();
             ce.internalRemove(staleParent);
         }
@@ -413,7 +413,7 @@
                 }
                 // -> check for moved child entry in node-attic
                 // -> check if child points to a removed/moved sns
-                List siblings = entry.childNodeEntries.get(name);
+                List<NodeEntry> siblings = entry.childNodeEntries.get(name);
                 if (entry.containsAtticChild(siblings, name, index)) {
                     throw new PathNotFoundException(factory.saveGetJCRPath(path));
                 }
@@ -487,7 +487,7 @@
                 }
                 // -> check for moved child entry in node-attic
                 // -> check if child points to a removed/moved sns
-                List siblings = entry.childNodeEntries.get(name);
+                List<NodeEntry> siblings = entry.childNodeEntries.get(name);
                 if (entry.containsAtticChild(siblings, name, index)) {
                     throw new PathNotFoundException(factory.saveGetJCRPath(path));
                 }
@@ -567,7 +567,7 @@
      * @see NodeEntry#hasNodeEntry(Name)
      */
     public synchronized boolean hasNodeEntry(Name nodeName) {
-        List namedEntries = childNodeEntries.get(nodeName);
+        List<NodeEntry> namedEntries = childNodeEntries.get(nodeName);
         if (namedEntries.isEmpty()) {
             return false;
         } else {
@@ -598,14 +598,14 @@
      * @see NodeEntry#getNodeEntry(Name, int, boolean)
      */
     public NodeEntry getNodeEntry(Name nodeName, int index, boolean loadIfNotFound) throws
RepositoryException {
-        List entries = childNodeEntries.get(nodeName);
+        List<NodeEntry> entries = childNodeEntries.get(nodeName);
         NodeEntry cne = null;
         if (entries.size() >= index) {
             // position of entry might differ from index-1 if a SNS with lower
             // index has been transiently removed.
             int eIndex = 1;
             for (int i = 0; i < entries.size() && cne == null; i++) {
-                NodeEntry ne = (NodeEntry) entries.get(i);
+                NodeEntry ne = entries.get(i);
                 if (EntryValidation.isValidNodeEntry(ne)) {
                     if (eIndex == index) {
                         cne = ne;
@@ -629,8 +629,8 @@
     /**
      * @see NodeEntry#getNodeEntries()
      */
-    public synchronized Iterator getNodeEntries() throws RepositoryException {
-        Collection entries = new ArrayList();
+    public synchronized Iterator<NodeEntry> getNodeEntries() throws RepositoryException
{
+        Collection<NodeEntry> entries = new ArrayList<NodeEntry>();
         for (Iterator<NodeEntry> it = getCompleteChildNodeEntries().iterator(); it.hasNext();)
{
             NodeEntry entry = it.next();
             if (EntryValidation.isValidNodeEntry(entry)) {
@@ -643,17 +643,17 @@
     /**
      * @see NodeEntry#getNodeEntries(Name)
      */
-    public synchronized List getNodeEntries(Name nodeName) throws RepositoryException {
-        List namedEntries = getCompleteChildNodeEntries().get(nodeName);
+    public synchronized List<NodeEntry> getNodeEntries(Name nodeName) throws RepositoryException
{
+        List<NodeEntry> namedEntries = getCompleteChildNodeEntries().get(nodeName);
         if (namedEntries.isEmpty()) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         } else {
-            List entries = new ArrayList();
+            List<NodeEntry> entries = new ArrayList<NodeEntry>();
             // get array of the list, since during validation the childNodeEntries
             // may be modified if upon NodeEntry.getItemState the entry gets removed.
-            Object[] arr = namedEntries.toArray();
+            NodeEntry[] arr = namedEntries.toArray(new NodeEntry[namedEntries.size()]);
             for (int i = 0; i < arr.length; i++) {
-                NodeEntry cne = (NodeEntry) arr[i];
+                NodeEntry cne = arr[i];
                 if (EntryValidation.isValidNodeEntry(cne)) {
                     entries.add(cne);
                 }
@@ -665,14 +665,14 @@
     /**
      * @see NodeEntry#setNodeEntries(Iterator)
      */
-    public void setNodeEntries(Iterator childInfos) throws RepositoryException {
+    public void setNodeEntries(Iterator<ChildInfo> childInfos) throws RepositoryException
{
         if (childNodeAttic.isEmpty()) {
             ((ChildNodeEntriesImpl) childNodeEntries).update(childInfos);
         } else {
             // filter those entries that have been moved to the attic.
-            List remaining = new ArrayList();
+            List<ChildInfo> remaining = new ArrayList<ChildInfo>();
             while (childInfos.hasNext()) {
-                ChildInfo ci = (ChildInfo) childInfos.next();
+                ChildInfo ci = childInfos.next();
                 if (!childNodeAttic.contains(ci.getName(), ci.getIndex(), ci.getUniqueID()))
{
                     remaining.add(ci);
                 }
@@ -739,11 +739,11 @@
      * @inheritDoc
      * @see NodeEntry#getPropertyEntries()
      */
-    public synchronized Iterator getPropertyEntries() {
-        Collection props;
+    public synchronized Iterator<PropertyEntry> getPropertyEntries() {
+        Collection<PropertyEntry> props;
         if (getStatus() == Status.EXISTING_MODIFIED) {
             // filter out removed properties
-            props = new ArrayList();
+            props = new ArrayList<PropertyEntry>();
             // use array since upon validation the entry might be removed.
             Object[] arr = properties.getPropertyEntries().toArray();
             for (int i = 0; i < arr.length; i++) {
@@ -775,19 +775,19 @@
     /**
      * @see NodeEntry#setPropertyEntries(Collection)
      */
-    public void setPropertyEntries(Collection propNames) throws ItemExistsException, RepositoryException
{
-        Set diff = new HashSet();
+    public void setPropertyEntries(Collection<Name> propNames) throws ItemExistsException,
RepositoryException {
+        Set<Name> diff = new HashSet<Name>();
         diff.addAll(properties.getPropertyNames());
         boolean containsExtra = diff.removeAll(propNames);
 
         // add all entries that are missing
-        for (Iterator it = propNames.iterator(); it.hasNext();) {
-            Name propName = (Name) it.next();
+        for (Iterator<Name> it = propNames.iterator(); it.hasNext();) {
+            Name propName = it.next();
             if (!properties.contains(propName)) {
                 // TODO: check again.
                 // setPropertyEntries is used by WorkspaceItemStateFactory upon
                 // creating a NodeState, in which case the uuid/mixins are set
-                // anyway and not need exists to explicitely load the corresponding
+                // anyway and not need exists to explicitly load the corresponding
                 // property state in order to retrieve the values.
                 internalAddPropertyEntry(propName, false);
             }
@@ -798,8 +798,8 @@
         // collection of property names are removed from this NodeEntry.
         ItemState state = internalGetItemState();
         if (containsExtra && (state == null || state.getStatus() == Status.INVALIDATED))
{
-            for (Iterator it = diff.iterator(); it.hasNext();) {
-                Name propName = (Name) it.next();
+            for (Iterator<Name> it = diff.iterator(); it.hasNext();) {
+                Name propName = it.next();
                 PropertyEntry pEntry = properties.get(propName);
                 if (pEntry != null) {
                     pEntry.remove();
@@ -1089,7 +1089,7 @@
             }
         } else {
             Name propName = childEntry.getName();
-            PropertyEntry atticEntry = (PropertyEntry) propertiesInAttic.get(propName);
+            PropertyEntry atticEntry = propertiesInAttic.get(propName);
             if (atticEntry == null) {
                 properties.remove((PropertyEntry) childEntry);
             } else if (atticEntry == childEntry) {
@@ -1116,8 +1116,8 @@
         if (recursive) {
             // invalidate all child entries including properties present in the
             // attic (removed props shadowed by a new property with the same name).
-            for (Iterator it = getAllChildEntries(true); it.hasNext();) {
-                HierarchyEntry ce = (HierarchyEntry) it.next();
+            for (Iterator<HierarchyEntry> it = getAllChildEntries(true); it.hasNext();)
{
+                HierarchyEntry ce = it.next();
                 ce.invalidate(true);
             }
         }
@@ -1251,7 +1251,7 @@
         // for external prop-removal the attic must be consulted first
         // in order not access a NEW prop shadowing a transiently removed
         // property with the same name.
-        PropertyEntry child = (PropertyEntry) propertiesInAttic.get(childName);
+        PropertyEntry child = propertiesInAttic.get(childName);
         if (child == null) {
             child = properties.get(childName);
         }
@@ -1330,12 +1330,12 @@
         IteratorChain chain = new IteratorChain();
         // attic
         if (includeAttic) {
-            Collection attic = propertiesInAttic.values();
-            chain.addIterator(new ArrayList(attic).iterator());
+            Collection<PropertyEntry> attic = propertiesInAttic.values();
+            chain.addIterator(new ArrayList<PropertyEntry>(attic).iterator());
         }
         // add props
         synchronized (properties) {
-            Collection props = properties.getPropertyEntries();
+            Collection<PropertyEntry> props = properties.getPropertyEntries();
             chain.addIterator(props.iterator());
         }
         // add childNodeEntries
@@ -1355,12 +1355,12 @@
      * this <code>NodeEntry</code>.
      */
     private int getChildIndex(NodeEntry cne, boolean wspIndex) throws ItemNotFoundException,
RepositoryException {
-        List sns = new ArrayList(childNodeEntries.get(cne.getName()));
+        List<NodeEntry> sns = new ArrayList<NodeEntry>(childNodeEntries.get(cne.getName()));
 
         if (wspIndex) {
-            List atticSiblings = childNodeAttic.get(cne.getName());
-            for (Iterator it = atticSiblings.iterator(); it.hasNext();) {
-                NodeEntryImpl sibl = (NodeEntryImpl) it.next();
+            List<NodeEntryImpl> atticSiblings = childNodeAttic.get(cne.getName());
+            for (Iterator<NodeEntryImpl> it = atticSiblings.iterator(); it.hasNext();)
{
+                NodeEntryImpl sibl = it.next();
                 if (sibl.revertInfo != null) {
                     sns.add(sibl.revertInfo.oldIndex - 1, sibl);
                 } else {
@@ -1383,8 +1383,8 @@
         } else {
             // siblings exist.
             int index = Path.INDEX_DEFAULT;
-            for (Iterator it = sns.iterator(); it.hasNext(); ) {
-                NodeEntry entry = (NodeEntry) it.next();
+            for (Iterator<NodeEntry> it = sns.iterator(); it.hasNext(); ) {
+                NodeEntry entry = it.next();
                 if (entry == cne) { // TODO see below
                     return index;
                 }
@@ -1418,7 +1418,7 @@
      * matches the given name/index or if the siblings list contain a reordered
      * entry that matches.
      */
-    private boolean containsAtticChild(List siblings, Name childName, int childIndex) {
+    private boolean containsAtticChild(List<NodeEntry> siblings, Name childName, int
childIndex) {
         // check if a matching entry exists in the attic
         if (childNodeAttic.contains(childName, childIndex)) {
             return true;
@@ -1426,15 +1426,15 @@
         // special treatment for potentially moved/reordered/removed sns
         // TODO: check again
         if (childIndex > Path.INDEX_DEFAULT) {
-            List siblingsInAttic = childNodeAttic.get(childName);
+            List<NodeEntryImpl> siblingsInAttic = childNodeAttic.get(childName);
             if (siblings.size() < childIndex && childIndex <= siblings.size()
+ siblingsInAttic.size()) {
                 return true;
             }
         }
         if (getStatus() == Status.EXISTING_MODIFIED) {
-            for (Iterator it = siblings.iterator(); it.hasNext();) {
-                NodeEntryImpl child = (NodeEntryImpl) it.next();
-                if (!EntryValidation.isValidNodeEntry(child) || (child.revertInfo != null
&& child.revertInfo.oldIndex == childIndex)) {
+            for (Iterator<NodeEntry> it = siblings.iterator(); it.hasNext();) {
+                NodeEntry child = it.next();
+                if (!EntryValidation.isValidNodeEntry(child) || ((NodeEntryImpl)child).revertInfo
!= null && ((NodeEntryImpl)child).revertInfo.oldIndex == childIndex) {
                     return true;
                 }
             }
@@ -1456,8 +1456,8 @@
             throw new IllegalArgumentException();
         }
 
-        for (Iterator it = operation.getAddedStates().iterator(); it.hasNext();) {
-            HierarchyEntry he = ((ItemState) it.next()).getHierarchyEntry();
+        for (Iterator<ItemState> it = operation.getAddedStates().iterator(); it.hasNext();)
{
+            HierarchyEntry he = it.next().getHierarchyEntry();
             if (he.getStatus() == Status.NEW) {
                 switch (operation.getStatus()) {
                     case Operation.STATUS_PERSISTED:
@@ -1515,7 +1515,7 @@
                 if (!rmEntry.denotesNode()) {
                     Name propName = rmEntry.getName();
                     if (propertiesInAttic.containsKey(propName)) {
-                        properties.add((PropertyEntry) propertiesInAttic.remove(propName));
+                        properties.add(propertiesInAttic.remove(propName));
                     } // else: propEntry has never been moved to the attic (see 'addPropertyEntry')
                 }
                 rmEntry.revert();

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java?rev=816719&r1=816718&r2=816719&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Merge.java
Fri Sep 18 17:27:32 2009
@@ -47,7 +47,7 @@
     private final boolean isShallow;
     private final VersionManager mgr;
 
-    private Iterator<ItemId> failedIds = null;
+    private Iterator<? extends ItemId> failedIds = null;
 
     private Merge(NodeState nodeState, String srcWorkspaceName, boolean bestEffort, boolean
isShallow, VersionManager mgr) {
         this.nodeState = nodeState;
@@ -118,7 +118,7 @@
         return srcWorkspaceName == null;
     }
 
-    public void setFailedIds(Iterator<ItemId> failedIds) {
+    public void setFailedIds(Iterator<? extends ItemId> failedIds) {
         if (failedIds == null) {
             throw new IllegalArgumentException("IdIterator must not be null.");
         }
@@ -128,7 +128,7 @@
         this.failedIds = failedIds;
     }
 
-    public Iterator<ItemId> getFailedIds() {
+    public Iterator<? extends ItemId> getFailedIds() {
         if (failedIds == null) {
             throw new IllegalStateException("Merge operation has not been executed yet.");
         }



Mime
View raw message