1 8 package org.apache.avalon.excalibur.cache.store; 9 10 import java.util.HashMap ; 11 12 15 public class MemoryStore 16 extends AbstractCacheStore 17 { 18 private HashMap m_entries; 19 private int m_capacity; 20 21 public MemoryStore( final int capacity ) 22 { 23 if ( capacity < 1 ) throw new IllegalArgumentException ( "Specified capacity must be at least 1" ); 24 25 m_capacity = capacity; 26 m_entries = new HashMap ( m_capacity ); 27 } 28 29 public int capacity() 30 { 31 return m_capacity; 32 } 33 34 public int size() 35 { 36 return m_entries.size(); 37 } 38 39 public Object put( final Object key, final Object value ) 40 { 41 return m_entries.put( key, value ); 42 } 43 44 public Object get( final Object key ) 45 { 46 return m_entries.get( key ); 47 } 48 49 public Object remove( final Object key ) 50 { 51 return m_entries.remove( key ); 52 } 53 54 public boolean containsKey( final Object key ) 55 { 56 return m_entries.containsKey( key ); 57 } 58 59 public Object [] keys() 60 { 61 return m_entries.keySet().toArray(); 62 } 63 } 64 | Popular Tags |