You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2006/07/24 12:34:46 UTC

svn commit: r424999 [1/2] - in /xmlgraphics/batik/branches/anim/sources/org/apache/batik: ./ css/engine/ css/engine/value/ dom/ dom/svg/ dom/util/ ext/awt/image/renderable/ ext/awt/image/rendered/ gvt/font/ swing/gvt/ util/

Author: cam
Date: Mon Jul 24 03:34:44 2006
New Revision: 424999

URL: http://svn.apache.org/viewvc?rev=424999&view=rev
Log:
1. Merged trunk changes r416564:424971 into anim branch.

Modified:
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/Version.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/CSSEngine.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/StringIntMap.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/StringMap.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/AbstractElement.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractElement.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DocumentDescriptor.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DoublyIndexedTable.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/HashTable.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/IntTable.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/TriplyIndexedTable.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/ext/awt/image/renderable/AbstractRable.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/ext/awt/image/rendered/AbstractRed.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/gvt/font/AWTGlyphGeometryCache.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java
    xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SoftDoublyIndexedTable.java

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/Version.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/Version.java?rev=424999&r1=424998&r2=424999&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/Version.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/Version.java Mon Jul 24 03:34:44 2006
@@ -39,20 +39,20 @@
      *   <tr>
      *     <th>Source</th>
      *     <th>Version string</th>
-     *   </tr>
      *   <tr>
+     *   </tr>
      *     <td>Release version</td>
      *     <td><em>version</em></td>
-     *   </tr>
      *   <tr>
+     *   </tr>
      *     <td>Trunk</td>
      *     <td>SVN+<em>yyyymmdd</em></td>
-     *   </tr>
      *   <tr>
+     *   </tr>
      *     <td>Branch</td>
      *     <td><em>branch-name</em> branch; SVN+<em>yyyymmdd</em></td>
      *   </tr>
-     *   <tr>
+     *   </tr>
      *     <td>Unknown</td>
      *     <td>development version</td>
      *   </tr>

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/CSSEngine.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/CSSEngine.java?rev=424999&r1=424998&r2=424999&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/CSSEngine.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/CSSEngine.java Mon Jul 24 03:34:44 2006
@@ -2290,6 +2290,24 @@
     }
 
     /**
+     * Returns whether the DOM subtree rooted at the specified node
+     * contains a {@link CSSStyleSheetNode}.
+     */
+    protected boolean hasStyleSheetNode(Node n) {
+        if (n instanceof CSSStyleSheetNode) {
+            return true;
+        }
+        n = getCSSFirstChild(n);
+        while (n != null) {
+            if (hasStyleSheetNode(n)) {
+                return true;
+            }
+            n = getCSSNextSibling(n);
+        }
+        return false;
+    }
+
+    /**
      * Handles an attribute change in the document.
      */
     protected void handleAttrModified(Element e,
@@ -2307,15 +2325,13 @@
         }
 
         String attrNS = attr.getNamespaceURI();
-        String name   = ((attrNS == null) ?
-                         attr.getNodeName() :
-                         attr.getLocalName());
+        String name = attrNS == null ? attr.getNodeName() : attr.getLocalName();
 
