jmcnally    2002/06/18 11:56:40

  Modified:    src/java/org/apache/jcs/engine/memory/lru
                        LRUMemoryCache.java
  Log:
  add another inner class to support hiding the MemoryElementDescriptor
  
  Revision  Changes    Path
  1.16      +42 -2     
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java
  
  Index: LRUMemoryCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/lru/LRUMemoryCache.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- LRUMemoryCache.java       6 Jun 2002 05:35:02 -0000       1.15
  +++ LRUMemoryCache.java       18 Jun 2002 18:56:39 -0000      1.16
  @@ -301,12 +301,52 @@
           }
           public Object next()
           {
  -            return ((MemoryElementDescriptor)i.next()).ce;
  +            return new MapEntryWrapper((Map.Entry)i.next());
           }
           public void remove()
           {
               i.remove();
           } 
  +        public boolean equals(Object o)
  +        {
  +            return i.equals(o);
  +        }
  +        public int hashCode()
  +        {
  +            return i.hashCode();
  +        }
  +    }
  +
  +    public class MapEntryWrapper
  +        implements Map.Entry
  +    {
  +        private final Map.Entry e;
  +        private MapEntryWrapper(Map.Entry e)
  +        {
  +            this.e = e;
  +        }
  +
  +        public boolean equals(Object o)
  +        {
  +            return e.equals(o);
  +        }
  +        public Object getKey()
  +        {
  +            return e.getKey();
  +        }
  +        public Object getValue()
  +        {
  +            return ((MemoryElementDescriptor)e.getValue()).ce;
  +        }
  +        public int hashCode()
  +        {
  +            return e.hashCode();
  +        }
  +        public Object setValue(Object value)
  +        {
  +            throw new UnsupportedOperationException("Use normal cache methods"
  +                + " to alter the contents of the cache.");
  +        }
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to