jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1004622 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ lock/ nodetype/ state/ util/
Date Tue, 05 Oct 2010 12:32:02 GMT
Author: jukka
Date: Tue Oct  5 12:32:01 2010
New Revision: 1004622

URL: http://svn.apache.org/viewvc?rev=1004622&view=rev
Log:
JCR-2763: Drop the Dumpable interface

Removed:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/Dumpable.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/BitSetENTCacheImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCache.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCacheImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
Tue Oct  5 12:32:01 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core;
 
-import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -36,7 +35,6 @@ import org.apache.jackrabbit.core.state.
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.NodeStateListener;
-import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
@@ -51,7 +49,7 @@ import org.slf4j.LoggerFactory;
  * items.
  */
 public class CachingHierarchyManager extends HierarchyManagerImpl
-        implements NodeStateListener, Dumpable {
+        implements NodeStateListener {
 
     /**
      * Default upper limit of cached states
@@ -751,31 +749,30 @@ public class CachingHierarchyManager ext
     }
 
     /**
-     * Dump contents of path map and elements included to <code>PrintStream</code>
given.
-     *
-     * @param ps print stream to dump to
+     * Dump contents of path map and elements included to a string.
      */
-    public void dump(final PrintStream ps) {
+    public String toString() {
+        final StringBuilder builder = new StringBuilder();
         synchronized (cacheMonitor) {
             pathCache.traverse(new PathMap.ElementVisitor<LRUEntry>() {
                 public void elementVisited(PathMap.Element<LRUEntry> element) {
-                    StringBuffer line = new StringBuffer();
                     for (int i = 0; i < element.getDepth(); i++) {
-                        line.append("--");
+                        builder.append("--");
                     }
-                    line.append(element.getName());
+                    builder.append(element.getName());
                     int index = element.getIndex();
                     if (index != 0 && index != 1) {
-                        line.append('[');
-                        line.append(index);
-                        line.append(']');
+                        builder.append('[');
+                        builder.append(index);
+                        builder.append(']');
                     }
-                    line.append("  ");
-                    line.append(element.get());
-                    ps.println(line.toString());
+                    builder.append("  ");
+                    builder.append(element.get());
+                    builder.append("\n");
                 }
             }, true);
         }
+        return builder.toString();
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Tue Oct  5 12:32:01 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core;
 
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Map;
@@ -47,7 +46,6 @@ import org.apache.jackrabbit.core.state.
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.SessionItemStateManager;
-import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.version.VersionHistoryImpl;
 import org.apache.jackrabbit.core.version.VersionImpl;
 import org.apache.jackrabbit.core.security.AccessManager;
@@ -85,7 +83,7 @@ import org.slf4j.LoggerFactory;
  * If the parent <code>Session</code> is an <code>XASession</code>,
there is
  * one <code>ItemManager</code> instance per started global transaction.
  */
-public class ItemManager implements Dumpable, ItemStateListener {
+public class ItemManager implements ItemStateListener {
 
     private static Logger log = LoggerFactory.getLogger(ItemManager.class);
 
@@ -117,6 +115,7 @@ public class ItemManager implements Dump
      * @param sessionContext component context of the associated session
      * @param rootNodeDef the definition of the root node
      */
+    @SuppressWarnings("unchecked")
     protected ItemManager(SessionContext sessionContext) {
         this.sism = sessionContext.getItemStateManager();
         this.hierMgr = sessionContext.getHierarchyManager();
@@ -999,31 +998,31 @@ public class ItemManager implements Dump
         }
     }
 
-    //-------------------------------------------------------------< Dumpable >
+    //--------------------------------------------------------------< Object >
     /**
      * {@inheritDoc}
      */
-    public synchronized void dump(PrintStream ps) {
-        ps.println("ItemManager (" + this + ")");
-        ps.println();
-        ps.println("Items in cache:");
-        ps.println();
+    public synchronized String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("ItemManager (" + this + ")\n");
+        builder.append("Items in cache:\n");
         synchronized (itemCache) {
             for (ItemId id : itemCache.keySet()) {
                 ItemData item = itemCache.get(id);
                 if (item.isNode()) {
-                    ps.print("Node: ");
+                    builder.append("Node: ");
                 } else {
-                    ps.print("Property: ");
+                    builder.append("Property: ");
                 }
                 if (item.getState().isTransient()) {
-                    ps.print("transient ");
+                    builder.append("transient ");
                 } else {
-                    ps.print("          ");
+                    builder.append("          ");
                 }
-                ps.println(id + "\t" + safeGetJCRPath(id) + " (" + item + ")");
+                builder.append(id + "\t" + safeGetJCRPath(id) + " (" + item + ")\n");
             }
         }
+        return builder.toString();
     }
 
     //----------------------------------------------------< ItemStateListener >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Tue Oct  5 12:32:01 2010
@@ -23,7 +23,6 @@ import static org.apache.jackrabbit.core
 import static org.apache.jackrabbit.core.ItemValidator.CHECK_RETENTION;
 
 import java.io.File;
-import java.io.PrintStream;
 import java.security.AccessControlException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -85,7 +84,6 @@ import org.apache.jackrabbit.core.sessio
 import org.apache.jackrabbit.core.session.SessionRefreshOperation;
 import org.apache.jackrabbit.core.session.SessionSaveOperation;
 import org.apache.jackrabbit.core.state.SessionItemStateManager;
-import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.version.InternalVersionManager;
 import org.apache.jackrabbit.core.xml.ImportHandler;
 import org.apache.jackrabbit.core.xml.SessionImporter;
@@ -107,7 +105,7 @@ import org.xml.sax.ContentHandler;
  * A <code>SessionImpl</code> ...
  */
 public class SessionImpl extends AbstractSession
-        implements JackrabbitSession, NamespaceResolver, NamePathResolver, IdentifierResolver,
Dumpable {
+        implements JackrabbitSession, NamespaceResolver, NamePathResolver, IdentifierResolver
{
 
     /**
      * Name of the session attribute that controls whether the
@@ -169,6 +167,7 @@ public class SessionImpl extends Abstrac
     /**
      * Listeners (weak references)
      */
+    @SuppressWarnings("unchecked")
     protected final Map<SessionListener, SessionListener> listeners =
         new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
 
@@ -1192,24 +1191,6 @@ public class SessionImpl extends Abstrac
         return retentionManager;
     }
 
-    //-------------------------------------------------------------< Dumpable >
-    /**
-     * {@inheritDoc}
-     */
-    public void dump(PrintStream ps) {
-        ps.print("Session: ");
-        if (userId == null) {
-            ps.print("unknown");
-        } else {
-            ps.print(userId);
-        }
-        ps.println(" (" + this + ")");
-        ps.println();
-        context.getItemManager().dump(ps);
-        ps.println();
-        context.getItemStateManager().dump(ps);
-    }
-
     //--------------------------------------------------------------< Object >
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Tue Oct  5 12:32:01 2010
@@ -39,7 +39,6 @@ import org.apache.jackrabbit.core.state.
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
-import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
@@ -64,7 +63,6 @@ import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -75,8 +73,8 @@ import java.util.concurrent.TimeUnit;
 /**
  * Provides the functionality needed for locking and unlocking nodes.
  */
-public class LockManagerImpl implements LockManager, SynchronousEventListener,
-        LockEventListener, Dumpable {
+public class LockManagerImpl
+        implements LockManager, SynchronousEventListener, LockEventListener {
 
     /**
      * Logger
@@ -1397,28 +1395,27 @@ public class LockManagerImpl implements 
     }
 
     /**
-     * Dump contents of path map and elements included to <code>PrintStream</code>
given.
-     *
-     * @param ps print stream to dump to
+     * Dump contents of path map and elements included to a string.
      */
-    public void dump(final PrintStream ps) {
+    public String toString() {
+        final StringBuilder builder = new StringBuilder();
         lockMap.traverse(new PathMap.ElementVisitor<LockInfo>() {
             public void elementVisited(PathMap.Element<LockInfo> element) {
-                StringBuffer line = new StringBuffer();
                 for (int i = 0; i < element.getDepth(); i++) {
-                    line.append("--");
+                    builder.append("--");
                 }
-                line.append(element.getName());
+                builder.append(element.getName());
                 int index = element.getIndex();
                 if (index != 0 && index != 1) {
-                    line.append('[');
-                    line.append(index);
-                    line.append(']');
-                }
-                line.append("  ");
-                line.append(element.get());
-                ps.println(line.toString());
+                    builder.append('[');
+                    builder.append(index);
+                    builder.append(']');
+                }
+                builder.append("  ");
+                builder.append(element.get());
+                builder.append("\n");
             }
         }, true);
+        return builder.toString();
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/BitSetENTCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/BitSetENTCacheImpl.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/BitSetENTCacheImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/BitSetENTCacheImpl.java
Tue Oct  5 12:32:01 2010
@@ -16,13 +16,13 @@
  */
 package org.apache.jackrabbit.core.nodetype;
 
+import org.apache.jackrabbit.core.nodetype.EffectiveNodeTypeCache.Key;
 import org.apache.jackrabbit.spi.Name;
 
 import java.util.TreeSet;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.ArrayList;
-import java.io.PrintStream;
 
 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
 
@@ -50,12 +50,12 @@ public class BitSetENTCacheImpl implemen
     /**
      * An ordered set of the keys. This is used for {@link #findBest(Key)}.
      */
-    private final TreeSet sortedKeys;
+    private final TreeSet<Key> sortedKeys;
 
     /**
      * cache of pre-built aggregations of node types
      */
-    private final HashMap aggregates;
+    private final HashMap<Key, EffectiveNodeType> aggregates;
 
     /**
      * A lookup table for bit numbers for a given name.
@@ -75,8 +75,8 @@ public class BitSetENTCacheImpl implemen
      * Creates a new bitset effective node type cache
      */
     BitSetENTCacheImpl() {
-        sortedKeys = new TreeSet();
-        aggregates = new HashMap();
+        sortedKeys = new TreeSet<Key>();
+        aggregates = new HashMap<Key, EffectiveNodeType>();
     }
 
     /**
@@ -109,9 +109,9 @@ public class BitSetENTCacheImpl implemen
         if (contains(key)) {
             return key;
         }
-        Iterator iter = sortedKeys.iterator();
+        Iterator<Key> iter = sortedKeys.iterator();
         while (iter.hasNext()) {
-            Key k = (Key) iter.next();
+            Key k = iter.next();
             if (key.contains(k)) {
                 return k;
             }
@@ -127,9 +127,9 @@ public class BitSetENTCacheImpl implemen
          * remove all affected effective node types from aggregates cache
          * (copy keys first to prevent ConcurrentModificationException)
          */
-        ArrayList keys = new ArrayList(aggregates.keySet());
-        for (Iterator keysIter = keys.iterator(); keysIter.hasNext();) {
-            Key k = (Key) keysIter.next();
+        ArrayList<Key> keys = new ArrayList<Key>(aggregates.keySet());
+        for (Iterator<Key> keysIter = keys.iterator(); keysIter.hasNext();) {
+            Key k = keysIter.next();
             EffectiveNodeType ent = get(k);
             if (ent.includesNodeType(name)) {
                 remove(k);
@@ -148,7 +148,7 @@ public class BitSetENTCacheImpl implemen
      * {@inheritDoc}
      */
     public EffectiveNodeType get(Key key) {
-        return (EffectiveNodeType) aggregates.get(key);
+        return aggregates.get(key);
     }
 
     /**
@@ -196,7 +196,7 @@ public class BitSetENTCacheImpl implemen
      *         never cached.
      */
     private EffectiveNodeType remove(Key key) {
-        EffectiveNodeType removed = (EffectiveNodeType) aggregates.remove(key);
+        EffectiveNodeType removed = aggregates.remove(key);
         if (removed != null) {
             // other than the original implementation, the weights in the
             // treeset are now the same as in the given keys. so we can use
@@ -222,17 +222,15 @@ public class BitSetENTCacheImpl implemen
     /**
      * {@inheritDoc}
      */
-    public void dump(PrintStream ps) {
-        ps.println("EffectiveNodeTypeCache (" + this + ")");
-        ps.println();
-        ps.println("EffectiveNodeTypes in cache:");
-        ps.println();
-        Iterator iter = sortedKeys.iterator();
-        while (iter.hasNext()) {
-            Key k = (Key) iter.next();
-            //EffectiveNodeType ent = (EffectiveNodeType) aggregates.get(k);
-            ps.println(k);
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("EffectiveNodeTypeCache (" + this + ")\n");
+        builder.append("EffectiveNodeTypes in cache:\n");
+        for (Key key : sortedKeys) {
+            builder.append(key);
+            builder.append("\n");
         }
+        return builder.toString();
     }
 
     /**
@@ -397,7 +395,7 @@ public class BitSetENTCacheImpl implemen
          * This compares 1. the cardinality (number of set bits) and 2. the
          * numeric value of the bit sets in descending order.
          */
-        public int compareTo(Object other) {
+        public int compareTo(Key other) {
             BitSetKey o = (BitSetKey) other;
             int res = o.names.length - names.length;
             if (res == 0) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCache.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCache.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCache.java
Tue Oct  5 12:32:01 2010
@@ -16,14 +16,13 @@
  */
 package org.apache.jackrabbit.core.nodetype;
 
-import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
 
 /**
  * <code>EffectiveNodeTypeCache</code> defines the interface for a cache for
  * effective node types. Effective node types are addressed by {@link Key}s.
  */
-public interface EffectiveNodeTypeCache extends Cloneable, Dumpable {
+public interface EffectiveNodeTypeCache extends Cloneable {
 
     /**
      * Puts an effective node type to the cache. The key is internally generated
@@ -90,7 +89,7 @@ public interface EffectiveNodeTypeCache 
     * An <code>ENTKey</code> uniquely identifies
     * a combination (i.e. an aggregation) of one or more node types.
     */
-    interface Key extends Comparable {
+    interface Key extends Comparable<Key> {
 
         /**
          * Returns the node type names of this key.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCacheImpl.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCacheImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/EffectiveNodeTypeCacheImpl.java
Tue Oct  5 12:32:01 2010
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.core.nodet
 
 import org.apache.jackrabbit.spi.Name;
 
-import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
@@ -37,19 +36,19 @@ public class EffectiveNodeTypeCacheImpl 
     /**
      * ordered set of keys
      */
-    private final TreeSet sortedKeys;
+    private final TreeSet<Key> sortedKeys;
 
     /**
      * cache of pre-built aggregations of node types
      */
-    private final HashMap aggregates;
+    private final HashMap<Key, EffectiveNodeType> aggregates;
 
     /**
      * Creates a new effective node type cache.
      */
     EffectiveNodeTypeCacheImpl() {
-        sortedKeys = new TreeSet();
-        aggregates = new HashMap();
+        sortedKeys = new TreeSet<Key>();
+        aggregates = new HashMap<Key, EffectiveNodeType>();
     }
 
     /**
@@ -91,7 +90,7 @@ public class EffectiveNodeTypeCacheImpl 
      * {@inheritDoc}
      */
     public EffectiveNodeType get(Key key) {
-        return (EffectiveNodeType) aggregates.get(key);
+        return aggregates.get(key);
     }
 
     /**
@@ -101,16 +100,16 @@ public class EffectiveNodeTypeCacheImpl 
      *         never cached.
      */
     private EffectiveNodeType remove(Key key) {
-        EffectiveNodeType removed = (EffectiveNodeType) aggregates.remove(key);
+        EffectiveNodeType removed = aggregates.remove(key);
         if (removed != null) {
             // remove index entry
 
             // FIXME: can't simply call TreeSet.remove(key) because the entry
             // in sortedKeys might have a different weight and would thus
             // not be found
-            Iterator iter = sortedKeys.iterator();
+            Iterator<Key> iter = sortedKeys.iterator();
             while (iter.hasNext()) {
-                Key k = (Key) iter.next();
+                Key k = iter.next();
                 // WeightedKey.equals(Object) ignores the weight
                 if (key.equals(k)) {
                     sortedKeys.remove(k);
@@ -127,9 +126,9 @@ public class EffectiveNodeTypeCacheImpl 
     public void invalidate(Name name) {
         // remove all affected effective node types from aggregates cache
         // (copy keys first to prevent ConcurrentModificationException)
-        ArrayList keys = new ArrayList(sortedKeys);
-        for (Iterator keysIter = keys.iterator(); keysIter.hasNext();) {
-            Key k = (Key) keysIter.next();
+        ArrayList<Key> keys = new ArrayList<Key>(sortedKeys);
+        for (Iterator<Key> keysIter = keys.iterator(); keysIter.hasNext();) {
+            Key k = keysIter.next();
             EffectiveNodeType ent = get(k);
             if (ent.includesNodeType(name)) {
                 remove(k);
@@ -145,9 +144,9 @@ public class EffectiveNodeTypeCacheImpl 
         if (contains(key)) {
             return key;
         }
-        Iterator iter = sortedKeys.iterator();
+        Iterator<Key> iter = sortedKeys.iterator();
         while (iter.hasNext()) {
-            Key k = (Key) iter.next();
+            Key k = iter.next();
             // check if the existing aggregate is a 'subset' of the one we're
             // looking for
             if (key.contains(k)) {
@@ -169,22 +168,20 @@ public class EffectiveNodeTypeCacheImpl 
         return clone;
     }
 
-    //-------------------------------------------------------------< Dumpable >
+    //--------------------------------------------------------------< Object >
 
     /**
      * {@inheritDoc}
      */
-    public void dump(PrintStream ps) {
-        ps.println("EffectiveNodeTypeCache (" + this + ")");
-        ps.println();
-        ps.println("EffectiveNodeTypes in cache:");
-        ps.println();
-        Iterator iter = sortedKeys.iterator();
-        while (iter.hasNext()) {
-            Key k = (Key) iter.next();
-            //EffectiveNodeType ent = (EffectiveNodeType) aggregates.get(k);
-            ps.println(k);
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("EffectiveNodeTypeCache (" + this + ")\n");
+        builder.append("EffectiveNodeTypes in cache:\n");
+        for (Key key : sortedKeys) {
+            builder.append(key);
+            builder.append("\n");
         }
+        return builder.toString();
     }
 
     //--------------------------------------------------------< inner classes >
@@ -248,7 +245,7 @@ public class EffectiveNodeTypeCacheImpl 
         /**
          * @param ntNames
          */
-        WeightedKey(Collection ntNames) {
+        WeightedKey(Collection<Name> ntNames) {
             this(ntNames, ntNames.size());
         }
 
@@ -272,7 +269,7 @@ public class EffectiveNodeTypeCacheImpl 
          */
         public boolean contains(Key otherKey) {
             WeightedKey key = (WeightedKey) otherKey;
-            Set tmp = new HashSet(Arrays.asList(names));
+            Set<Name> tmp = new HashSet<Name>(Arrays.asList(names));
             for (int i = 0; i < key.names.length; i++) {
                 if (!tmp.contains(key.names[i])) {
                     return false;
@@ -286,7 +283,7 @@ public class EffectiveNodeTypeCacheImpl 
          */
         public Key subtract(Key otherKey) {
             WeightedKey key = (WeightedKey) otherKey;
-            Set tmp = new HashSet(Arrays.asList(names));
+            Set<Name> tmp = new HashSet<Name>(Arrays.asList(names));
             tmp.removeAll(Arrays.asList(key.names));
             return new WeightedKey(tmp);
 
@@ -300,7 +297,7 @@ public class EffectiveNodeTypeCacheImpl 
          * @param o the other key to compare
          * @return the result of the comparison
          */
-        public int compareTo(Object o) {
+        public int compareTo(Key o) {
             WeightedKey other = (WeightedKey) o;
 
             // compare weights

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
Tue Oct  5 12:32:01 2010
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.core.nodet
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -50,7 +49,6 @@ import org.apache.jackrabbit.commons.cnd
 import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
 import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
 import org.apache.jackrabbit.core.session.SessionContext;
-import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
@@ -72,7 +70,7 @@ import org.xml.sax.SAXException;
  * NodeTypeManager.
  */
 public class NodeTypeManagerImpl extends AbstractNodeTypeManager
-        implements JackrabbitNodeTypeManager, Dumpable, NodeTypeRegistryListener {
+        implements JackrabbitNodeTypeManager, NodeTypeRegistryListener {
 
     /**
      * Component context of the current session.
@@ -231,7 +229,7 @@ public class NodeTypeManagerImpl extends
 
                     Properties namespaces = ntr.getNamespaces();
                     if (namespaces != null) {
-                        Enumeration prefixes = namespaces.propertyNames();
+                        Enumeration<?> prefixes = namespaces.propertyNames();
                         while (prefixes.hasMoreElements()) {
                             String prefix = (String) prefixes.nextElement();
                             String uri = namespaces.getProperty(prefix);
@@ -320,18 +318,18 @@ public class NodeTypeManagerImpl extends
         // flush all affected cache entries
         ntCache.remove(ntName);
         synchronized (pdCache) {
-            Iterator iter = pdCache.values().iterator();
+            Iterator<PropertyDefinitionImpl> iter = pdCache.values().iterator();
             while (iter.hasNext()) {
-                PropertyDefinitionImpl pd = (PropertyDefinitionImpl) iter.next();
+                PropertyDefinitionImpl pd = iter.next();
                 if (ntName.equals(pd.unwrap().getDeclaringNodeType())) {
                     iter.remove();
                 }
             }
         }
         synchronized (ndCache) {
-            Iterator iter = ndCache.values().iterator();
+            Iterator<NodeDefinitionImpl> iter = ndCache.values().iterator();
             while (iter.hasNext()) {
-                NodeDefinitionImpl nd = (org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl)
iter.next();
+                NodeDefinitionImpl nd = iter.next();
                 if (ntName.equals(nd.unwrap().getDeclaringNodeType())) {
                     iter.remove();
                 }
@@ -633,14 +631,14 @@ public class NodeTypeManagerImpl extends
         return new QNodeTypeDefinitionImpl(definition, context, QValueFactoryImpl.getInstance());
     }
 
-    //-------------------------------------------------------------< Dumpable >
+    //--------------------------------------------------------------< Object >
+
     /**
      * {@inheritDoc}
      */
-    public void dump(PrintStream ps) {
-        ps.println("NodeTypeManager (" + this + ")");
-        ps.println();
-        context.getNodeTypeRegistry().dump(ps);
+    public String toString() {
+        return "NodeTypeManager(" + this + ")\n"
+            + context.getNodeTypeRegistry();
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Tue Oct  5 12:32:01 2010
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.io.PrintStream;
 import java.io.Reader;
 import java.util.Arrays;
 import java.util.Collection;
@@ -48,7 +47,6 @@ import org.apache.jackrabbit.core.cluste
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
-import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.QValue;
@@ -68,7 +66,7 @@ import EDU.oswego.cs.dl.util.concurrent.
 /**
  * A <code>NodeTypeRegistry</code> ...
  */
-public class NodeTypeRegistry implements Dumpable, NodeTypeEventListener {
+public class NodeTypeRegistry implements NodeTypeEventListener {
 
     private static Logger log = LoggerFactory.getLogger(NodeTypeRegistry.class);
 
@@ -107,6 +105,7 @@ public class NodeTypeRegistry implements
     /**
      * Listeners (soft references)
      */
+    @SuppressWarnings("unchecked")
     private final Map<NodeTypeRegistryListener, NodeTypeRegistryListener> listeners
=
             Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
 
@@ -566,32 +565,31 @@ public class NodeTypeRegistry implements
         listeners.remove(listener);
     }
 
-    //-------------------------------------------------------------< Dumpable >
+    //--------------------------------------------------------------< Object >
+
     /**
      * {@inheritDoc}
      */
-    public void dump(PrintStream ps) {
-        ps.println("NodeTypeRegistry (" + this + ")");
-        ps.println();
-        ps.println("Registered NodeTypes:");
-        ps.println();
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("NodeTypeRegistry (" + this + ")\n");
+        builder.append("Registered NodeTypes:\n");
         for (QNodeTypeDefinition ntd : registeredNTDefs.values()) {
-            ps.println(ntd.getName());
-            Name[] supertypes = ntd.getSupertypes();
-            ps.println("\tSupertypes");
-            for (Name supertype : supertypes) {
-                ps.println("\t\t" + supertype);
-            }
-            ps.println("\tMixin\t" + ntd.isMixin());
-            ps.println("\tOrderableChildNodes\t" + ntd.hasOrderableChildNodes());
-            ps.println("\tPrimaryItemName\t" + (ntd.getPrimaryItemName() == null ? "<null>"
: ntd.getPrimaryItemName().toString()));
+            builder.append(ntd.getName());
+            builder.append("\n");
+            builder.append(
+                    "\tSupertypes: "
+                    + Arrays.toString(ntd.getSupertypes()) + "\n");
+            builder.append("\tMixin\t" + ntd.isMixin() + "\n");
+            builder.append("\tOrderableChildNodes\t" + ntd.hasOrderableChildNodes() + "\n");
+            builder.append("\tPrimaryItemName\t" + (ntd.getPrimaryItemName() == null ? "<null>"
: ntd.getPrimaryItemName().toString()) + "\n");
             QPropertyDefinition[] pd = ntd.getPropertyDefs();
             for (QPropertyDefinition aPd : pd) {
-                ps.print("\tPropertyDefinition");
-                ps.println(" (declared in " + aPd.getDeclaringNodeType() + ")");
-                ps.println("\t\tName\t\t" + (aPd.definesResidual() ? "*" : aPd.getName().toString()));
+                builder.append("\tPropertyDefinition\n");
+                builder.append(" (declared in " + aPd.getDeclaringNodeType() + ")\n");
+                builder.append("\t\tName\t\t" + (aPd.definesResidual() ? "*" : aPd.getName().toString())
+ "\n");
                 String type = aPd.getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(aPd.getRequiredType());
-                ps.println("\t\tRequiredType\t" + type);
+                builder.append("\t\tRequiredType\t" + type + "\n");
                 QValueConstraint[] vca = aPd.getValueConstraints();
                 StringBuffer constraints = new StringBuffer();
                 if (vca == null) {
@@ -604,7 +602,7 @@ public class NodeTypeRegistry implements
                         constraints.append(aVca.getString());
                     }
                 }
-                ps.println("\t\tValueConstraints\t" + constraints.toString());
+                builder.append("\t\tValueConstraints\t" + constraints + "\n");
                 QValue[] defVals = aPd.getDefaultValues();
                 StringBuffer defaultValues = new StringBuffer();
                 if (defVals == null) {
@@ -617,38 +615,37 @@ public class NodeTypeRegistry implements
                         defaultValues.append(defVal.toString());
                     }
                 }
-                ps.println("\t\tDefaultValue\t" + defaultValues.toString());
-                ps.println("\t\tAutoCreated\t" + aPd.isAutoCreated());
-                ps.println("\t\tMandatory\t" + aPd.isMandatory());
-                ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aPd.getOnParentVersion()));
-                ps.println("\t\tProtected\t" + aPd.isProtected());
-                ps.println("\t\tMultiple\t" + aPd.isMultiple());
+                builder.append("\t\tDefaultValue\t" + defaultValues + "\n");
+                builder.append("\t\tAutoCreated\t" + aPd.isAutoCreated() + "\n");
+                builder.append("\t\tMandatory\t" + aPd.isMandatory() + "\n");
+                builder.append("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aPd.getOnParentVersion())
+ "\n");
+                builder.append("\t\tProtected\t" + aPd.isProtected() + "\n");
+                builder.append("\t\tMultiple\t" + aPd.isMultiple() + "\n");
             }
             QNodeDefinition[] nd = ntd.getChildNodeDefs();
             for (QNodeDefinition aNd : nd) {
-                ps.print("\tNodeDefinition");
-                ps.println(" (declared in " + aNd.getDeclaringNodeType() + ")");
-                ps.println("\t\tName\t\t" + (aNd.definesResidual() ? "*" : aNd.getName().toString()));
+                builder.append("\tNodeDefinition\\n");
+                builder.append(" (declared in " + aNd.getDeclaringNodeType() + ")\\n");
+                builder.append("\t\tName\t\t" + (aNd.definesResidual() ? "*" : aNd.getName().toString())
+ "\n");
                 Name[] reqPrimaryTypes = aNd.getRequiredPrimaryTypes();
                 if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0) {
                     for (Name reqPrimaryType : reqPrimaryTypes) {
-                        ps.print("\t\tRequiredPrimaryType\t" + reqPrimaryType);
+                        builder.append("\t\tRequiredPrimaryType\t" + reqPrimaryType + "\n");
                     }
                 }
                 Name defPrimaryType = aNd.getDefaultPrimaryType();
                 if (defPrimaryType != null) {
-                    ps.print("\n\t\tDefaultPrimaryType\t" + defPrimaryType);
+                    builder.append("\n\t\tDefaultPrimaryType\t" + defPrimaryType + "\n");
                 }
-                ps.println("\n\t\tAutoCreated\t" + aNd.isAutoCreated());
-                ps.println("\t\tMandatory\t" + aNd.isMandatory());
-                ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aNd.getOnParentVersion()));
-                ps.println("\t\tProtected\t" + aNd.isProtected());
-                ps.println("\t\tAllowsSameNameSiblings\t" + aNd.allowsSameNameSiblings());
+                builder.append("\n\t\tAutoCreated\t" + aNd.isAutoCreated() + "\n");
+                builder.append("\t\tMandatory\t" + aNd.isMandatory() + "\n");
+                builder.append("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aNd.getOnParentVersion())
+ "\n");
+                builder.append("\t\tProtected\t" + aNd.isProtected() + "\n");
+                builder.append("\t\tAllowsSameNameSiblings\t" + aNd.allowsSameNameSiblings()
+ "\n");
             }
         }
-        ps.println();
-
-        entCache.dump(ps);
+        builder.append(entCache);
+        return builder.toString();
     }
 
     //------------------------------------------------< NodeTypeEventListener >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Tue Oct  5 12:32:01 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core.state;
 
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -38,7 +37,6 @@ import org.apache.jackrabbit.core.Zombie
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
-import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,7 +45,7 @@ import org.slf4j.LoggerFactory;
  * Item state manager that handles both transient and persistent items.
  */
 public class SessionItemStateManager
-        implements UpdatableItemStateManager, Dumpable, NodeStateListener {
+        implements UpdatableItemStateManager, NodeStateListener {
 
     private static Logger log = LoggerFactory.getLogger(SessionItemStateManager.class);
 
@@ -119,28 +117,19 @@ public class SessionItemStateManager
         return new ZombieHierarchyManager(hierMgr, this, getAttic());
     }
 
-    //-------------------------------------------------------------< Dumpable >
+    //--------------------------------------------------------------< Object >
 
     /**
      * {@inheritDoc}
      */
-    public void dump(PrintStream ps) {
-        ps.println("SessionItemStateManager (" + this + ")");
-        ps.println();
-        ps.print("[transient] ");
-        if (transientStore instanceof Dumpable) {
-            ((Dumpable) transientStore).dump(ps);
-        } else {
-            ps.println(transientStore.toString());
-        }
-        ps.println();
-        ps.print("[attic]     ");
-        if (atticStore instanceof Dumpable) {
-            ((Dumpable) atticStore).dump(ps);
-        } else {
-            ps.println(atticStore.toString());
-        }
-        ps.println();
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("SessionItemStateManager (" + this + ")\n");
+        builder.append("[transient]\n");
+        builder.append(transientStore);
+        builder.append("[attic]\n");
+        builder.append(atticStore);
+        return builder.toString();
     }
 
     //-----------------------------------------------------< ItemStateManager >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=1004622&r1=1004621&r2=1004622&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Tue Oct  5 12:32:01 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core.state;
 
-import java.io.PrintStream;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Set;
@@ -39,7 +38,6 @@ import org.apache.jackrabbit.core.observ
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
 import org.apache.jackrabbit.core.persistence.CachingPersistenceManager;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
-import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.spi.Name;
@@ -110,7 +108,7 @@ import org.slf4j.LoggerFactory;
  * virtual node type representation don't allow such references.
  */
 public class SharedItemStateManager
-        implements ItemStateManager, ItemStateListener, Dumpable {
+        implements ItemStateManager, ItemStateListener {
 
     /**
      * Logger instance
@@ -435,17 +433,14 @@ public class SharedItemStateManager
         dispatcher.notifyStateDiscarded(discarded);
     }
 
-    //-------------------------------------------------------------< Dumpable >
+    //--------------------------------------------------------------< Object >
+
     /**
      * {@inheritDoc}
      */
-    public void dump(PrintStream ps) {
-        ps.println("SharedItemStateManager (" + this + ")");
-        if (cache instanceof Dumpable) {
-            ps.println();
-            ps.print("[referenceCache] ");
-            ((Dumpable) cache).dump(ps);
-        }
+    public String toString() {
+        return "SharedItemStateManager (" + this + ")\n"
+            + "[referenceCache]\n" + cache;
     }
 
     //-------------------------------------------------< misc. public methods >



Mime
View raw message