jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r641301 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype: BitsetENTCacheImpl.java EffectiveNodeTypeCache.java
Date Wed, 26 Mar 2008 13:35:47 GMT
Author: angela
Date: Wed Mar 26 06:35:45 2008
New Revision: 641301

URL: http://svn.apache.org/viewvc?rev=641301&view=rev
Log:
minor cleanup, javadoc and improved class structuring

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java?rev=641301&r1=641300&r2=641301&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
Wed Mar 26 06:35:45 2008
@@ -79,22 +79,23 @@
         aggregates = new HashMap();
     }
 
+    //---------------------------------------------< EffectiveNodeTypeCache >---
     /**
-     * {@inheritDoc}
+     * @see EffectiveNodeTypeCache#getKey(Name[])
      */
     public Key getKey(Name[] ntNames) {
         return new BitsetKey(ntNames, nameIndex.size() + ntNames.length);
     }
 
     /**
-     * {@inheritDoc}
+     * @see EffectiveNodeTypeCache#put(EffectiveNodeType)
      */
     public void put(EffectiveNodeType ent) {
         put(getKey(ent.getMergedNodeTypes()), ent);
     }
 
     /**
-     * {@inheritDoc}
+     * @see EffectiveNodeTypeCache#put(Key, EffectiveNodeType)
      */
     public void put(Key key, EffectiveNodeType ent) {
         aggregates.put(key, ent);
@@ -102,7 +103,7 @@
     }
 
     /**
-     * {@inheritDoc}
+     * @see EffectiveNodeTypeCache#findBest(Key)
      */
     public Key findBest(Key key) {
         // quick check for already cached key
@@ -120,7 +121,7 @@
     }
 
     /**
-     * {@inheritDoc}
+     * @see EffectiveNodeTypeCache#invalidate(Name)
      */
     public void invalidate(Name name) {
         /**
@@ -138,21 +139,21 @@
     }
 
     /**
-     * {@inheritDoc}
+     * @see EffectiveNodeTypeCache#contains(Key)
      */
     public boolean contains(Key key) {
         return aggregates.containsKey(key);
     }
 
     /**
-     * {@inheritDoc}
+     * @see EffectiveNodeTypeCache#get(Key)
      */
     public EffectiveNodeType get(Key key) {
         return (EffectiveNodeType) aggregates.get(key);
     }
 
     /**
-     * {@inheritDoc}
+     * @see EffectiveNodeTypeCache#clear()
      */
     public void clear() {
         sortedKeys.clear();
@@ -160,6 +161,7 @@
         nameIndex.clear();
     }
 
+    //------------------------------------------------------------< private >---
     /**
      * Returns the bit number for the given name. If the name does not exist
      * a new new bit number for that name is created.
@@ -215,8 +217,9 @@
         return removed;
     }
 
+    //----------------------------------------------------------< Cloneable >---
     /**
-     * {@inheritDoc}
+     * @see Cloneable#clone()
      */
     public Object clone() {
         BitsetENTCacheImpl clone = new BitsetENTCacheImpl();
@@ -228,8 +231,9 @@
         return clone;
     }
 
+    //-----------------------------------------------------------< Dumpable >---
     /**
-     * {@inheritDoc}
+     * @see org.apache.jackrabbit.jcr2spi.util.Dumpable#dump(PrintStream)
      */
     public void dump(PrintStream ps) {
         ps.println("EffectiveNodeTypeCache (" + this + ")");
@@ -244,6 +248,7 @@
         }
     }
 