-        CSSStylableElement elt = (CSSStylableElement)e;
+        CSSStylableElement elt = (CSSStylableElement) e;
         StyleMap style = elt.getComputedStyleMap(null);
         if (style != null) {
-            if ((attrNS == styleNamespaceURI) ||
-                ((attrNS != null) && attrNS.equals(styleNamespaceURI))) {
+            if (attrNS == styleNamespaceURI
+                    || attrNS != null && attrNS.equals(styleNamespaceURI)) {
                 if (name.equals(styleLocalName)) {
                     // The style declaration attribute has been modified.
                     inlineStyleAttributeUpdated
@@ -2325,9 +2341,9 @@
             }
 
             if (nonCSSPresentationalHints != null) {
-                if ((attrNS == nonCSSPresentationalHintsNamespaceURI) ||
-                    ((attrNS != null) &&
-                     attrNS.equals(nonCSSPresentationalHintsNamespaceURI))) {
+                if (attrNS == nonCSSPresentationalHintsNamespaceURI ||
+                        attrNS != null &&
+                        attrNS.equals(nonCSSPresentationalHintsNamespaceURI)) {
                     if (nonCSSPresentationalHints.contains(name)) {
                         // The 'name' attribute which represents a non CSS
                         // presentational hint has been modified.
@@ -2353,6 +2369,78 @@
     }
 
     /**
+     * Handles a node insertion in the document.
+     */
+    protected void handleNodeInserted(Node n) {
+        if (hasStyleSheetNode(n)) {
+            // Invalidate all the CSSStylableElements in the document.
+            styleSheetNodes = null;
+            invalidateProperties(document.getDocumentElement(),
+                                 null, null, true);
+        } else if (n instanceof CSSStylableElement) {
+            // Invalidate the CSSStylableElement siblings, to correctly
+            // match the adjacent selectors and first-child pseudo-class.
+            n = getCSSNextSibling(n);
+            while (n != null) {
+                invalidateProperties(n, null, null, true);
+                n = getCSSNextSibling(n);
+            }
+        }
+    }
+
+    /**
+     * Handles a node removal from the document.
+     */
+    protected void handleNodeRemoved(Node n) {
+        if (hasStyleSheetNode(n)) {
+            // Wait for the DOMSubtreeModified to do the invalidations
+            // because at this time the node is in the tree.
+            styleSheetRemoved = true;
+        } else if (n instanceof CSSStylableElement) {
+            // Wait for the DOMSubtreeModified to do the invalidations
+            // because at this time the node is in the tree.
+            removedStylableElementSibling = getCSSNextSibling(n);
+        }
+        // Clears the computed styles in the removed tree.
+        disposeStyleMaps(n);
+    }
+
+    /**
+     * Handles a subtree modification in the document.
+     */
+    protected void handleSubtreeModified(Node n) {
+        if (styleSheetRemoved) {
+            // Invalidate all the CSSStylableElements in the document.
+            styleSheetRemoved = false;
+            styleSheetNodes = null;
+            invalidateProperties(document.getDocumentElement(),
+                                 null, null, true);
+        } else if (removedStylableElementSibling != null) {
+            // Invalidate the CSSStylableElement siblings, to
+            // correctly match the adjacent selectors and
+            // first-child pseudo-class.
+            n = removedStylableElementSibling;
+            while (n != null) {
+                invalidateProperties(n, null, null, true);
+                n = getCSSNextSibling(n);
+            }
+            removedStylableElementSibling = null;
+        }
+    }
+
+    /**
+     * Handles a character data modification in the document.
+     */
+    protected void handleCharacterDataModified(Node n) {
+        if (getCSSParentNode(n) instanceof CSSStyleSheetNode) {
+            // Invalidate all the CSSStylableElements in the document.
+            styleSheetNodes = null;
+            invalidateProperties(document.getDocumentElement(),
+                                 null, null, true);
+        }
+    }
+
+    /**
      * To handle mutations of a CSSNavigableDocument.
      */
     protected class CSSNavigableDocumentHandler
@@ -2374,38 +2462,14 @@
          * A node has been inserted into the CSSNavigableDocument tree.
          */
         public void nodeInserted(Node newNode) {
-            if (newNode instanceof CSSStyleSheetNode) {
-                styleSheetNodes = null;
-                // Invalidate all the CSSStylableElements in the document.
-                invalidateProperties(document.getDocumentElement(),
-                                     null, null, true);
-            } else if (newNode instanceof CSSStylableElement) {
-                // Invalidate the CSSStylableElement siblings, to
-                // correctly match the adjacent selectors and
-                // first-child pseudo-class.
-                for (Node n = getCSSNextSibling(newNode);
-                     n != null;
-                     n = getCSSNextSibling(n)) {
-                    invalidateProperties(n, null, null, true);
-                }
-            }
+            handleNodeInserted(newNode);
         }
 
         /**
          * A node is about to be removed from the CSSNavigableDocument tree.
          */
         public void nodeToBeRemoved(Node oldNode) {
-            if (oldNode instanceof CSSStyleSheetNode) {
-                // Wait for the DOMSubtreeModified to do the invalidations
-                // because at this time the node is in the tree.
-                styleSheetRemoved = true;
-            } else if (oldNode instanceof CSSStylableElement) {
-                // Wait for the DOMSubtreeModified to do the invalidations
-                // because at this time the node is in the tree.
-                removedStylableElementSibling = getCSSNextSibling(oldNode);
-            }
-            // Clears the computed styles in the removed tree.
-            disposeStyleMaps(oldNode);
+            handleNodeRemoved(oldNode);
         }
 
         /**
@@ -2413,36 +2477,14 @@
          * in some way.
          */
         public void subtreeModified(Node rootOfModifications) {
-            if (styleSheetRemoved) {
-                styleSheetRemoved = false;
-                styleSheetNodes = null;
-
-                // Invalidate all the CSSStylableElements in the document.
-                invalidateProperties(document.getDocumentElement(),
-                                     null, null, true);
-            } else if (removedStylableElementSibling != null) {
-                // Invalidate the CSSStylableElement siblings, to
-                // correctly match the adjacent selectors and
-                // first-child pseudo-class.
-                for (Node n = removedStylableElementSibling;
-                     n != null;
-                     n = getCSSNextSibling(n)) {
-                    invalidateProperties(n, null, null, true);
-                }
-                removedStylableElementSibling = null;
-            }
+            handleSubtreeModified(rootOfModifications);
         }
 
         /**
          * Character data in the CSSNavigableDocument tree has been modified.
          */
         public void characterDataModified(Node text) {
-            if (getCSSParentNode(text) instanceof CSSStyleSheetNode) {
-                styleSheetNodes = null;
-                // Invalidate all the CSSStylableElements in the document.
-                invalidateProperties(document.getDocumentElement(),
-                                     null, null, true);
-            }
+            handleCharacterDataModified(text);
         }
 
         /**
@@ -2550,24 +2592,7 @@
      */
     protected class DOMNodeInsertedListener implements EventListener {
         public void handleEvent(Event evt) {
-            EventTarget et = evt.getTarget();
-            if (et instanceof CSSStyleSheetNode) {
-                styleSheetNodes = null;
-                // Invalidate all the CSSStylableElements in the document.
-                invalidateProperties(document.getDocumentElement(),
-                                     null, null, true);
-                return;
-            }
-            if (et instanceof CSSStylableElement) {
-                // Invalidate the CSSStylableElement siblings, to
-                // correctly match the adjacent selectors and
-                // first-child pseudo-class.
-                for (Node n = ((Node)evt.getTarget()).getNextSibling();
-                     n != null;
-                     n = n.getNextSibling()) {
-                    invalidateProperties(n, null, null, true);
-                }
-            }
+            handleNodeInserted((Node) evt.getTarget());
         }
     }
 
@@ -2577,18 +2602,7 @@
      */
     protected class DOMNodeRemovedListener implements EventListener {
         public void handleEvent(Event evt) {
-            EventTarget et = evt.getTarget();
-            if (et instanceof CSSStyleSheetNode) {
-                // Wait for the DOMSubtreeModified to do the invalidations
-                // because at this time the node is in the tree.
-                styleSheetRemoved = true;
-            } else if (et instanceof CSSStylableElement) {
-                // Wait for the DOMSubtreeModified to do the invalidations
-                // because at this time the node is in the tree.
-                removedStylableElementSibling = ((Node)et).getNextSibling();
-            }
-            // Clears the computed styles in the removed tree.
-            disposeStyleMaps((Node)et);
+            handleNodeRemoved((Node) evt.getTarget());
         }
     }
 
@@ -2598,24 +2612,7 @@
      */
     protected class DOMSubtreeModifiedListener implements EventListener {
         public void handleEvent(Event evt) {
-            if (styleSheetRemoved) {
-                styleSheetRemoved = false;
-                styleSheetNodes = null;
-
-                // Invalidate all the CSSStylableElements in the document.
-                invalidateProperties(document.getDocumentElement(),
-                                     null, null, true);
-            } else if (removedStylableElementSibling != null) {
-                // Invalidate the CSSStylableElement siblings, to
-                // correctly match the adjacent selectors and
-                // first-child pseudo-class.
-                for (Node n = removedStylableElementSibling;
-                     n != null;
-                     n = n.getNextSibling()) {
-                    invalidateProperties(n, null, null, true);
-                }
-                removedStylableElementSibling = null;
-            }
+            handleSubtreeModified((Node) evt.getTarget());
         }
     }
 
@@ -2624,13 +2621,7 @@
      */
     protected class DOMCharacterDataModifiedListener implements EventListener {
         public void handleEvent(Event evt) {
-            Node n = (Node)evt.getTarget();
-            if (n.getParentNode() instanceof CSSStyleSheetNode) {
-                styleSheetNodes = null;
-                // Invalidate all the CSSStylableElements in the document.
-                invalidateProperties(document.getDocumentElement(),
-                                     null, null, true);
-            }
+            handleCharacterDataModified((Node) evt.getTarget());
         }
     }
 

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/StringIntMap.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/StringIntMap.java?rev=424999&r1=424998&r2=424999&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/StringIntMap.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/StringIntMap.java Mon Jul 24 03:34:44 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 2002  The Apache Software Foundation 
+   Copyright 2002, 2006  The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -30,113 +30,116 @@
      * The underlying array
      */
     protected Entry[] table;
-	    
+
     /**
      * The number of entries
      */
     protected int count;
-	    
+
     /**
      * Creates a new table.
      * @param c The capacity of the table.
      */
     public StringIntMap(int c) {
-	table = new Entry[((c * 3) >>> 2) + 1];
+        // the table is set to 75% of the requested size
+        table = new Entry[( c - ( c >> 2)) + 1];
     }
 
     /**
      * Gets the value corresponding to the given string.
      * @return the value or -1.
      */
-    public int get(String key) {
-	int hash  = key.hashCode() & 0x7FFFFFFF;
-	int index = hash % table.length;
-	
-	for (Entry e = table[index]; e != null; e = e.next) {
-	    if ((e.hash == hash) && e.key.equals(key)) {
-		return e.value;
-	    }
-	}
-	return -1;
+    public int get( String key ) {
+        int hash = key.hashCode() & 0x7FFFFFFF;
+        int index = hash % table.length;
+
+        for ( Entry e = table[ index ]; e != null; e = e.next ) {
+            if ( ( e.hash == hash ) && e.key.equals( key ) ) {
+                return e.value;
+            }
+        }
+        return -1;
     }
-    
+
     /**
      * Sets a new value for the given variable
      */
-    public void put(String key, int value) {
-	int hash  = key.hashCode() & 0x7FFFFFFF;
-	int index = hash % table.length;
-	
-	for (Entry e = table[index]; e != null; e = e.next) {
-	    if ((e.hash == hash) && e.key.equals(key)) {
-		e.value = value;
-		return;
-	    }
-	}
-	
-	// The key is not in the hash table
+    public void put( String key, int value ) {
+        int hash = key.hashCode() & 0x7FFFFFFF;
+        int index = hash % table.length;
+
+        for ( Entry e = table[ index ]; e != null; e = e.next ) {
+            if ( ( e.hash == hash ) && e.key.equals( key ) ) {
+                e.value = value;
+                return;
+            }
+        }
+
+        // The key is not in the hash table
         int len = table.length;
-	if (count++ >= (len * 3) >>> 2) {
-	    rehash();
-	    index = hash % table.length;
-	}
-	
-	Entry e = new Entry(hash, key, value, table[index]);
-	table[index] = e;
+        if ( count++ >= ( len - ( len >> 2 ) ) ) {
+            // more than 75% loaded: grow
+            rehash();
+            index = hash % table.length;
+        }
+
+        Entry e = new Entry( hash, key, value, table[ index ] );
+        table[ index ] = e;
     }
 
     /**
      * Rehash the table
      */
-    protected void rehash () {
-	Entry[] oldTable = table;
-	
-	table = new Entry[oldTable.length * 2 + 1];
-	
-	for (int i = oldTable.length-1; i >= 0; i--) {
-	    for (Entry old = oldTable[i]; old != null;) {
-		Entry e = old;
-		old = old.next;
-		
-		int index = e.hash % table.length;
-		e.next = table[index];
-		table[index] = e;
-	    }
-	}
+    protected void rehash() {
+        Entry[] oldTable = table;
+
+        table = new Entry[oldTable.length * 2 + 1];
+
+        for ( int i = oldTable.length - 1; i >= 0; i-- ) {
+            for ( Entry old = oldTable[ i ]; old != null; ) {
+                Entry e = old;
+                old = old.next;
+
+                int index = e.hash % table.length;
+                e.next = table[ index ];
+                table[ index ] = e;
+            }
+        }
     }
 
     /**
      * To manage collisions
      */
     protected static class Entry {
-	/**
-	 * The hash code
-	 */
-	public int hash;
-	
-	/**
-	 * The key
-	 */
-	public String key;
-	
-	/**
-	 * The value
-	 */
-	public int value;
-	
-	/**
-	 * The next entry
-	 */
-	public Entry next;
-	
-	/**
-	 * Creates a new entry
-	 */
-	public Entry(int hash, String key, int value, Entry next) {
-	    this.hash  = hash;
-	    this.key   = key;
-	    this.value = value;
-	    this.next  = next;
-	}
+
+        /**
+         * The hash code, must not change after init.
+         */
+        public final int hash;
+
+        /**
+         * The key
+         */
+        public String key;
+
+        /**
+         * The value, not changed after creation.
+         */
+        public int value;
+
+        /**
+         * The next entry - changed, when table[] is reordered.
+         */
+        public Entry next;
+
+        /**
+         * Creates a new entry
+         */
+        public Entry( int hash, String key, int value, Entry next ) {
+            this.hash  = hash;
+            this.key   = key;
+            this.value = value;
+            this.next  = next;
+        }
     }
 }

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/StringMap.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/StringMap.java?rev=424999&r1=424998&r2=424999&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/StringMap.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/StringMap.java Mon Jul 24 03:34:44 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 2002  The Apache Software Foundation 
+   Copyright 2002, 2006  The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -29,110 +29,111 @@
     /**
      * The initial capacity
      */
-    protected final static int INITIAL_CAPACITY = 11;
+    protected static final int INITIAL_CAPACITY = 11;
 
     /**
      * The underlying array
      */
     protected Entry[] table;
-	    
+
     /**
      * The number of entries
      */
     protected int count;
-	    
+
     /**
      * Creates a new table.
      */
     public StringMap() {
-	table = new Entry[INITIAL_CAPACITY];
+        table = new Entry[INITIAL_CAPACITY];
     }
 
     /**
      * Creates a copy of the given StringMap object.
      * @param t The table to copy.
      */
-    public StringMap(StringMap t) {
-	count = t.count;
-	table = new Entry[t.table.length];
-	for (int i = 0; i < table.length; i++) {
-	    Entry e = t.table[i];
-	    Entry n = null;
-	    if (e != null) {
-		n = new Entry(e.hash, e.key, e.value, null);
-		table[i] = n;
-		e = e.next;
-		while (e != null) {
-		    n.next = new Entry(e.hash, e.key, e.value, null);
-		    n = n.next;
-		    e = e.next;
-		}
-	    }
-	}
+    public StringMap( StringMap t ) {
+        count = t.count;
+        table = new Entry[t.table.length];
+        for ( int i = 0; i < table.length; i++ ) {
+            Entry e = t.table[ i ];
+            Entry n = null;
+            if ( e != null ) {
+                n = new Entry( e.hash, e.key, e.value, null );
+                table[ i ] = n;
+                e = e.next;
+                while ( e != null ) {
+                    n.next = new Entry( e.hash, e.key, e.value, null );
+                    n = n.next;
+                    e = e.next;
+                }
+            }
+        }
     }
 
     /**
      * Gets the value corresponding to the given string.
      * @return the value or null
      */
-    public Object get(String key) {
-	int hash  = key.hashCode() & 0x7FFFFFFF;
-	int index = hash % table.length;
-	
-	for (Entry e = table[index]; e != null; e = e.next) {
-	    if ((e.hash == hash) && e.key == key) {
-		return e.value;
-	    }
-	}
-	return null;
+    public Object get( String key ) {
+        int hash = key.hashCode() & 0x7FFFFFFF;
+        int index = hash % table.length;
+
+        for ( Entry e = table[ index ]; e != null; e = e.next ) {
+            if ( ( e.hash == hash ) && e.key == key ) {
+                return e.value;
+            }
+        }
+        return null;
     }
-    
+
     /**
      * Sets a new value for the given variable
      * @return the old value or null
      */
-    public Object put(String key, Object value) {
-	int hash  = key.hashCode() & 0x7FFFFFFF;
-	int index = hash % table.length;
-	
-	for (Entry e = table[index]; e != null; e = e.next) {
-	    if ((e.hash == hash) && e.key == key) {
-		Object old = e.value;
-		e.value = value;
-		return old;
-	    }
-	}
-	
-	// The key is not in the hash table
+    public Object put( String key, Object value ) {
+        int hash = key.hashCode() & 0x7FFFFFFF;
+        int index = hash % table.length;
+
+        for ( Entry e = table[ index ]; e != null; e = e.next ) {
+            if ( ( e.hash == hash ) && e.key == key ) {
+                Object old = e.value;
+                e.value = value;
+                return old;
+            }
+        }
+
+        // The key is not in the hash table
         int len = table.length;
-	if (count++ >= (len * 3) >>> 2) {
-	    rehash();
-	    index = hash % table.length;
-	}
-	
-	Entry e = new Entry(hash, key, value, table[index]);
-	table[index] = e;
-	return null;
+        if ( count++ >= ( len - ( len >> 2 ) ) ) {
+            // more than 75% loaded: grow
+            rehash();
+            index = hash % table.length;
+        }
+
+        Entry e = new Entry( hash, key, value, table[ index ] );
+        table[ index ] = e;
+        return null;
     }
 
     /**
      * Rehash the table
      */
-    protected void rehash () {
-	Entry[] oldTable = table;
-	
-	table = new Entry[oldTable.length * 2 + 1];
-	
-	for (int i = oldTable.length-1; i >= 0; i--) {
-	    for (Entry old = oldTable[i]; old != null;) {
-		Entry e = old;
-		old = old.next;
-		
-		int index = e.hash % table.length;
-		e.next = table[index];
-		table[index] = e;
-	    }
-	}
+    protected void rehash() {
+        Entry[] oldTable = table;
+
+        table = new Entry[oldTable.length * 2 + 1];
+
+        for ( int i = oldTable.length - 1; i >= 0; i-- ) {
+            for ( Entry old = oldTable[ i ]; old != null; ) {
+                Entry e = old;
+                old = old.next;
+
+                int index = e.hash % table.length;
+                e.next = table[ index ];
+                table[ index ] = e;
+            }
+        }
     }
 
     /**
@@ -143,22 +144,22 @@
 	 * The hash code
 	 */
 	public int hash;
-	
+
 	/**
 	 * The key
 	 */
 	public String key;
-	
+
 	/**
 	 * The value
 	 */
 	public Object value;
-	
+
 	/**
 	 * The next entry
 	 */
 	public Entry next;
-	
+
 	/**
 	 * Creates a new entry
 	 */

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/AbstractElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/AbstractElement.java?rev=424999&r1=424998&r2=424999&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/AbstractElement.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/AbstractElement.java Mon Jul 24 03:34:44 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 2000-2003,2006  The Apache Software Foundation 
+   Copyright 2000-2003,2006  The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -66,62 +66,64 @@
      *   INVALID_CHARACTER_ERR: if name contains invalid characters,
      */
     protected AbstractElement(String name, AbstractDocument owner) {
-	ownerDocument = owner;
-	if (owner.getStrictErrorChecking() && !DOMUtilities.isValidName(name)) {
-	    throw createDOMException(DOMException.INVALID_CHARACTER_ERR,
-				     "xml.name",
-				     new Object[] { name });
-	}
+        ownerDocument = owner;
+        if (owner.getStrictErrorChecking() && !DOMUtilities.isValidName(name)) {
+            throw createDOMException(DOMException.INVALID_CHARACTER_ERR,
+                   "xml.name",
+                   new Object[] { name });
+        }
     }
 
     /**
      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeType()}.
+     *
      * @return {@link org.w3c.dom.Node#ELEMENT_NODE}
      */
     public short getNodeType() {
-	return ELEMENT_NODE;
+        return ELEMENT_NODE;
     }
 
     /**
      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#hasAttributes()}.
      */
     public boolean hasAttributes() {
-	return attributes != null && attributes.getLength() != 0;
+        return attributes != null && attributes.getLength() != 0;
     }
 
     /**
      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getAttributes()}.
      */
     public NamedNodeMap getAttributes() {
-	return (attributes == null)
+      	return (attributes == null)
             ? attributes = createAttributes()
             : attributes;
     }
 
     /**
      * <b>DOM</b>: Implements {@link org.w3c.dom.Element#getTagName()}.
+     *
      * @return {@link #getNodeName()}.
      */
     public String getTagName() {
-	return getNodeName();
+        return getNodeName();
     }
 
     /**
      * <b>DOM</b>: Implements {@link org.w3c.dom.Element#hasAttribute(String)}.
      */
-    public boolean hasAttribute(String name) {
-	return attributes != null && attributes.getNamedItem(name) != null;
+    public boolean hasAttribute( String name ) {
+        return attributes != null && attributes.getNamedItem( name ) != null;
     }
 
     /**
      * <b>DOM</b>: Implements {@link org.w3c.dom.Element#getAttribute(String)}.
      */
     public String getAttribute(String name) {
-	if (attributes == null) {
-	    return "";
-	}
-	Attr attr = (Attr)attributes.getNamedItem(name);
-	return (attr == null) ? "" : attr.getValue();
+        if ( attributes == null ) {
+          return "";
+        }
+        Attr attr = (Attr)attributes.getNamedItem( name );
+        return ( attr == null ) ? "" : attr.getValue();
     }
 
     /**
@@ -129,9 +131,9 @@
      * org.w3c.dom.Element#setAttribute(String,String)}.
      */
     public void setAttribute(String name, String value) throws DOMException {
-	if (attributes == null) {
-	    attributes = createAttributes();
-	}
+        if (attributes == null) {
+            attributes = createAttributes();
+        }
         Attr attr = getAttributeNode(name);
         if (attr == null) {
             attr = getOwnerDocument().createAttribute(name);
@@ -147,10 +149,10 @@
      * org.w3c.dom.Element#removeAttribute(String)}.
      */
     public void removeAttribute(String name) throws DOMException {
-	if (!hasAttribute(name)) {
-            return;
-	}
-	attributes.removeNamedItem(name);
+        if (!hasAttribute(name)) {
+                  return;
+        }
+        attributes.removeNamedItem(name);
     }
 
     /**
@@ -158,10 +160,10 @@
      * org.w3c.dom.Element#getAttributeNode(String)}.
      */
     public Attr getAttributeNode(String name) {
-	if (attributes == null) {
-	    return null;
-	}
-	return (Attr)attributes.getNamedItem(name);
+        if (attributes == null) {
+            return null;
+        }
+        return (Attr)attributes.getNamedItem(name);
     }
 
     /**
@@ -169,13 +171,13 @@
      * org.w3c.dom.Element#setAttributeNode(Attr)}.
      */
     public Attr setAttributeNode(Attr newAttr) throws DOMException {
-	if (newAttr == null) {
-	    return null;
-	}
-	if (attributes == null) {
-	    attributes = createAttributes();
-	}
-	return (Attr)attributes.setNamedItemNS(newAttr);
+        if (newAttr == null) {
+            return null;
+        }
+        if (attributes == null) {
+            attributes = createAttributes();
+        }
+        return (Attr)attributes.setNamedItemNS(newAttr);
     }
 
     /**
@@ -183,16 +185,16 @@
      * org.w3c.dom.Element#removeAttributeNode(Attr)}.
      */
     public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
-	if (oldAttr == null) {
-	    return null;
-	}
-	if (attributes == null) {
-	    throw createDOMException(DOMException.NOT_FOUND_ERR,
-				     "attribute.missing",
-				     new Object[] { oldAttr.getName() });
-	}
+        if (oldAttr == null) {
+            return null;
+        }
+        if (attributes == null) {
+            throw createDOMException(DOMException.NOT_FOUND_ERR,
+                   "attribute.missing",
+                   new Object[] { oldAttr.getName() });
+        }
         String nsURI = oldAttr.getNamespaceURI();
-	return (Attr)attributes.removeNamedItemNS(nsURI,
+      	return (Attr)attributes.removeNamedItemNS(nsURI,
                                                   (nsURI==null
                                                    ? oldAttr.getNodeName()
                                                    : oldAttr.getLocalName()));
@@ -202,52 +204,53 @@
      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#normalize()}.
      */
     public void normalize() {
-	super.normalize();
-	if (attributes != null) {
-	    NamedNodeMap map = getAttributes();
-	    for (int i = map.getLength() - 1; i >= 0; i--) {
-		map.item(i).normalize();
-	    }
-	}
+        super.normalize();
+        if (attributes != null) {
+            NamedNodeMap map = getAttributes();
+            for (int i = map.getLength() - 1; i >= 0; i--) {
+                map.item(i).normalize();
+            }
+        }
     }
 
     /**
      * <b>DOM</b>: Implements {@link
      * org.w3c.dom.Element#hasAttributeNS(String,String)}.
      */
-    public boolean hasAttributeNS(String namespaceURI, String localName) {
-        if (namespaceURI != null && namespaceURI.length() == 0) {
+    public boolean hasAttributeNS( String namespaceURI, String localName ) {
+        if ( namespaceURI != null && namespaceURI.length() == 0 ) {
             namespaceURI = null;
         }
-	return attributes != null &&
-	       attributes.getNamedItemNS(namespaceURI, localName) != null;
+        return attributes != null &&
+                attributes.getNamedItemNS( namespaceURI, localName ) != null;
     }
 
     /**
      * <b>DOM</b>: Implements {@link
      * org.w3c.dom.Element#getAttributeNS(String,String)}.
      */
-    public String getAttributeNS(String namespaceURI, String localName) {
-	if (attributes == null) {
-	    return "";
-	}
-        if (namespaceURI != null && namespaceURI.length() == 0) {
+    public String getAttributeNS( String namespaceURI, String localName ) {
+        if ( attributes == null ) {
+            return "";
+        }
+        if ( namespaceURI != null && namespaceURI.length() == 0 ) {
             namespaceURI = null;
         }
-	Attr attr = (Attr)attributes.getNamedItemNS(namespaceURI, localName);
-	return (attr == null) ? "" : attr.getValue();
+        Attr attr = (Attr)attributes.getNamedItemNS( namespaceURI, localName );
+        return ( attr == null ) ? "" : attr.getValue();
     }
 
     /**
      * <b>DOM</b>: Implements {@link
      * org.w3c.dom.Element#setAttributeNS(String,String,String)}.
      */
-    public void setAttributeNS(String namespaceURI, 
-			       String qualifiedName, 
+    public void setAttributeNS(String namespaceURI,
+			       String qualifiedName,
 			       String value) throws DOMException {
-	if (attributes == null) {
-	    attributes = createAttributes();
-	}
+
+        if (attributes == null) {
+            attributes = createAttributes();
+        }
         if (namespaceURI != null && namespaceURI.length() == 0) {
             namespaceURI = null;
         }
@@ -266,30 +269,30 @@
      * <b>DOM</b>: Implements {@link
      * org.w3c.dom.Element#removeAttributeNS(String,String)}.
      */
-    public void removeAttributeNS(String namespaceURI, 
+    public void removeAttributeNS(String namespaceURI,
 				  String localName) throws DOMException {
         if (namespaceURI != null && namespaceURI.length() == 0) {
             namespaceURI = null;
         }
-	if (!hasAttributeNS(namespaceURI, localName)) {
-            return;
-	}
-	attributes.removeNamedItemNS(namespaceURI, localName);
+        if (!hasAttributeNS(namespaceURI, localName)) {
+                  return;
+        }
+      	attributes.removeNamedItemNS(namespaceURI, localName);
     }
 
     /**
      * <b>DOM</b>: Implements {@link
      * org.w3c.dom.Element#getAttributeNodeNS(String,String)}.
      */
-    public Attr getAttributeNodeNS(String namespaceURI, 
+    public Attr getAttributeNodeNS(String namespaceURI,
 				   String localName) {
         if (namespaceURI != null && namespaceURI.length() == 0) {
             namespaceURI = null;
         }
-	if (attributes == null) {
-	    return null;
-	}
-	return (Attr)attributes.getNamedItemNS(namespaceURI, localName);
+        if (attributes == null) {
+            return null;
+        }
+        return (Attr)attributes.getNamedItemNS(namespaceURI, localName);
     }
 
     /**
@@ -297,13 +300,13 @@
      * org.w3c.dom.Element#setAttributeNodeNS(Attr)}.
      */
     public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
-	if (newAttr == null) {
-	    return null;
-	}
-	if (attributes == null) {
-	    attributes = createAttributes();
-	}
-	return (Attr)attributes.setNamedItemNS(newAttr);
+        if (newAttr == null) {
+            return null;
+        }
+        if (attributes == null) {
+            attributes = createAttributes();
+        }
+        return (Attr)attributes.setNamedItemNS(newAttr);
     }
 
     /**
@@ -339,12 +342,12 @@
      * <b>DOM</b>: Implements
      * {@link org.w3c.dom.Element#setIdAttributeNS(String,String,boolean)}.
      */
-    public void setIdAttributeNS(String ns, String ln, boolean isId)
+    public void setIdAttributeNS( String ns, String ln, boolean isId )
             throws DOMException {
-        if (ns != null && ns.length() == 0) {
+        if ( ns != null && ns.length() == 0 ) {
             ns = null;
         }
-        AbstractAttr a = (AbstractAttr) getAttributeNodeNS(ns, ln);
+        AbstractAttr a = (AbstractAttr)getAttributeNodeNS( ns, ln );
         if (a == null) {
             throw createDOMException(DOMException.NOT_FOUND_ERR,
                                      "attribute.missing",
@@ -362,9 +365,9 @@
      * <b>DOM</b>: Implements
      * {@link org.w3c.dom.Element#setIdAttributeNode(Attr,boolean)}.
      */
-    public void setIdAttributeNode(Attr attr, boolean isId)
+    public void setIdAttributeNode( Attr attr, boolean isId )
             throws DOMException {
-        AbstractAttr a = (AbstractAttr) attr;
+        AbstractAttr a = (AbstractAttr)attr;
         if (a.isReadonly()) {
             throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
                                      "readonly.node",
@@ -378,13 +381,13 @@
      */
     protected Attr getIdAttribute() {
         NamedNodeMap nnm = getAttributes();
-        if (nnm == null) {
+        if ( nnm == null ) {
             return null;
         }
         int len = nnm.getLength();
-        for (int i = 0; i < len; i++) {
-            AbstractAttr a = (AbstractAttr) nnm.item(i);
-            if (a.isId()) {
+        for ( int i = 0; i < len; i++ ) {
+            AbstractAttr a = (AbstractAttr)nnm.item( i );
+            if ( a.isId() ) {
                 return a;
             }
         }
@@ -432,7 +435,7 @@
         String ln = (ns == null) ? node.getNodeName() : node.getLocalName();
         for (Node n = this; n != null; n = n.getParentNode()) {
             switch (n.getNodeType()) {
-            case ELEMENT_NODE:
+            case ELEMENT_NODE:      // fall-through is intended
             case DOCUMENT_NODE:
                 ElementsByTagName l = ad.getElementsByTagName(n, nm);
                 if (l != null) {
@@ -470,14 +473,14 @@
             invalidateElementsByTagName(c);
             c = c.getNextSibling();
         }
-            
+
     }
 
     /**
      * Creates the attribute list.
      */
     protected NamedNodeMap createAttributes() {
-	return new NamedNodeHashMap();
+      	return new NamedNodeHashMap();
     }
 
     /**
@@ -486,23 +489,23 @@
      * @param d The destination document.
      */
     protected Node export(Node n, AbstractDocument d) {
-	super.export(n, d);
-	AbstractElement ae = (AbstractElement)n;
-	if (attributes != null) {
-	    NamedNodeMap map = attributes;
-	    for (int i = map.getLength() - 1; i >= 0; i--) {
-		AbstractAttr aa = (AbstractAttr)map.item(i);
-		if (aa.getSpecified()) {
-		    Attr attr = (Attr)aa.deepExport(aa.cloneNode(false), d);
-		    if (aa instanceof AbstractAttrNS) {
-			ae.setAttributeNodeNS(attr);
-		    } else {
-			ae.setAttributeNode(attr);
-		    }
-		}
-	    }
-	}
-	return n;
+        super.export(n, d);
+        AbstractElement ae = (AbstractElement)n;
+        if (attributes != null) {
+            NamedNodeMap map = attributes;
+            for (int i = map.getLength() - 1; i >= 0; i--) {
+                AbstractAttr aa = (AbstractAttr)map.item(i);
+                if (aa.getSpecified()) {
+                    Attr attr = (Attr)aa.deepExport(aa.cloneNode(false), d);
+                    if (aa instanceof AbstractAttrNS) {
+                        ae.setAttributeNodeNS(attr);
+                    } else {
+                        ae.setAttributeNode(attr);
+                    }
+                }
+            }
+        }
+        return n;
     }
 
     /**
@@ -511,23 +514,23 @@
      * @param d The destination document.
      */
     protected Node deepExport(Node n, AbstractDocument d) {
-	super.deepExport(n, d);
-	AbstractElement ae = (AbstractElement)n;
-	if (attributes != null) {
-	    NamedNodeMap map = attributes;
-	    for (int i = map.getLength() - 1; i >= 0; i--) {
-		AbstractAttr aa = (AbstractAttr)map.item(i);
-		if (aa.getSpecified()) {
-		    Attr attr = (Attr)aa.deepExport(aa.cloneNode(false), d);
-		    if (aa instanceof AbstractAttrNS) {
-			ae.setAttributeNodeNS(attr);
-		    } else {
-			ae.setAttributeNode(attr);
-		    }
-		}
-	    }
-	}
-	return n;
+        super.deepExport(n, d);
+        AbstractElement ae = (AbstractElement)n;
+        if (attributes != null) {
+            NamedNodeMap map = attributes;
+            for (int i = map.getLength() - 1; i >= 0; i--) {
+                AbstractAttr aa = (AbstractAttr)map.item(i);
+                if (aa.getSpecified()) {
+                    Attr attr = (Attr)aa.deepExport(aa.cloneNode(false), d);
+                    if (aa instanceof AbstractAttrNS) {
+                        ae.setAttributeNodeNS(attr);
+                    } else {
+                        ae.setAttributeNode(attr);
+                    }
+                }
+            }
+        }
+        return n;
     }
 
     /**
@@ -535,20 +538,20 @@
      * @param n a node of the type of this.
      */
     protected Node copyInto(Node n) {
-	super.copyInto(n);
-	AbstractElement ae = (AbstractElement)n;
-	if (attributes != null) {
-	    NamedNodeMap map = attributes;
-	    for (int i = map.getLength() - 1; i >= 0; i--) {
-		AbstractAttr aa = (AbstractAttr)map.item(i).cloneNode(true);
-		if (aa instanceof AbstractAttrNS) {
-		    ae.setAttributeNodeNS(aa);
-		} else {
-		    ae.setAttributeNode(aa);
-		}
-	    }
-	}
-	return n;
+        super.copyInto(n);
+        AbstractElement ae = (AbstractElement)n;
+        if (attributes != null) {
+            NamedNodeMap map = attributes;
+            for (int i = map.getLength() - 1; i >= 0; i--) {
+                AbstractAttr aa = (AbstractAttr)map.item(i).cloneNode(true);
+                if (aa instanceof AbstractAttrNS) {
+                    ae.setAttributeNodeNS(aa);
+                } else {
+                    ae.setAttributeNode(aa);
+                }
+            }
+        }
+        return n;
     }
 
     /**
@@ -556,20 +559,20 @@
      * @param n a node of the type of this.
      */
     protected Node deepCopyInto(Node n) {
-	super.deepCopyInto(n);
-	AbstractElement ae = (AbstractElement)n;
-	if (attributes != null) {
-	    NamedNodeMap map = attributes;
-	    for (int i = map.getLength() - 1; i >= 0; i--) {
-		AbstractAttr aa = (AbstractAttr)map.item(i).cloneNode(true);
-		if (aa instanceof AbstractAttrNS) {
-		    ae.setAttributeNodeNS(aa);
-		} else {
-		    ae.setAttributeNode(aa);
-		}
-	    }
-	}
-	return n;
+        super.deepCopyInto(n);
+        AbstractElement ae = (AbstractElement)n;
+        if (attributes != null) {
+            NamedNodeMap map = attributes;
+            for (int i = map.getLength() - 1; i >= 0; i--) {
+                AbstractAttr aa = (AbstractAttr)map.item(i).cloneNode(true);
+                if (aa instanceof AbstractAttrNS) {
+                    ae.setAttributeNodeNS(aa);
+                } else {
+                    ae.setAttributeNode(aa);
+                }
+            }
+        }
+        return n;
     }
 
     /**
@@ -577,24 +580,24 @@
      * @param n The node to be inserted.
      */
     protected void checkChildType(Node n, boolean replace) {
-	switch (n.getNodeType()) {
-	case ELEMENT_NODE:
-	case PROCESSING_INSTRUCTION_NODE:
-	case COMMENT_NODE:
-	case TEXT_NODE:
-	case CDATA_SECTION_NODE:
-	case ENTITY_REFERENCE_NODE:
-	case DOCUMENT_FRAGMENT_NODE:
-	    break;
-	default:
-	    throw createDOMException
-                (DOMException.HIERARCHY_REQUEST_ERR,
-                 "child.type",
-                 new Object[] { new Integer(getNodeType()),
-                                getNodeName(),
-                                new Integer(n.getNodeType()),
-                                n.getNodeName() });
-	}
+        switch (n.getNodeType()) {
+        case ELEMENT_NODE:                // fall-through is intended
+        case PROCESSING_INSTRUCTION_NODE:
+        case COMMENT_NODE:
+        case TEXT_NODE:
+        case CDATA_SECTION_NODE:
+        case ENTITY_REFERENCE_NODE:
+        case DOCUMENT_FRAGMENT_NODE:
+            break;
+        default:
+            throw createDOMException
+                      (DOMException.HIERARCHY_REQUEST_ERR,
+                       "child.type",
+                       new Object[] { new Integer(getNodeType()),
+                                      getNodeName(),
+                                      new Integer(n.getNodeType()),
+                                      n.getNodeName() });
+        }
     }
 
     /**
@@ -612,38 +615,38 @@
                                          String newv, short change) {
         switch (change) {
         case MutationEvent.ADDITION:
-            if (((AbstractAttr)node).isId()) 
+            if (((AbstractAttr)node).isId())
                 ownerDocument.addIdEntry(this, newv);
             attrAdded(node, newv);
             break;
 
         case MutationEvent.MODIFICATION:
-            if (((AbstractAttr)node).isId()) 
+            if (((AbstractAttr)node).isId())
                 ownerDocument.updateIdEntry(this, oldv, newv);
             attrModified(node, oldv, newv);
             break;
 
         default: // MutationEvent.REMOVAL:
-            if (((AbstractAttr)node).isId()) 
+            if (((AbstractAttr)node).isId())
                 ownerDocument.removeIdEntry(this, oldv);
             attrRemoved(node, oldv);
         }
-	AbstractDocument doc = getCurrentDocument();
-	if (doc.getEventsEnabled() && !oldv.equals(newv)) {
-	    DocumentEvent de = (DocumentEvent)doc;
-	    DOMMutationEvent ev
-                = (DOMMutationEvent) de.createEvent("MutationEvents");
-	    ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
-                                   "DOMAttrModified",
-                                   true,    // canBubbleArg
-                                   false,   // cancelableArg
-                                   node,    // relatedNodeArg
-                                   oldv,    // prevValueArg
-                                   newv,    // newValueArg
-                                   name,    // attrNameArg
-                                   change); // attrChange
-	    dispatchEvent(ev);
-	}
+        AbstractDocument doc = getCurrentDocument();
+        if (doc.getEventsEnabled() && !oldv.equals(newv)) {
+            DocumentEvent de = (DocumentEvent)doc;
+            DOMMutationEvent ev
+                      = (DOMMutationEvent) de.createEvent("MutationEvents");
+            ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
+                                         "DOMAttrModified",
+                                         true,    // canBubbleArg
+                                         false,   // cancelableArg
+                                         node,    // relatedNodeArg
+                                         oldv,    // prevValueArg
+                                         newv,    // newValueArg
+                                         name,    // attrNameArg
+                                         change); // attrChange
+            dispatchEvent(ev);
+        }
     }
 
     /**
@@ -666,263 +669,265 @@
 
     /**
      * An implementation of the {@link org.w3c.dom.NamedNodeMap}.
+     *
+     * <br>This Map is not Thread-safe, concurrent updates or reading while updating may give
+     * unexpected results.
      */
     public class NamedNodeHashMap implements NamedNodeMap, Serializable {
 
         /**
          * The initial capacity
          */
-        protected final static int INITIAL_CAPACITY = 3;
+        protected static final int INITIAL_CAPACITY = 3;
 
         /**
          * The underlying array
          */
         protected Entry[] table;
-	    
+
         /**
          * The number of entries
          */
         protected int count;
-	    
-	/**
-	 * Creates a new NamedNodeHashMap object.
-	 */
-	public NamedNodeHashMap() {
-            table = new Entry[INITIAL_CAPACITY];
-	}
-
-	/**
-	 * <b>DOM</b>: Implements {@link
-         * org.w3c.dom.NamedNodeMap#getNamedItem(String)}.
-	 */
-	public Node getNamedItem(String name) {
-	    if (name == null) {
-		return null;
-	    }
-	    return get(null, name);
-	}
-
-	/**
-	 * <b>DOM</b>: Implements {@link
-         * org.w3c.dom.NamedNodeMap#setNamedItem(Node)}.
-	 */
-	public Node setNamedItem(Node arg) throws DOMException {
-	    if (arg == null) {
-		return null;
-	    }
-	    checkNode(arg);
-
-	    return setNamedItem(null, arg.getNodeName(), arg);
-	}
-
-	/**
-	 * <b>DOM</b>: Implements {@link
-	 * org.w3c.dom.NamedNodeMap#removeNamedItem(String)}.
-	 */
-	public Node removeNamedItem(String name) throws DOMException {
-	    return removeNamedItemNS(null, name);
-	}
-
-	/**
-	 * <b>DOM</b>: Implements {@link org.w3c.dom.NamedNodeMap#item(int)}.
-	 */
-	public Node item(int index) {
-            if (index < 0 || index >= count) {
+
+        /**
+         * Creates a new NamedNodeHashMap object.
+         */
+        public NamedNodeHashMap() {
+                  table = new Entry[INITIAL_CAPACITY];
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link org.w3c.dom.NamedNodeMap#getNamedItem(String)}.
+         */
+        public Node getNamedItem( String name ) {
+            if ( name == null ) {
+                return null;
+            }
+            return get( null, name );
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link org.w3c.dom.NamedNodeMap#setNamedItem(Node)}.
+         */
+        public Node setNamedItem( Node arg ) throws DOMException {
+            if ( arg == null ) {
+                return null;
+            }
+            checkNode( arg );
+
+            return setNamedItem( null, arg.getNodeName(), arg );
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link org.w3c.dom.NamedNodeMap#removeNamedItem(String)}.
+         */
+        public Node removeNamedItem( String name ) throws DOMException {
+            return removeNamedItemNS( null, name );
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link org.w3c.dom.NamedNodeMap#item(int)}.
+         */
+        public Node item( int index ) {
+            if ( index < 0 || index >= count ) {
                 return null;
             }
             int j = 0;
-            for (int i = 0; i < table.length; i++) {
-                Entry e = table[i];
-                if (e == null) {
+            for ( int i = 0; i < table.length; i++ ) {
+                Entry e = table[ i ];
+                if ( e == null ) {
                     continue;
                 }
                 do {
-                    if (j++ == index) {
+                    if ( j++ == index ) {
                         return e.value;
                     }
                     e = e.next;
-                } while (e != null);
+                } while ( e != null );
             }
             return null;
-	}
+        }
 
-	/**
-	 * <b>DOM</b>: Implements {@link org.w3c.dom.NamedNodeMap#getLength()}.
-	 */
-	public int getLength() {
+        /**
+         * <b>DOM</b>: Implements {@link org.w3c.dom.NamedNodeMap#getLength()}.
+         */
+        public int getLength() {
             return count;
-	}
+        }
 
-	/**
-	 * <b>DOM</b>: Implements {@link
-	 * org.w3c.dom.NamedNodeMap#getNamedItemNS(String,String)}.
-	 */
-	public Node getNamedItemNS(String namespaceURI, String localName) {
-            if (namespaceURI != null && namespaceURI.length() == 0) {
+        /**
+         * <b>DOM</b>: Implements {@link
+         * org.w3c.dom.NamedNodeMap#getNamedItemNS(String,String)}.
+         */
+        public Node getNamedItemNS( String namespaceURI, String localName ) {
+            if ( namespaceURI != null && namespaceURI.length() == 0 ) {
                 namespaceURI = null;
             }
-            return get(namespaceURI, localName);
-	}
+            return get( namespaceURI, localName );
+        }
 
-	/**
-	 * <b>DOM</b>: Implements {@link
-         * org.w3c.dom.NamedNodeMap#setNamedItemNS(Node)}.
-	 */
-	public Node setNamedItemNS(Node arg) throws DOMException {
-	    if (arg == null) {
-		return null;
-	    }
-	    String nsURI = arg.getNamespaceURI();
-            return setNamedItem(nsURI,
-                                (nsURI == null) 
-                                ? arg.getNodeName()
-                                : arg.getLocalName(), arg);
-	}
-
-	/**
-	 * <b>DOM</b>: Implements {@link
-	 * org.w3c.dom.NamedNodeMap#removeNamedItemNS(String,String)}.
-	 */
-	public Node removeNamedItemNS(String namespaceURI, String localName)
-	    throws DOMException {
-	    if (isReadonly()) {
-		throw createDOMException
-                    (DOMException.NO_MODIFICATION_ALLOWED_ERR,
-                     "readonly.node.map",
-                     new Object[] {});
-	    }
-	    if (localName == null) {
-		throw createDOMException(DOMException.NOT_FOUND_ERR,
-					 "attribute.missing",
-					 new Object[] { "" });
-	    }
-            if (namespaceURI != null && namespaceURI.length() == 0) {
+        /**
+         * <b>DOM</b>: Implements {@link org.w3c.dom.NamedNodeMap#setNamedItemNS(Node)}.
+         */
+        public Node setNamedItemNS( Node arg ) throws DOMException {
+            if ( arg == null ) {
+                return null;
+            }
+            String nsURI = arg.getNamespaceURI();
+            return setNamedItem( nsURI,
+                    ( nsURI == null )
+                            ? arg.getNodeName()
+                            : arg.getLocalName(), arg );
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link org.w3c.dom.NamedNodeMap#removeNamedItemNS(String,String)}.
+         */
+        public Node removeNamedItemNS( String namespaceURI, String localName )
+                throws DOMException {
+            if ( isReadonly() ) {
+                throw createDOMException
+                        ( DOMException.NO_MODIFICATION_ALLOWED_ERR,
+                                "readonly.node.map",
+                                new Object[]{} );
+            }
+            if ( localName == null ) {
+                throw createDOMException( DOMException.NOT_FOUND_ERR,
+                        "attribute.missing",
+                        new Object[]{""} );
+            }
+            if ( namespaceURI != null && namespaceURI.length() == 0 ) {
                 namespaceURI = null;
             }
-	    AbstractAttr n = (AbstractAttr)remove(namespaceURI, localName);
-	    if (n == null) {
-		throw createDOMException(DOMException.NOT_FOUND_ERR,
-					 "attribute.missing",
-					 new Object[] { localName });
-	    }
-	    n.setOwnerElement(null);
-	    
-	    // Mutation event
-	    fireDOMAttrModifiedEvent(n.getNodeName(), n, n.getNodeValue(), "",
-                                     MutationEvent.REMOVAL);
-	    return n;
-	}
-
-	/**
-	 * Adds a node to the map.
- 	 */
-	public Node setNamedItem(String ns, String name, Node arg)
-            throws DOMException {
-            if (ns != null && ns.length() == 0) {
+            AbstractAttr n = (AbstractAttr)remove( namespaceURI, localName );
+            if ( n == null ) {
+                throw createDOMException( DOMException.NOT_FOUND_ERR,
+                        "attribute.missing",
+                        new Object[]{localName} );
+            }
+            n.setOwnerElement( null );
+
+            // Mutation event
+            fireDOMAttrModifiedEvent( n.getNodeName(), n, n.getNodeValue(), "",
+                    MutationEvent.REMOVAL );
+            return n;
+        }
+
+        /**
+         * Adds a node to the map.
+         */
+        public Node setNamedItem( String ns, String name, Node arg )
+                throws DOMException {
+
+            if ( ns != null && ns.length() == 0 ) {
                 ns = null;
             }
-	    ((AbstractAttr)arg).setOwnerElement(AbstractElement.this);
-	    AbstractAttr result = (AbstractAttr)put(ns, name, arg);
+            ( (AbstractAttr)arg ).setOwnerElement( AbstractElement.this );
+            AbstractAttr result = (AbstractAttr)put( ns, name, arg );
 
-	    if (result != null) {
-		result.setOwnerElement(null);
-		fireDOMAttrModifiedEvent(name,
-                                         result,
-					 result.getNodeValue(),
-					 "",
-                                         MutationEvent.REMOVAL);
-	    }
-            fireDOMAttrModifiedEvent(name,
-                                     (Attr)arg,
-                                     "",
-                                     arg.getNodeValue(),
-                                     MutationEvent.ADDITION);
-	    return result;
-	}
-
-	/**
-	 * Checks the validity of a node to add.
-	 */
-	protected void checkNode(Node arg) {
-	    if (isReadonly()) {
-		throw createDOMException
-                    (DOMException.NO_MODIFICATION_ALLOWED_ERR,
-                     "readonly.node.map",
-                     new Object[] {});
-	    }
-	    if (getOwnerDocument() != arg.getOwnerDocument()) {
-		throw createDOMException(DOMException.WRONG_DOCUMENT_ERR,
-					 "node.from.wrong.document",
-					 new Object[] { new Integer
-                                                         (arg.getNodeType()),
-		                                        arg.getNodeName() });
-	    }
-	    if (arg.getNodeType() == ATTRIBUTE_NODE &&
-		((Attr)arg).getOwnerElement() != null) {
-		throw createDOMException(DOMException.WRONG_DOCUMENT_ERR,
-					 "inuse.attribute",
-					 new Object[] { arg.getNodeName() });
-	    }
-	}
+            if ( result != null ) {
+                result.setOwnerElement( null );
+                fireDOMAttrModifiedEvent( name,
+                        result,
+                        result.getNodeValue(),
+                        "",
+                        MutationEvent.REMOVAL );
+            }
+            fireDOMAttrModifiedEvent( name,
+                    (Attr)arg,
+                    "",
+                    arg.getNodeValue(),
+                    MutationEvent.ADDITION );
+            return result;
+    }
+
+        /**
+         * Checks the validity of a node to add.
+         */
+        protected void checkNode( Node arg ) {
+            if ( isReadonly() ) {
+                throw createDOMException
+                        ( DOMException.NO_MODIFICATION_ALLOWED_ERR,
+                                "readonly.node.map",
+                                new Object[]{} );
+            }
+            if ( getOwnerDocument() != arg.getOwnerDocument() ) {
+                throw createDOMException( DOMException.WRONG_DOCUMENT_ERR,
+                        "node.from.wrong.document",
+                        new Object[]{new Integer( arg.getNodeType() ),
+                                arg.getNodeName()} );
+            }
+            if ( arg.getNodeType() == ATTRIBUTE_NODE &&
+                    ( (Attr)arg ).getOwnerElement() != null ) {
+                throw createDOMException( DOMException.WRONG_DOCUMENT_ERR,
+                        "inuse.attribute",
+                        new Object[]{arg.getNodeName()} );
+            }
+        }
 
         /**
          * Gets the value of a variable
+         *
          * @return the value or null
          */
-        protected Node get(String ns, String nm) {
-            int hash  = hashCode(ns, nm) & 0x7FFFFFFF;
+        protected Node get( String ns, String nm ) {
+            int hash = hashCode( ns, nm ) & 0x7FFFFFFF;
             int index = hash % table.length;
-	
-            for (Entry e = table[index]; e != null; e = e.next) {
-                if ((e.hash == hash) && e.match(ns, nm)) {
+
+            for ( Entry e = table[ index ]; e != null; e = e.next ) {
+                if ( ( e.hash == hash ) && e.match( ns, nm ) ) {
                     return e.value;
                 }
             }
             return null;
         }
-    
+
         /**
          * Sets a new value for the given variable
+         *
          * @return the old value or null
          */
-        protected Node put(String ns, String nm, Node value) {
-            int hash  = hashCode(ns, nm) & 0x7FFFFFFF;
+        protected Node put( String ns, String nm, Node value ) {
+            int hash = hashCode( ns, nm ) & 0x7FFFFFFF;
             int index = hash % table.length;
-	
-            for (Entry e = table[index]; e != null; e = e.next) {
-                if ((e.hash == hash) && e.match(ns, nm)) {
+
+            for ( Entry e = table[ index ]; e != null; e = e.next ) {
+                if ( ( e.hash == hash ) && e.match( ns, nm ) ) {
                     Node old = e.value;
                     e.value = value;
                     return old;
                 }
             }
-	
+
             // The key is not in the hash table
             int len = table.length;
-            if (count++ >= (len * 3) >>> 2) {
+            if ( count++ >= ( len - ( len >> 2 ) ) ) {
+                // more than 75% loaded: grow
                 rehash();
                 index = hash % table.length;
             }
-            
-            Entry e = new Entry(hash, ns, nm, value, table[index]);
-            table[index] = e;
+
+            Entry e = new Entry( hash, ns, nm, value, table[ index ] );
+            table[ index ] = e;
             return null;
         }
 
         /**
          * Removes an entry from the table.
+         *
          * @return the value or null.
          */
-        protected Node remove(String ns, String nm) {
-            int hash  = hashCode(ns, nm) & 0x7FFFFFFF;
+        protected Node remove( String ns, String nm ) {
+            int hash = hashCode( ns, nm ) & 0x7FFFFFFF;
             int index = hash % table.length;
-	
+
             Entry p = null;
-            for (Entry e = table[index]; e != null; e = e.next) {
-                if ((e.hash == hash) && e.match(ns, nm)) {
+            for ( Entry e = table[ index ]; e != null; e = e.next ) {
+                if ( ( e.hash == hash ) && e.match( ns, nm ) ) {
                     Node result = e.value;
-                    if (p == null) {
-                        table[index] = e.next;
+                    if ( p == null ) {
+                        table[ index ] = e.next;
                     } else {
                         p.next = e.next;
                     }
@@ -935,18 +940,18 @@
         }
 
         /**
-         * Rehash the table
+         * Rehash and grow the table.
          */
         protected void rehash () {
             Entry[] oldTable = table;
-	
+
             table = new Entry[oldTable.length * 2 + 1];
-	
+
             for (int i = oldTable.length-1; i >= 0; i--) {
                 for (Entry old = oldTable[i]; old != null;) {
                     Entry e = old;
                     old = old.next;
-                    
+
                     int index = e.hash % table.length;
                     e.next = table[index];
                     table[index] = e;
@@ -955,7 +960,7 @@
         }
 
         /**
-         * Computes a hash code corresponding to the given strings. 
+         * Computes a hash code corresponding to the given strings.
          */
         protected int hashCode(String ns, String nm) {
             int result = (ns == null) ? 0 : ns.hashCode();
@@ -965,34 +970,35 @@
 
     /**
      * To manage collisions in the attributes map.
+     * Implements a linked list of <code>Node</code>-objects.
      */
     protected static class Entry implements Serializable {
 
         /**
-         * The hash code
+         * The hash code, must not change after creation.
          */
-        public int hash;
-	
+        public int hash;       // should be final - would that break Serialization?
+
         /**
          * The namespace URI
          */
         public String namespaceURI;
-	
+
         /**
          * The node name.
          */
         public String name;
-        
+
         /**
          * The value
          */
         public Node value;
-	
+
         /**
          * The next entry
          */
         public Entry next;
-	
+
         /**
          * Creates a new entry
          */
@@ -1003,7 +1009,7 @@
             this.value = value;
             this.next = next;
         }
-        
+
         /**
          * Whether this entry match the given keys.
          */

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractElement.java?rev=424999&r1=424998&r2=424999&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractElement.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractElement.java Mon Jul 24 03:34:44 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 2001-2003,2005  The Apache Software Foundation 
+   Copyright 2001-2003,2005-2006  The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
 import org.apache.batik.dom.AbstractDocument;
 import org.apache.batik.dom.events.NodeEventTarget;
 import org.apache.batik.util.SoftDoublyIndexedTable;
+
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.NamedNodeMap;
@@ -38,7 +39,7 @@
 public abstract class AbstractElement
         extends org.apache.batik.dom.AbstractElement
         implements NodeEventTarget, CSSNavigableNode {
-    
+
     /**
      * The live attribute values.
      */
@@ -58,7 +59,7 @@
     protected AbstractElement(String prefix, AbstractDocument owner) {
         ownerDocument = owner;
         setPrefix(prefix);
-	initializeAttributes();
+      	initializeAttributes();
     }
 
     // CSSNavigableNode ///////////////////////////////////////////////////
@@ -169,7 +170,7 @@
      * Creates the attribute list.
      */
     protected NamedNodeMap createAttributes() {
-	return new ExtendedNamedNodeHashMap();
+      	return new ExtendedNamedNodeHashMap();
     }
 
     /**
@@ -180,9 +181,9 @@
     */
     public void setUnspecifiedAttribute(String nsURI, String name,
                                         String value) {
-	if (attributes == null) {
-	    attributes = createAttributes();
-	}
+        if (attributes == null) {
+            attributes = createAttributes();
+        }
         ((ExtendedNamedNodeHashMap)attributes).
             setUnspecifiedAttribute(nsURI, name, value);
     }
@@ -234,22 +235,22 @@
      * Exports this node to the given document.
      */
     protected Node export(Node n, AbstractDocument d) {
-	super.export(n, d);
-        ((AbstractElement)n).initializeAttributes();
+        super.export(n, d);
+              ((AbstractElement)n).initializeAttributes();
 
-	super.export(n, d);
-	return n;
+        super.export(n, d);
+        return n;
     }
 
     /**
      * Deeply exports this node to the given document.
      */
     protected Node deepExport(Node n, AbstractDocument d) {
-	super.export(n, d);
-        ((AbstractElement)n).initializeAttributes();
+        super.export(n, d);
+              ((AbstractElement)n).initializeAttributes();
 
-	super.deepExport(n, d);
-	return n;
+        super.deepExport(n, d);
+        return n;
     }
 
     /**
@@ -263,54 +264,55 @@
         public ExtendedNamedNodeHashMap() {
         }
 
-	/**
-	 * Adds an unspecified attribute to the map.
+        /**
+         * Adds an unspecified attribute to the map.
+         *
          * @param nsURI The attribute namespace URI.
          * @param name The attribute's qualified name.
          * @param value The attribute's default value.
-	 */
-	public void setUnspecifiedAttribute(String nsURI, String name,
-                                            String value) {
-	    Attr attr = getOwnerDocument().createAttributeNS(nsURI, name);
-	    attr.setValue(value);
-	    ((AbstractAttr)attr).setSpecified(false);
-            setNamedItemNS(attr);
-	}
-
- 	/**
-	 * <b>DOM</b>: Implements {@link
-         * NamedNodeMap#removeNamedItemNS(String,String)}.
-	 */
-	public Node removeNamedItemNS(String namespaceURI, String localName)
-	    throws DOMException {
-	    if (isReadonly()) {
-		throw createDOMException
-                    (DOMException.NO_MODIFICATION_ALLOWED_ERR,
-                     "readonly.node.map",
-                     new Object[] {});
-	    }
-	    if (localName == null) {
-		throw createDOMException(DOMException.NOT_FOUND_ERR,
-					 "attribute.missing",
-					 new Object[] { "" });
-	    }
-	    AbstractAttr n = (AbstractAttr)remove(namespaceURI, localName);
-	    if (n == null) {
-		throw createDOMException(DOMException.NOT_FOUND_ERR,
-					 "attribute.missing",
-					 new Object[] { localName });
-	    }
-	    n.setOwnerElement(null);
+         */
+        public void setUnspecifiedAttribute( String nsURI, String name,
+                                             String value ) {
+            Attr attr = getOwnerDocument().createAttributeNS( nsURI, name );
+            attr.setValue( value );
+            ( (AbstractAttr)attr ).setSpecified( false );
+            setNamedItemNS( attr );
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link NamedNodeMap#removeNamedItemNS(String,String)}.
+         */
+        public Node removeNamedItemNS( String namespaceURI, String localName )
+                throws DOMException {
+            if ( isReadonly() ) {
+                throw createDOMException
+                        ( DOMException.NO_MODIFICATION_ALLOWED_ERR,
+                                "readonly.node.map",
+                                new Object[]{} );
+            }
+            if ( localName == null ) {
+                throw createDOMException( DOMException.NOT_FOUND_ERR,
+                        "attribute.missing",
+                        new Object[]{""} );
+            }
+            AbstractAttr n = (AbstractAttr)remove( namespaceURI, localName );
+            if ( n == null ) {
+                throw createDOMException( DOMException.NOT_FOUND_ERR,
+                        "attribute.missing",
+                        new Object[]{localName} );
+            }
+            n.setOwnerElement( null );
             String prefix = n.getPrefix();
-	    
+
             // Reset the attribute to its default value
-            if (!resetAttribute(namespaceURI, prefix, localName)) {
+            if ( !resetAttribute( namespaceURI, prefix, localName ) ) {
                 // Mutation event
-                fireDOMAttrModifiedEvent(n.getNodeName(), n,
-                                         n.getNodeValue(), "",
-                                         MutationEvent.REMOVAL);
+                fireDOMAttrModifiedEvent( n.getNodeName(), n,
+                        n.getNodeValue(), "",
+                        MutationEvent.REMOVAL );
             }
             return n;
-	}
+        }
     }
+
 }

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DocumentDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DocumentDescriptor.java?rev=424999&r1=424998&r2=424999&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DocumentDescriptor.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DocumentDescriptor.java Mon Jul 24 03:34:44 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 2001,2003  The Apache Software Foundation 
+   Copyright 2001,2003,2006  The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -28,38 +28,38 @@
  * @version $Id$
  */
 public class DocumentDescriptor {
-	    
+
     /**
      * The table initial capacity
      */
-    protected final static int INITIAL_CAPACITY = 101;
+    protected static final int INITIAL_CAPACITY = 101;
 
     /**
      * The underlying array
      */
     protected Entry[] table;
-	    
+
     /**
      * The number of entries
      */
     protected int count;
-	    
+
     /**
      * Creates a new table.
      */
     public DocumentDescriptor() {
-	table = new Entry[INITIAL_CAPACITY];
+      	table = new Entry[INITIAL_CAPACITY];
     }
 
     /**
      * Returns the number of elements in the document.
      */
     public int getNumberOfElements() {
-	synchronized (this) {
-            return count;
+        synchronized (this) {
+                  return count;
         }
     }
-    
+
     /**
      * Returns the location line in the source file of the end element.
      * @return zero if the information is unknown.
@@ -68,18 +68,18 @@
         synchronized (this) {
             int hash = elt.hashCode() & 0x7FFFFFFF;
             int index = hash % table.length;
-	
+
             for (Entry e = table[index]; e != null; e = e.next) {
-                if (e.hash != hash) 
+                if (e.hash != hash)
                     continue;
                 Object o = e.get();
-                if (o == elt) 
+                if (o == elt)
                     return e.locationLine;
             }
         }
         return 0;
     }
-    
+
     /**
      * Returns the location column in the source file of the end element.
      * @return zero if the information is unknown.
@@ -88,18 +88,18 @@
         synchronized (this) {
             int hash = elt.hashCode() & 0x7FFFFFFF;
             int index = hash % table.length;
-	
+
             for (Entry e = table[index]; e != null; e = e.next) {
-                if (e.hash != hash) 
+                if (e.hash != hash)
                     continue;
                 Object o = e.get();
-                if (o == elt) 
+                if (o == elt)
                     return e.locationColumn;
             }
         }
         return 0;
     }
-    
+
     /**
      * Sets the location in the source file of the end element.
      */
@@ -107,22 +107,23 @@
         synchronized (this) {
             int hash  = elt.hashCode() & 0x7FFFFFFF;
             int index = hash % table.length;
-	
+
             for (Entry e = table[index]; e != null; e = e.next) {
-                if (e.hash != hash) 
+                if (e.hash != hash)
                     continue;
                 Object o = e.get();
                 if (o == elt)
                     e.locationLine = line;
             }
-	
+
             // The key is not in the hash table
             int len = table.length;
-            if (count++ >= (len * 3) >>> 2) {
+            if (count++ >= (len - ( len >> 2 ))) {
+                // more than 75% loaded: grow              
                 rehash();
                 index = hash % table.length;
             }
-	
+
             Entry e = new Entry(hash, elt, line, col, table[index]);
             table[index] = e;
         }
@@ -132,20 +133,20 @@
      * Rehash the table
      */
     protected void rehash () {
-	Entry[] oldTable = table;
-	
-	table = new Entry[oldTable.length * 2 + 1];
-	
-	for (int i = oldTable.length-1; i >= 0; i--) {
-	    for (Entry old = oldTable[i]; old != null;) {
-		Entry e = old;
-		old = old.next;
-		
-		int index = e.hash % table.length;
-		e.next = table[index];
-		table[index] = e;
-	    }
-	}
+        Entry[] oldTable = table;
+
+        table = new Entry[oldTable.length * 2 + 1];
+
+        for (int i = oldTable.length-1; i >= 0; i--) {
+            for (Entry old = oldTable[i]; old != null;) {
+                Entry e = old;
+                old = old.next;
+
+                int index = e.hash % table.length;
+                e.next = table[index];
+                table[index] = e;
+            }
+        }
     }
 
     protected void removeEntry(Entry e) {
@@ -163,7 +164,7 @@
             if (prev == null)
                 // First entry.
                 table[index] = curr.next;
-            else 
+            else
                 prev.next = curr.next;
             count--;
         }
@@ -173,26 +174,26 @@
      * To manage collisions
      */
     protected class Entry extends CleanerThread.WeakReferenceCleared {
-	/**
-	 * The hash code
-	 */
-	public int hash;
-	
-	/**
-	 * The line number.
-	 */
-	public int locationLine;
-	
-	/**
-	 * The column number.
-	 */
-	public int locationColumn;
-	
-	/**
-	 * The next entry
-	 */
-	public Entry next;
-	
+      /**
+       * The hash code
+       */
+      public int hash;
+
+      /**
+       * The line number.
+       */
+      public int locationLine;
+
+      /**
+       * The column number.
+       */
+      public int locationColumn;
+
+      /**
+       * The next entry
+       */
+      public Entry next;
+
 	/**
 	 * Creates a new entry
 	 */
@@ -202,10 +203,10 @@
                      int locationColumn,
                      Entry next) {
             super(element);
-	    this.hash           = hash;
-	    this.locationLine   = locationLine;
+            this.hash           = hash;
+            this.locationLine   = locationLine;
             this.locationColumn = locationColumn;
-	    this.next           = next;
+            this.next           = next;
 	}
 
         public void cleared() {

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DoublyIndexedTable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DoublyIndexedTable.java?rev=424999&r1=424998&r2=424999&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DoublyIndexedTable.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/util/DoublyIndexedTable.java Mon Jul 24 03:34:44 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 2001  The Apache Software Foundation 
+   Copyright 2001,2006  The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -84,7 +84,8 @@
 
         // The key is not in the hash table
         int len = table.length;
-        if (count++ >= (len * 3) >>> 2) {
+        if (count++ >= (len - (len >> 2))) {
+            // more than 75% loaded: grow
             rehash();
             index = hash % table.length;
         }
@@ -191,7 +192,7 @@
     }
 
     /**
-     * Computes a hash code corresponding to the given objects. 
+     * Computes a hash code corresponding to the given objects.
      */
     protected int hashCode(Object o1, Object o2) {
         int result = (o1 == null) ? 0 : o1.hashCode();
@@ -201,7 +202,7 @@
     /**
      * An entry in the {@link DoublyIndexedTable}.
      */
-    public static class Entry {
+    protected static class Entry {
 
         /**
          * The hash code.