jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r772955 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: persistence/ persistence/bundle/ persistence/bundle/util/ state/ value/
Date Fri, 08 May 2009 12:24:54 GMT
Author: thomasm
Date: Fri May  8 12:24:54 2009
New Revision: 772955

URL: http://svn.apache.org/viewvc?rev=772955&view=rev
Log:
JCR-2087 Upgrade to Java 5 as the base platform

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/AbstractPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/AbstractPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/AbstractPersistenceManager.java?rev=772955&r1=772954&r2=772955&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/AbstractPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/AbstractPersistenceManager.java
Fri May  8 12:24:54 2009
@@ -57,9 +57,9 @@
      * {@inheritDoc}
      */
     public synchronized void store(ChangeLog changeLog) throws ItemStateException {
-        Iterator iter = changeLog.deletedStates();
+        Iterator<ItemState> iter = changeLog.deletedStates();
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+            ItemState state = iter.next();
             if (state.isNode()) {
                 destroy((NodeState) state);
             } else {
@@ -84,9 +84,9 @@
                 store((PropertyState) state);
             }
         }
-        iter = changeLog.modifiedRefs();
+        Iterator<NodeReferences> refIter = changeLog.modifiedRefs();
         while (iter.hasNext()) {
-            NodeReferences refs = (NodeReferences) iter.next();
+            NodeReferences refs = refIter.next();
             if (refs.hasReferences()) {
                 store(refs);
             } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=772955&r1=772954&r2=772955&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
Fri May  8 12:24:54 2009
@@ -296,7 +296,7 @@
      * {@inheritDoc}
      */
     public synchronized void onExternalUpdate(ChangeLog changes) {
-        Iterator iter = changes.modifiedStates();
+        Iterator<ItemState> iter = changes.modifiedStates();
         while (iter.hasNext()) {
             ItemState state = (ItemState) iter.next();
             if (state.isNode()) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java?rev=772955&r1=772954&r2=772955&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
Fri May  8 12:24:54 2009
@@ -35,7 +35,6 @@
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.NoSuchElementException;
 
@@ -104,7 +103,7 @@
     public static final int SM_LONGLONG_KEYS = 2;
 
     /** flag indicating if this manager was initialized */
-    protected boolean initialized = false;
+    protected boolean initialized;
 
     /** the jdbc driver name */
     protected String driver;
@@ -125,10 +124,10 @@
     protected String schemaObjectPrefix;
 
     /** flag indicating if a consistency check should be issued during startup */
-    protected boolean consistencyCheck = false;
+    protected boolean consistencyCheck;
 
     /** flag indicating if the consistency check should attempt to fix issues */
-    protected boolean consistencyFix = false;
+    protected boolean consistencyFix;
 
     /** initial size of buffer used to serialize objects */
     protected static final int INITIAL_BUFFER_SIZE = 1024;
@@ -137,7 +136,7 @@
     protected boolean externalBLOBs;
 
     /** indicates whether to block if the database connection is lost */
-    protected boolean blockOnConnectionLoss = false;
+    protected boolean blockOnConnectionLoss;
 
     /**
      * The class that manages statement execution and recovery from connection loss.
@@ -712,14 +711,12 @@
      * {@linkplain NodePropBundle bundles} here
      */
     protected void checkBundleConsistency(NodeId id, NodePropBundle bundle,
-                                          boolean fix, Collection modifications) {
+                                          boolean fix, Collection<NodePropBundle> modifications)
{
         //log.info(name + ": checking bundle '" + id + "'");
 
         // look at the node's children
-        Collection missingChildren = new ArrayList();
-        Iterator iter = bundle.getChildNodeEntries().iterator();
-        while (iter.hasNext()) {
-            NodePropBundle.ChildNodeEntry entry = (NodePropBundle.ChildNodeEntry) iter.next();
+        Collection<NodePropBundle.ChildNodeEntry> missingChildren = new ArrayList<NodePropBundle.ChildNodeEntry>();
+        for (NodePropBundle.ChildNodeEntry entry : bundle.getChildNodeEntries()) {
 
             // skip check for system nodes (root, system root, version storage, node types)
             if (entry.getId().toString().endsWith("babecafebabe")) {
@@ -752,9 +749,8 @@
         }
         // remove child node entry (if fixing is enabled)
         if (fix && !missingChildren.isEmpty()) {
-            Iterator iterator = missingChildren.iterator();
-            while (iterator.hasNext()) {
-                bundle.getChildNodeEntries().remove(iterator.next());
+            for (NodePropBundle.ChildNodeEntry entry : missingChildren) {
+                bundle.getChildNodeEntries().remove(entry);
             }
             modifications.add(bundle);
         }
@@ -781,7 +777,7 @@
 
         int count = 0;
         int total = 0;
-        Collection modifications = new ArrayList();
+        Collection<NodePropBundle> modifications = new ArrayList<NodePropBundle>();
 
         if (uuids == null) {
             // get all node bundles in the database with a single sql statement,
@@ -868,7 +864,7 @@
             //     b) check bundle, store any bundle-to-be-modified in collection
             //     c) if recursive, add child uuids to list of uuids
 
-            List uuidList = new ArrayList(uuids.length);
+            List<UUID> uuidList = new ArrayList<UUID>(uuids.length);
             // convert uuid string array to list of UUID objects
             for (int i = 0; i < uuids.length; i++) {
                 try {
@@ -894,9 +890,7 @@
                     checkBundleConsistency(id, bundle, fix, modifications);
 
                     if (recursive) {
-                        Iterator iter = bundle.getChildNodeEntries().iterator();
-                        while (iter.hasNext()) {
-                            NodePropBundle.ChildNodeEntry entry = (NodePropBundle.ChildNodeEntry)
iter.next();
+                        for (NodePropBundle.ChildNodeEntry entry : bundle.getChildNodeEntries())
{
                             uuidList.add(entry.getId().getUUID());
                         }
                     }
@@ -916,9 +910,7 @@
         // repair collected broken bundles
         if (fix && !modifications.isEmpty()) {
             log.info(name + ": Fixing " + modifications.size() + " inconsistent bundle(s)...");
-            Iterator iterator = modifications.iterator();
-            while (iterator.hasNext()) {
-                NodePropBundle bundle = (NodePropBundle) iterator.next();
+            for (NodePropBundle bundle : modifications) {
                 try {
                     log.info(name + ": Fixing bundle '" + bundle.getId() + "'");
                     bundle.markOld(); // use UPDATE instead of INSERT
@@ -1033,7 +1025,7 @@
     protected Object[] createParams(UUID uuid, Object p, boolean before) {
 
         // Create the key
-        List key = new ArrayList();
+        List<Object> key = new ArrayList<Object>();
         if (getStorageModel() == SM_BINARY_KEYS) {
             key.add(uuid.getRawBytes());
         } else {
@@ -1042,7 +1034,7 @@
         }
 
         // Create the parameters
-        List params = new ArrayList();
+        List<Object> params = new ArrayList<Object>();
         if (before) {
             params.add(p);
             params.addAll(key);
@@ -1082,7 +1074,7 @@
             }
             Statement stmt = connectionManager.executeStmt(sql, keys, false, maxCount);
             rs = stmt.getResultSet();
-            ArrayList result = new ArrayList();
+            ArrayList<UUID> result = new ArrayList<UUID>();
             while ((maxCount == 0 || result.size() < maxCount) && rs.next()) {
                 UUID current;
                 if (getStorageModel() == SM_BINARY_KEYS) {
@@ -1609,10 +1601,10 @@
      */
     private class ListNodeIdIterator implements NodeIdIterator {
 
-        private final ArrayList list;
+        private final ArrayList<UUID> list;
         private int pos;
 
-        ListNodeIdIterator(ArrayList list) {
+        ListNodeIdIterator(ArrayList<UUID> list) {
             this.list = list;
         }
 
@@ -1620,7 +1612,7 @@
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
-            return new NodeId((UUID) list.get(pos++));
+            return new NodeId(list.get(pos++));
         }
 
         public boolean hasNext() {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java?rev=772955&r1=772954&r2=772955&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
Fri May  8 12:24:54 2009
@@ -67,7 +67,7 @@
     private static Logger log = LoggerFactory.getLogger(BundleFsPersistenceManager.class);
 
     /** flag indicating if this manager was initialized */
-    protected boolean initialized = false;
+    protected boolean initialized;
 
     /** file system where BLOB data is stored */
     protected BundleFsPersistenceManager.CloseableBLOBStore blobStore;
@@ -76,7 +76,7 @@
      * Default blocksize for BLOB filesystem:
      * @see #setBlobFSBlockSize(String)
      */
-    private int blobFSBlockSize = 0;
+    private int blobFSBlockSize;
 
     /**
      * the minimum size of a property until it gets written to the blob store
@@ -506,7 +506,7 @@
      */
     public NodeIdIterator getAllNodeIds(NodeId bigger, int maxCount)
             throws ItemStateException {
-        ArrayList list = new ArrayList();
+        ArrayList<NodeId> list = new ArrayList<NodeId>();
         try {
             getListRecursive(list, "", bigger == null ? null : bigger.getUUID(), maxCount);
             return new FileNodeIdIterator(list);
@@ -542,7 +542,7 @@
         return new UUID(u);
     }
 
-    private void getListRecursive(ArrayList list, String path, UUID bigger,
+    private void getListRecursive(ArrayList<NodeId> list, String path, UUID bigger,
             int maxCount) throws FileSystemException {
         if (maxCount > 0 && list.size() >= maxCount) {
             return;
@@ -572,12 +572,15 @@
         }
     }
 
+    /**
+     * Iterator over all node ids in this persistence manager.
+     */
     private static class FileNodeIdIterator implements NodeIdIterator {
 
-        private final ArrayList list;
+        private final ArrayList<NodeId> list;
         private int pos;
 
-        FileNodeIdIterator(ArrayList list) {
+        FileNodeIdIterator(ArrayList<NodeId> list) {
             this.list = list;
         }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java?rev=772955&r1=772954&r2=772955&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NodePropBundle.java
Fri May  8 12:24:54 2009
@@ -83,7 +83,7 @@
     /**
      * the child node entries
      */
-    private LinkedList childNodeEntries = new LinkedList();
+    private LinkedList<NodePropBundle.ChildNodeEntry> childNodeEntries = new LinkedList<NodePropBundle.ChildNodeEntry>();
 
     /**
      * the properties
@@ -98,17 +98,17 @@
     /**
      * flag that indicates if this bundle is referenceable
      */
-    private boolean isReferenceable = false;
+    private boolean isReferenceable;
 
     /**
      * the mod count
      */
-    private short modCount = 0;
+    private short modCount;
 
     /**
      * the size
      */
-    private long size = 0;
+    private long size;
     
     /**
      * Shared set, consisting of the parent ids of this shareable node. This
@@ -341,7 +341,7 @@
      * Returns the list of the child node entries.
      * @return the list of the child node entries.
      */
-    public List getChildNodeEntries() {
+    public List<NodePropBundle.ChildNodeEntry> getChildNodeEntries() {
         return childNodeEntries;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java?rev=772955&r1=772954&r2=772955&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java
Fri May  8 12:24:54 2009
@@ -31,22 +31,26 @@
     /**
      * Added states
      */
-    private final Map addedStates = new LinkedMap();
+    @SuppressWarnings("unchecked")
+    private final Map<ItemId, ItemState> addedStates = (Map<ItemId, ItemState>)
new LinkedMap();
 
     /**
      * Modified states
      */
-    private final Map modifiedStates = new LinkedMap();
+    @SuppressWarnings("unchecked")
+    private final Map<ItemId, ItemState> modifiedStates = (Map<ItemId, ItemState>)
new LinkedMap();
 
     /**
      * Deleted states
      */
-    private final Map deletedStates = new LinkedMap();
+    @SuppressWarnings("unchecked")
+    private final Map<ItemId, ItemState> deletedStates = (Map<ItemId, ItemState>)
new LinkedMap();
 
     /**
      * Modified references
      */
-    private final Map modifiedRefs = new LinkedMap();
+    @SuppressWarnings("unchecked")
+    private final Map<NodeReferencesId, NodeReferences> modifiedRefs = (Map<NodeReferencesId,
NodeReferences>) new LinkedMap();
 
     /**
      * Checks whether this change log contains any changes. This method is
@@ -122,9 +126,9 @@
      * @throws NoSuchItemStateException if the item has been deleted
      */
     public ItemState get(ItemId id) throws NoSuchItemStateException {
-        ItemState state = (ItemState) addedStates.get(id);
+        ItemState state = addedStates.get(id);
         if (state == null) {
-            state = (ItemState) modifiedStates.get(id);
+            state = modifiedStates.get(id);
             if (state == null) {
                 if (deletedStates.containsKey(id)) {
                     throw new NoSuchItemStateException("State has been marked destroyed:
" + id);
@@ -163,7 +167,7 @@
      * @return node references or <code>null</code>
      */
     public NodeReferences get(NodeReferencesId id) {
-        return (NodeReferences) modifiedRefs.get(id);
+        return modifiedRefs.get(id);
     }
 
     /**
@@ -171,7 +175,7 @@
      *
      * @return iterator over all added states.
      */
-    public Iterator addedStates() {
+    public Iterator<ItemState> addedStates() {
         return addedStates.values().iterator();
     }
 
@@ -180,7 +184,7 @@
      *
      * @return iterator over all modified states.
      */
-    public Iterator modifiedStates() {
+    public Iterator<ItemState> modifiedStates() {
         return modifiedStates.values().iterator();
     }
 
@@ -189,7 +193,7 @@
      *
      * @return iterator over all deleted states.
      */
-    public Iterator deletedStates() {
+    public Iterator<ItemState> deletedStates() {
         return deletedStates.values().iterator();
     }
 
@@ -198,7 +202,7 @@
      *
      * @return iterator over all modified references.
      */
-    public Iterator modifiedRefs() {
+    public Iterator<NodeReferences> modifiedRefs() {
         return modifiedRefs.values().iterator();
     }
 
@@ -209,9 +213,9 @@
      */
     public void merge(ChangeLog other) {
         // Remove all states from our 'added' set that have now been deleted
-        Iterator iter = other.deletedStates();
+        Iterator<ItemState> iter = other.deletedStates();
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+            ItemState state = iter.next();
             if (addedStates.remove(state.getId()) == null) {
                 deletedStates.put(state.getId(), state);
             }
@@ -222,7 +226,7 @@
         // only add modified states that are not already 'added'
         iter = other.modifiedStates();
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+            ItemState state = iter.next();
             if (!addedStates.containsKey(state.getId())) {
                 modifiedStates.put(state.getId(), state);
             } else {
@@ -235,8 +239,8 @@
         // add 'added' state, but respect previously deleted
         iter = other.addedStates();
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
-            ItemState deletedState = (ItemState) deletedStates.remove(state.getId());
+            ItemState state = iter.next();
+            ItemState deletedState = deletedStates.remove(state.getId());
             if (deletedState != null) {
                 // the newly 'added' state had previously been deleted;
                 // merging those two operations results in a modified state
@@ -259,17 +263,17 @@
      * items we have.
      */
     public void push() {
-        Iterator iter = modifiedStates();
+        Iterator<ItemState> iter = modifiedStates();
         while (iter.hasNext()) {
-            ((ItemState) iter.next()).push();
+            iter.next().push();
         }
         iter = deletedStates();
         while (iter.hasNext()) {
-            ((ItemState) iter.next()).push();
+            iter.next().push();
         }
         iter = addedStates();
         while (iter.hasNext()) {
-            ((ItemState) iter.next()).push();
+            iter.next().push();
         }
     }
 
@@ -278,22 +282,22 @@
      * internal states and notify listeners.
      */
     public void persisted() {
-        Iterator iter = modifiedStates();
+        Iterator<ItemState> iter = modifiedStates();
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+            ItemState state = iter.next();
             state.setStatus(ItemState.STATUS_EXISTING);
             state.notifyStateUpdated();
         }
         iter = deletedStates();
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+            ItemState state = iter.next();
             state.setStatus(ItemState.STATUS_EXISTING_REMOVED);
             state.notifyStateDestroyed();
             state.discard();
         }
         iter = addedStates();
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+            ItemState state = iter.next();
             state.setStatus(ItemState.STATUS_EXISTING);
             state.notifyStateCreated();
         }
@@ -315,17 +319,17 @@
      * states.
      */
     public void disconnect() {
-        Iterator iter = modifiedStates();
+        Iterator<ItemState> iter = modifiedStates();
         while (iter.hasNext()) {
-            ((ItemState) iter.next()).disconnect();
+            iter.next().disconnect();
         }
         iter = deletedStates();
         while (iter.hasNext()) {
-            ((ItemState) iter.next()).disconnect();
+            iter.next().disconnect();
         }
         iter = addedStates();
         while (iter.hasNext()) {
-            ((ItemState) iter.next()).disconnect();
+            iter.next().disconnect();
         }
     }
 
@@ -337,9 +341,9 @@
      * @param parent parent manager that will hold current data
      */
     public void undo(ItemStateManager parent) {
-        Iterator iter = modifiedStates();
+        Iterator<ItemState> iter = modifiedStates();
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+            ItemState state = iter.next();
             try {
                 state.connect(parent.getItemState(state.getId()));
                 state.pull();
@@ -349,7 +353,7 @@
         }
         iter = deletedStates();
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+            ItemState state = iter.next();
             try {
                 state.connect(parent.getItemState(state.getId()));
                 state.pull();
@@ -359,7 +363,7 @@
         }
         iter = addedStates();
         while (iter.hasNext()) {
-            ((ItemState) iter.next()).discard();
+            iter.next().discard();
         }
         reset();
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java?rev=772955&r1=772954&r2=772955&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
Fri May  8 12:24:54 2009
@@ -549,11 +549,11 @@
     }
 
     private InternalValue(long value) {
-        super(new Long(value));
+        super(Long.valueOf(value));
     }
 
     private InternalValue(double value) {
-        super(new Double(value));
+        super(Double.valueOf(value));
     }
 
     private InternalValue(Calendar value) {



Mime
View raw message