Java Doc for ReferenceMap.java in  » Library » Apache-common-Collections » org » apache » commons » collections » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common Collections » org.apache.commons.collections 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.AbstractMap
      org.apache.commons.collections.ReferenceMap

ReferenceMap
public class ReferenceMap extends AbstractMap (Code)
Hash-based Map implementation that allows mappings to be removed by the garbage collector.

When you construct a ReferenceMap, you can specify what kind of references are used to store the map's keys and values. If non-hard references are used, then the garbage collector can remove mappings if a key or value becomes unreachable, or if the JVM's memory is running low. For information on how the different reference types behave, see Reference .

Different types of references can be specified for keys and values. The keys can be configured to be weak but the values hard, in which case this class will behave like a WeakHashMap. However, you can also specify hard keys and weak values, or any other combination. The default constructor uses hard keys and soft values, providing a memory-sensitive cache.

The algorithms used are basically the same as those in java.util.HashMap . In particular, you can specify a load factor and capacity to suit your needs. All optional Map operations are supported.

However, this Map implementation does not allow null elements. Attempting to add a null key or or a null value to the map will raise a NullPointerException.

As usual, this implementation is not synchronized. You can use java.util.Collections.synchronizedMap to provide synchronized access to a ReferenceMap.
See Also:   java.lang.ref.Reference
since:
   Commons Collections 2.1
version:
   $Revision: 348444 $ $Date: 2005-11-23 14:06:56 +0000 (Wed, 23 Nov 2005) $
author:
   Paul Jack



Field Summary
final public static  intHARD
     Constant indicating that hard references should be used.
final public static  intSOFT
     Constant indicating that soft references should be used.
final public static  intWEAK
     Constant indicating that weak references should be used.

Constructor Summary
public  ReferenceMap()
     Constructs a new ReferenceMap that will use hard references to keys and soft references to values.
public  ReferenceMap(int keyType, int valueType, boolean purgeValues)
     Constructs a new ReferenceMap that will use the specified types of references.
public  ReferenceMap(int keyType, int valueType)
     Constructs a new ReferenceMap that will use the specified types of references.
public  ReferenceMap(int keyType, int valueType, int capacity, float loadFactor, boolean purgeValues)
     Constructs a new ReferenceMap with the specified reference types, load factor and initial capacity.
public  ReferenceMap(int keyType, int valueType, int capacity, float loadFactor)
     Constructs a new ReferenceMap with the specified reference types, load factor and initial capacity.

Method Summary
public  voidclear()
     Clears this map.
public  booleancontainsKey(Object key)
     Returns true if this map contains the given key.
public  SetentrySet()
     Returns a set view of this map's entries.
public  Objectget(Object key)
     Returns the value associated with the given key, if any.
public  booleanisEmpty()
     Returns true if this map is empty.
public  SetkeySet()
     Returns a set view of this map's keys.
public  Objectput(Object key, Object value)
     Associates the given key with the given value.

Neither the key nor the value may be null.

public  Objectremove(Object key)
     Removes the key and its associated value from this map.
public  intsize()
     Returns the size of this map.
public  Collectionvalues()
     Returns a collection view of this map's values.

Field Detail
HARD
final public static int HARD(Code)
Constant indicating that hard references should be used.



SOFT
final public static int SOFT(Code)
Constant indicating that soft references should be used.



WEAK
final public static int WEAK(Code)
Constant indicating that weak references should be used.




Constructor Detail
ReferenceMap
public ReferenceMap()(Code)
Constructs a new ReferenceMap that will use hard references to keys and soft references to values.



ReferenceMap
public ReferenceMap(int keyType, int valueType, boolean purgeValues)(Code)
Constructs a new ReferenceMap that will use the specified types of references.
Parameters:
  keyType - the type of reference to use for keys;must be ReferenceMap.HARD, ReferenceMap.SOFT, ReferenceMap.WEAK
