Java Doc for ReferenceMap.java in  » Inversion-of-Control » guice-1.0 » com » google » inject » util » 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 » Inversion of Control » guice 1.0 » com.google.inject.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.google.inject.util.ReferenceMap

ReferenceMap
public class ReferenceMap implements Map<K, V>,Serializable(Code)
Concurrent hash map that wraps keys and/or values in soft or weak references. Does not support null keys or values. Uses identity equality for weak and soft keys.

The concurrent semantics of ConcurrentHashMap combined with the fact that the garbage collector can asynchronously reclaim and clean up after keys and values at any time can lead to some racy semantics. For example, ReferenceMap.size() returns an upper bound on the size, i.e. the actual size may be smaller in cases where the key or value has been reclaimed but the map entry has not been cleaned up yet.

Another example: If ReferenceMap.get(Object) cannot find an existing entry for a key, it will try to create one. This operation is not atomic. One thread could ReferenceMap.put(Object,Object) a value between the time another thread running get() checks for an entry and decides to create one. In this case, the newly created value will replace the put value in the map. Also, two threads running get() concurrently can potentially create duplicate values for a given key.

In other words, this class is great for caching but not atomicity.
author:
   crazybob@google.com (Bob Lee)


Inner Class :interface InternalReference
Inner Class :static class ReferenceAwareWrapper
Inner Class :static class KeyReferenceAwareWrapper extends ReferenceAwareWrapper
Inner Class :class SoftKeyReference extends FinalizableSoftReference implements InternalReference
Inner Class :class WeakKeyReference extends FinalizableWeakReference implements InternalReference
Inner Class :class SoftValueReference extends FinalizableSoftReference implements InternalReference
Inner Class :class WeakValueReference extends FinalizableWeakReference implements InternalReference
Inner Class :protected interface Strategy
Inner Class :protected enum PutStrategy implements Strategy
Inner Class :class Entry implements Map.Entry<K, V>

Field Summary
transient  ConcurrentMap<Object, Object>delegate
    
final  ReferenceTypekeyReferenceType
    
final  ReferenceTypevalueReferenceType
    

Constructor Summary
public  ReferenceMap(ReferenceType keyReferenceType, ReferenceType valueReferenceType)
     Concurrent hash map that wraps keys and/or values based on specified reference types.

Method Summary
public  voidclear()
    
public  booleancontainsKey(Object key)
    
public  booleancontainsValue(Object value)
    
 Objectdereference(ReferenceType referenceType, Object reference)
     Returns the refererent for reference given its reference type.
 TdereferenceCollection(ReferenceType referenceType, T in, T out)
     Dereferences elements in in using referenceType and puts them in out .
 EntrydereferenceEntry(Map.Entry<Object, Object> entry)
     Dereferences an entry.
 KdereferenceKey(Object o)
     Converts a reference to a key.
 Set<K>dereferenceKeySet(Set keyReferences)
     Dereferences a set of key references.
 VdereferenceValue(Object o)
     Converts a reference to a value.
 Collection<V>dereferenceValues(Collection valueReferences)
     Dereferences a collection of value references.
static  voidensureNotNull(Object o)
    
static  voidensureNotNull(Object... array)
    
public  Set<Map.Entry<K, V>>entrySet()
     Returns an unmodifiable set view of the entries in this map.
 Vexecute(Strategy strategy, K key, V value)
    
public  Vget(Object key)
    
protected  PutStrategygetPutStrategy()
    
 VinternalGet(K key)
    
public  booleanisEmpty()
    
static  intkeyHashCode(Object key)
    
public  Set<K>keySet()
     Returns an unmodifiable set view of the keys in this map.
 ObjectmakeKeyReferenceAware(Object o)
     Wraps key so it can be compared to a referenced key for equality.
 ObjectmakeValueReferenceAware(Object o)
     Wraps value so it can be compared to a referenced value for equality.
public  Vput(K key, V value)
    
public  voidputAll(Map<? extends K, ? extends V> t)
    
public  VputIfAbsent(K key, V value)
    
protected  StrategyputIfAbsentStrategy()
    
protected  StrategyputStrategy()
    
static  booleanreferenceEquals(Reference r, Object o)
     Tests weak and soft references for identity equality.
 ObjectreferenceKey(K key)
     Creates a reference for a key.
 ObjectreferenceValue(Object keyReference, Object value)
     Creates a reference for a value.
