You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2004/03/13 16:54:34 UTC

cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/map AbstractHashedMap.java AbstractLinkedMap.java

scolebourne    2004/03/13 07:54:34

  Modified:    collections RELEASE-NOTES.html
               collections/src/java/org/apache/commons/collections/map
                        AbstractHashedMap.java AbstractLinkedMap.java
  Log:
  AbstractHashedMap,AbstractLinkedMap add entryXxx() methods
  to get around protected scope limits in subclasses
  
  Revision  Changes    Path
  1.12      +14 -20    jakarta-commons/collections/RELEASE-NOTES.html
  
  Index: RELEASE-NOTES.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/RELEASE-NOTES.html,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RELEASE-NOTES.html	13 Mar 2004 12:43:43 -0000	1.11
  +++ RELEASE-NOTES.html	13 Mar 2004 15:54:34 -0000	1.12
  @@ -23,29 +23,23 @@
   
   <hr />
   
  -<center><h3>
  -NEW CLASSES
  -</h3></center>
  -
  -<p>These implementations are new to <i>Collections 3.1</i>:</p>
  -
  +<center><h3>NEW CLASSES</h3></center>
   <ul>
   </ul>
   
  -<hr />
  +<center><h3>ENHANCEMENTS</h3></center>
  +<ul>
  +<li>MultiKey - Add getKey(index) and size() methods and make constructor public</li>
  +<li>AbstractHashedMap,AbstractLinkedMap - Add methods to access entry methods when protected scope blocks</li>
  +</ul>
   
   <center><h3>BUG FIXES</h3></center>
  -<p>
  -[27159] AbstractHashedMap subclasses failed to clone() correctly
  -</p>
  -
  -<center><h3>ENHANCEMENTS</h3></center>
  -<p>
  -MultiKey - Add getKey(index) and size() methods and make constructor public
  -</p>
  +<ul>
  +<li>[27159] AbstractHashedMap subclasses failed to clone() correctly</li>
  +</ul>
   
  -<center><h3>CHANGES</h3></center>
  -<p>
  -[26470] TreeBidiMap - Add javadoc about requiring Comparable entries
  -MultiKey - Add extra explanatations, examples and warnings
  -</p>
  +<center><h3>JAVADOC</h3></center>
  +<ul>
  +<li>[26470] TreeBidiMap - Add javadoc about requiring Comparable entries</li>
  +<li>MultiKey - Add extra explanatations, examples and warnings</li>
  +</ul>
  
  
  
  1.13      +56 -2     jakarta-commons/collections/src/java/org/apache/commons/collections/map/AbstractHashedMap.java
  
  Index: AbstractHashedMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/AbstractHashedMap.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AbstractHashedMap.java	27 Feb 2004 00:24:05 -0000	1.12
  +++ AbstractHashedMap.java	13 Mar 2004 15:54:34 -0000	1.13
  @@ -645,6 +645,55 @@
       
       //-----------------------------------------------------------------------
       /**
  +     * Gets the <code>next</code> field from a <code>HashEntry</code>.
  +     * Used in subclasses that have no visibility of the field.
  +     * 
  +     * @param entry  the entry to query, must not be null
  +     * @return the <code>next</code> field of the entry
  +     * @throws NullPointerException if the entry is null
  +     */
  +    protected HashEntry entryNext(HashEntry entry) {
  +        return entry.next;
  +    }
  +    
  +    /**
  +     * Gets the <code>hashCode</code> field from a <code>HashEntry</code>.
  +     * Used in subclasses that have no visibility of the field.
  +     * 
  +     * @param entry  the entry to query, must not be null
  +     * @return the <code>hashCode</code> field of the entry
  +     * @throws NullPointerException if the entry is null
  +     */
  +    protected int entryHashCode(HashEntry entry) {
  +        return entry.hashCode;
  +    }
  +    
  +    /**
  +     * Gets the <code>key</code> field from a <code>HashEntry</code>.
  +     * Used in subclasses that have no visibility of the field.
  +     * 
  +     * @param entry  the entry to query, must not be null
  +     * @return the <code>key</code> field of the entry
  +     * @throws NullPointerException if the entry is null
  +     */
  +    protected Object entryKey(HashEntry entry) {
  +        return entry.key;
  +    }
  +    
  +    /**
  +     * Gets the <code>value</code> field from a <code>HashEntry</code>.
  +     * Used in subclasses that have no visibility of the field.
  +     * 
  +     * @param entry  the entry to query, must not be null
  +     * @return the <code>value</code> field of the entry
  +     * @throws NullPointerException if the entry is null
  +     */
  +    protected Object entryValue(HashEntry entry) {
  +        return entry.value;
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    /**
        * Gets an iterator over the map.
        * Changes made to the iterator affect this map.
        * <p>
  @@ -937,7 +986,12 @@
       
       //-----------------------------------------------------------------------
       /**
  -     * HashEntry used to store the data
  +     * HashEntry used to store the data.
  +     * <p>
  +     * If you subclass <code>AbstractHashedMap</code> but not <code>HashEntry</code>
  +     * then you will not be able to access the protected fields.
  +     * The <code>entryXxx()</code> methods on <code>AbstractHashedMap</code> exist
  +     * to provide the necessary access.
        */
       protected static class HashEntry implements Map.Entry, KeyValue {
           /** The next entry in the hash chain */
  
  
  
  1.10      +31 -2     jakarta-commons/collections/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java
  
  Index: AbstractLinkedMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractLinkedMap.java	18 Feb 2004 01:13:19 -0000	1.9
  +++ AbstractLinkedMap.java	13 Mar 2004 15:54:34 -0000	1.10
  @@ -293,6 +293,31 @@
       
       //-----------------------------------------------------------------------
       /**
  +     * Gets the <code>before</code> field from a <code>LinkEntry</code>.
  +     * Used in subclasses that have no visibility of the field.
  +     * 
  +     * @param entry  the entry to query, must not be null
  +     * @return the <code>before</code> field of the entry
  +     * @throws NullPointerException if the entry is null
  +     */
  +    protected LinkEntry entryBefore(LinkEntry entry) {
  +        return entry.before;
  +    }
  +    
  +    /**
  +     * Gets the <code>after</code> field from a <code>LinkEntry</code>.
  +     * Used in subclasses that have no visibility of the field.
  +     * 
  +     * @param entry  the entry to query, must not be null
  +     * @return the <code>after</code> field of the entry
  +     * @throws NullPointerException if the entry is null
  +     */
  +    protected LinkEntry entryAfter(LinkEntry entry) {
  +        return entry.after;
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    /**
        * Gets an iterator over the map.
        * Changes made to the iterator affect this map.
        * <p>
  @@ -467,9 +492,13 @@
       //-----------------------------------------------------------------------
       /**
        * LinkEntry that stores the data.
  +     * <p>
  +     * If you subclass <code>AbstractLinkedMap</code> but not <code>LinkEntry</code>
  +     * then you will not be able to access the protected fields.
  +     * The <code>entryXxx()</code> methods on <code>AbstractLinkedMap</code> exist
  +     * to provide the necessary access.
        */
       protected static class LinkEntry extends HashEntry {
  -        
           /** The entry before this one in the order */
           protected LinkEntry before;
           /** The entry after this one in the order */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org