Parameters:
  valueType - the type of reference to use for values;must be ReferenceMap.HARD, ReferenceMap.SOFT, ReferenceMap.WEAK
Parameters:
  purgeValues - should the value be automatically purged when the key is garbage collected



ReferenceMap
public ReferenceMap(int keyType, int valueType)(Code)
Constructs a new ReferenceMap that will use the specified types of references.
Parameters:
  keyType - the type of reference to use for keys;must be ReferenceMap.HARD, ReferenceMap.SOFT, ReferenceMap.WEAK
Parameters:
  valueType - the type of reference to use for values;must be ReferenceMap.HARD, ReferenceMap.SOFT, ReferenceMap.WEAK



ReferenceMap
public ReferenceMap(int keyType, int valueType, int capacity, float loadFactor, boolean purgeValues)(Code)
Constructs a new ReferenceMap with the specified reference types, load factor and initial capacity.
Parameters:
  keyType - the type of reference to use for keys;must be ReferenceMap.HARD, ReferenceMap.SOFT, ReferenceMap.WEAK
Parameters:
  valueType - the type of reference to use for values;must be ReferenceMap.HARD, ReferenceMap.SOFT, ReferenceMap.WEAK
Parameters:
  capacity - the initial capacity for the map
Parameters:
  loadFactor - the load factor for the map
Parameters:
  purgeValues - should the value be automatically purged when the key is garbage collected



ReferenceMap
public ReferenceMap(int keyType, int valueType, int capacity, float loadFactor)(Code)
Constructs a new ReferenceMap with the specified reference types, load factor and initial capacity.
Parameters:
  keyType - the type of reference to use for keys;must be ReferenceMap.HARD, ReferenceMap.SOFT, ReferenceMap.WEAK
Parameters:
  valueType - the type of reference to use for values;must be ReferenceMap.HARD, ReferenceMap.SOFT, ReferenceMap.WEAK
Parameters:
  capacity - the initial capacity for the map
Parameters:
  loadFactor - the load factor for the map




Method Detail
clear
public void clear()(Code)
Clears this map.



containsKey
public boolean containsKey(Object key)(Code)
Returns true if this map contains the given key. true if the given key is in this map



entrySet
public Set entrySet()(Code)
Returns a set view of this map's entries. a set view of this map's entries



get
public Object get(Object key)(Code)
Returns the value associated with the given key, if any. the value associated with the given key, or nullif the key maps to no value



isEmpty
public boolean isEmpty()(Code)
Returns true if this map is empty. true if this map is empty



keySet
public Set keySet()(Code)
Returns a set view of this map's keys. a set view of this map's keys



put
public Object put(Object key, Object value)(Code)
Associates the given key with the given value.

Neither the key nor the value may be null.
Parameters:
  key - the key of the mapping
Parameters:
  value - the value of the mapping the last value associated with that key, or null if no value was associated with the key
throws:
  NullPointerException - if either the key or valueis null




remove
public Object remove(Object key)(Code)
Removes the key and its associated value from this map.
Parameters:
  key - the key to remove the value associated with that key, or null ifthe key was not in the map



size
public int size()(Code)
Returns the size of this map. the size of this map



values
public Collection values()(Code)
Returns a collection view of this map's values. a collection view of this map's values.



Methods inherited from java.util.AbstractMap
public void clear()(Code)(Java Doc)
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean containsKey(Object key)(Code)(Java Doc)
public boolean containsValue(Object value)(Code)(Java Doc)
abstract public Set<Entry<K, V>> entrySet()(Code)(Java Doc)
public boolean equals(Object o)(Code)(Java Doc)
public V get(Object key)(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
public boolean isEmpty()(Code)(Java Doc)
public Set<K> keySet()(Code)(Java Doc)
public V put(K key, V value)(Code)(Java Doc)
public void putAll(Map<? extends K, ? extends V> m)(Code)(Java Doc)
public V remove(Object key)(Code)(Java Doc)
public int size()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
public Collection<V> values()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.