+    //----------------------------------------------------------------< Key >---
     /**
      * Implements a {@link Key} by storing the node type aggregate information
      * in a bit set. We do not use the {@link java.util.BitSet} because it
@@ -301,14 +306,76 @@
         }
 
         /**
-         * {@inheritDoc}
+         * Returns the bit number of the next bit that is set, starting at
+         * <code>fromIndex</code> inclusieve.
+         *
+         * @param fromIndex the bit position to start the search
+         * @return the bit position of the bit or -1 if none found.
+         */
+        private int nextSetBit(int fromIndex) {
+            int addr = fromIndex/BPW;
+            int off = fromIndex%BPW;
+            while (addr < bits.length) {
+                if (bits[addr] != 0) {
+                    while (off < BPW) {
+                        if ((bits[addr] & OR_MASK[off]) != 0) {
+                            return addr * BPW + off;
+                        }
+                        off++;
+                    }
+                    off=0;
+                }
+                addr++;
+            }
+            return -1;
+        }
+
+         /**
+          * Returns the number of bits set in val.
+          * For a derivation of this algorithm, see
+          * "Algorithms and data structures with applications to
+          *  graphics and geometry", by Jurg Nievergelt and Klaus Hinrichs,
+          *  Prentice Hall, 1993.
+          *
+          * @param val the value to calculate the bit count for
+          * @return the number of '1' bits in the value
+          */
+         private int bitCount(long val) {
+             val -= (val & 0xaaaaaaaaaaaaaaaaL) >>> 1;
+             val =  (val & 0x3333333333333333L) + ((val >>> 2) & 0x3333333333333333L);
+             val =  (val + (val >>> 4)) & 0x0f0f0f0f0f0f0f0fL;
+             val += val >>> 8;
+             val += val >>> 16;
+             return ((int)(val) + (int)(val >>> 32)) & 0xff;
+         }
+
+        /**
+         * Calculates the hashcode.
+         * @return the calculated hashcode
+         */
+        private int calcHashCode() {
+            long h = 1234;
+            int addr = bits.length -1;
+            while (addr >=0 && bits[addr] == 0) {
+                addr--;
+            }
+            while (addr >=0) {
+                h ^= bits[addr] * (addr + 1);
+                addr--;
+            }
+            return (int)((h >> 32) ^ h);
+        }
+
+        //------------------------------------------------------------< Key >---
+        /**
+         * @see Key#getNames()
          */
         public Name[] getNames() {
             return names;
         }
 
         /**
-         * {@inheritDoc}
+         * @see Key#contains(Key)
          */
         public boolean contains(Key otherKey) {
             /*
@@ -332,7 +399,7 @@
         }
 
         /**
-         * {@inheritDoc}
+         * @see Key#subtract(Key)
          */
         public Key subtract(Key otherKey) {
             /*
@@ -355,56 +422,14 @@
             return new BitsetKey(newBits, numBits);
         }
 
-        /**
-         * Returns the bit number of the next bit that is set, starting at
-         * <code>fromIndex</code> inclusieve.
-         *
-         * @param fromIndex the bit position to start the search
-         * @return the bit position of the bit or -1 if none found.
-         */
-        private int nextSetBit(int fromIndex) {
-            int addr = fromIndex/BPW;
-            int off = fromIndex%BPW;
-            while (addr < bits.length) {
-                if (bits[addr] != 0) {
-                    while (off < BPW) {
-                        if ((bits[addr] & OR_MASK[off]) != 0) {
-                            return addr * BPW + off;
-                        }
-                        off++;
-                    }
-                    off=0;
-                }
-                addr++;
-            }
-            return -1;
-        }
-
-         /**
-          * Returns the number of bits set in val.
-          * For a derivation of this algorithm, see
-          * "Algorithms and data structures with applications to
-          *  graphics and geometry", by Jurg Nievergelt and Klaus Hinrichs,
-          *  Prentice Hall, 1993.
-          *
-          * @param val the value to calculate the bit count for
-          * @return the number of '1' bits in the value
-          */
-         private int bitCount(long val) {
-             val -= (val & 0xaaaaaaaaaaaaaaaaL) >>> 1;
-             val =  (val & 0x3333333333333333L) + ((val >>> 2) & 0x3333333333333333L);
-             val =  (val + (val >>> 4)) & 0x0f0f0f0f0f0f0f0fL;
-             val += val >>> 8;
-             val += val >>> 16;
-             return ((int)(val) + (int)(val >>> 32)) & 0xff;
-         }
-
-
+        //-----------------------------------------------------< Comparable >---
         /**
          * {@inheritDoc}
          *
          * This compares 1. the cardinailty (number of set bits) and 2. the
          * nummeric value of the bitsets in descending order.
+         *
+         * @see Comparable#compareTo(Object)
          */
         public int compareTo(Object other) {
             BitsetKey o = (BitsetKey) other;
@@ -430,8 +455,9 @@
             return res;
         }
 
+        //---------------------------------------------------------< Object >---
         /**
-         * {@inheritDoc}
+         * @see Object#equals(Object)
          */
         public boolean equals(Object obj) {
             if (this == obj) {
@@ -457,31 +483,14 @@
         }
 
         /**
-         * {@inheritDoc}
+         * @see Object#hashCode()
          */
         public int hashCode() {
             return hashCode;
         }
 
         /**
-         * Calculates the hashcode.
-         * @return the calculated hashcode
-         */
-        private int calcHashCode() {
-            long h = 1234;
-            int addr = bits.length -1;
-            while (addr >=0 && bits[addr] == 0) {
-                addr--;
-            }
-            while (addr >=0) {
-                h ^= bits[addr] * (addr + 1);
-                addr--;
-            }
-            return (int)((h >> 32) ^ h);
-        }
-
-        /**
-         * {@inheritDoc}
+         * @see Object#toString()
          */
         public String toString() {
             StringBuffer buf = new StringBuffer("w=");
@@ -494,6 +503,5 @@
             }
             return buf.toString();
         }
-
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java?rev=641301&r1=641300&r2=641301&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java
Wed Mar 26 06:35:45 2008
@@ -71,11 +71,6 @@
     void invalidate(Name name);
 
     /**
-     * {@inheritDoc}
-     */
-    Object clone();
-
-    /**
      * Searches the best key k for which the given <code>key</code> is a super
      * set, i.e. for which {@link Key#contains(Key)}} returns
      * <code>true</code>. If an already cached effective node type matches the
@@ -124,6 +119,5 @@
          * @return the new key of the subtraction operation.
          */
         Key subtract(Key otherKey);
-
     }
 }



Mime
View raw message