public  Vremove(Object key)
    
public  booleanremove(Object key, Object value)
    
public  booleanreplace(K key, V oldValue, V newValue)
    
public  Vreplace(K key, V value)
    
protected  StrategyreplaceStrategy()
    
public  intsize()
    
public  Collection<V>values()
     Returns an unmodifiable set view of the values in this map.

Field Detail
delegate
transient ConcurrentMap<Object, Object> delegate(Code)



keyReferenceType
final ReferenceType keyReferenceType(Code)



valueReferenceType
final ReferenceType valueReferenceType(Code)




Constructor Detail
ReferenceMap
public ReferenceMap(ReferenceType keyReferenceType, ReferenceType valueReferenceType)(Code)
Concurrent hash map that wraps keys and/or values based on specified reference types.
Parameters:
  keyReferenceType - key reference type
Parameters:
  valueReferenceType - value reference type




Method Detail
clear
public void clear()(Code)



containsKey
public boolean containsKey(Object key)(Code)



containsValue
public boolean containsValue(Object value)(Code)



dereference
Object dereference(ReferenceType referenceType, Object reference)(Code)
Returns the refererent for reference given its reference type.



dereferenceCollection
T dereferenceCollection(ReferenceType referenceType, T in, T out)(Code)
Dereferences elements in in using referenceType and puts them in out . Returns out .



dereferenceEntry
Entry dereferenceEntry(Map.Entry<Object, Object> entry)(Code)
Dereferences an entry. Returns null if the key or value has been gc'ed.



dereferenceKey
K dereferenceKey(Object o)(Code)
Converts a reference to a key.



dereferenceKeySet
Set<K> dereferenceKeySet(Set keyReferences)(Code)
Dereferences a set of key references.



dereferenceValue
V dereferenceValue(Object o)(Code)
Converts a reference to a value.



dereferenceValues
Collection<V> dereferenceValues(Collection valueReferences)(Code)
Dereferences a collection of value references.



ensureNotNull
static void ensureNotNull(Object o)(Code)



ensureNotNull
static void ensureNotNull(Object... array)(Code)



entrySet
public Set<Map.Entry<K, V>> entrySet()(Code)
Returns an unmodifiable set view of the entries in this map. As this method creates a defensive copy, the performance is O(n).



execute
V execute(Strategy strategy, K key, V value)(Code)



get
public V get(Object key)(Code)



getPutStrategy
protected PutStrategy getPutStrategy()(Code)



internalGet
V internalGet(K key)(Code)



isEmpty
public boolean isEmpty()(Code)



keyHashCode
static int keyHashCode(Object key)(Code)



keySet
public Set<K> keySet()(Code)
Returns an unmodifiable set view of the keys in this map. As this method creates a defensive copy, the performance is O(n).



makeKeyReferenceAware
Object makeKeyReferenceAware(Object o)(Code)
Wraps key so it can be compared to a referenced key for equality.



makeValueReferenceAware
Object makeValueReferenceAware(Object o)(Code)
Wraps value so it can be compared to a referenced value for equality.



put
public V put(K key, V value)(Code)



putAll
public void putAll(Map<? extends K, ? extends V> t)(Code)



putIfAbsent
public V putIfAbsent(K key, V value)(Code)



putIfAbsentStrategy
protected Strategy putIfAbsentStrategy()(Code)



putStrategy
protected Strategy putStrategy()(Code)



referenceEquals
static boolean referenceEquals(Reference r, Object o)(Code)
Tests weak and soft references for identity equality. Compares references to other references and wrappers. If o is a reference, this returns true if r == o or if r and o reference the same non null object. If o is a wrapper, this returns true if r's referent is identical to the wrapped object.



referenceKey
Object referenceKey(K key)(Code)
Creates a reference for a key.



referenceValue
Object referenceValue(Object keyReference, Object value)(Code)
Creates a reference for a value.



remove
public V remove(Object key)(Code)



remove
public boolean remove(Object key, Object value)(Code)



replace
public boolean replace(K key, V oldValue, V newValue)(Code)



replace
public V replace(K key, V value)(Code)



replaceStrategy
protected Strategy replaceStrategy()(Code)



size
public int size()(Code)



values
public Collection<V> values()(Code)
Returns an unmodifiable set view of the values in this map. As this method creates a defensive copy, the performance is O(n).



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.