Java Doc for AbstractLinkedMap.java in  » Library » Apache-common-Collections » org » apache » commons » collections » map » 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.map 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.commons.collections.map.AbstractHashedMap
   org.apache.commons.collections.map.AbstractLinkedMap

All known Subclasses:   org.apache.commons.collections.map.LinkedMap,  org.apache.commons.collections.map.LRUMap,
AbstractLinkedMap
public class AbstractLinkedMap extends AbstractHashedMap implements OrderedMap(Code)
An abstract implementation of a hash-based map that links entries to create an ordered map and which provides numerous points for subclasses to override.

This class implements all the features necessary for a subclass linked hash-based map. Key-value entries are stored in instances of the LinkEntry class which can be overridden and replaced. The iterators can similarly be replaced, without the need to replace the KeySet, EntrySet and Values view classes.

Overridable methods are provided to change the default hashing behaviour, and to change how entries are added to and removed from the map. Hopefully, all you need for unusual subclasses is here.

This implementation maintains order by original insertion, but subclasses may work differently. The OrderedMap interface is implemented to provide access to bidirectional iteration and extra convenience methods.

The orderedMapIterator() method provides direct access to a bidirectional iterator. The iterators from the other views can also be cast to OrderedIterator if required.

All the available iterators can be reset back to the start by casting to ResettableIterator and calling reset().

The implementation is also designed to be subclassed, with lots of useful methods exposed.
since:
   Commons Collections 3.0
version:
   $Revision: 158688 $ $Date: 2005-03-22 22:14:15 +0000 (Tue, 22 Mar 2005) $
author:
   java util LinkedHashMap
author:
   Stephen Colebourne


Inner Class :protected static class LinkMapIterator extends LinkIterator implements OrderedMapIterator
Inner Class :protected static class EntrySetIterator extends LinkIterator
Inner Class :protected static class KeySetIterator extends EntrySetIterator
Inner Class :protected static class ValuesIterator extends LinkIterator
Inner Class :protected static class LinkEntry extends HashEntry
Inner Class :abstract protected static class LinkIterator implements OrderedIterator,ResettableIterator

Field Summary
protected transient  LinkEntryheader
    

Constructor Summary
protected  AbstractLinkedMap()
     Constructor only used in deserialization, do not use otherwise.
protected  AbstractLinkedMap(int initialCapacity, float loadFactor, int threshold)
     Constructor which performs no validation on the passed in parameters.
protected  AbstractLinkedMap(int initialCapacity)
     Constructs a new, empty map with the specified initial capacity.
protected  AbstractLinkedMap(int initialCapacity, float loadFactor)
     Constructs a new, empty map with the specified initial capacity and load factor.
protected  AbstractLinkedMap(Map map)
     Constructor copying elements from another map.

Method Summary
protected  voidaddEntry(HashEntry entry, int hashIndex)
     Adds an entry into this map, maintaining insertion order.
public  voidclear()
     Clears the map, resetting the size to zero and nullifying references to avoid garbage collection issues.
public  booleancontainsValue(Object value)
     Checks whether the map contains the specified value.
protected  HashEntrycreateEntry(HashEntry next, int hashCode, Object key, Object value)
     Creates an entry to store the data.
protected  IteratorcreateEntrySetIterator()
     Creates an entry set iterator.
protected  IteratorcreateKeySetIterator()
     Creates a key set iterator.
protected  IteratorcreateValuesIterator()
     Creates a values iterator.
protected  LinkEntryentryAfter(LinkEntry entry)
     Gets the after field from a LinkEntry.
protected  LinkEntryentryBefore(LinkEntry entry)
     Gets the before field from a LinkEntry.
public  ObjectfirstKey()
     Gets the first key in the map, which is the most recently inserted.
protected  LinkEntrygetEntry(int index)
     Gets the key at the specified index.
protected  voidinit()
     Initialise this subclass during construction.
public  ObjectlastKey()
     Gets the last key in the map, which is the first inserted.
public  MapIteratormapIterator()
     Gets an iterator over the map. Changes made to the iterator affect this map.

A MapIterator returns the keys in the map.

public  ObjectnextKey(Object key)
     Gets the next key in sequence.
public  OrderedMapIteratororderedMapIterator()
     Gets a bidirectional iterator over the map. Changes made to the iterator affect this map.

A MapIterator returns the keys in the map.

public  ObjectpreviousKey(Object key)
     Gets the previous key in sequence.
protected  voidremoveEntry(HashEntry entry, int hashIndex, HashEntry previous)
     Removes an entry from the map and the linked list.

Field Detail
header
protected transient LinkEntry header(Code)
Header in the linked list




Constructor Detail
AbstractLinkedMap
protected AbstractLinkedMap()(Code)
Constructor only used in deserialization, do not use otherwise.



AbstractLinkedMap
protected AbstractLinkedMap(int initialCapacity, float loadFactor, int threshold)(Code)
Constructor which performs no validation on the passed in parameters.
Parameters:
  initialCapacity - the initial capacity, must be a power of two
Parameters:
  loadFactor - the load factor, must be > 0.0f and generally < 1.0f
Parameters:
  threshold - the threshold, must be sensible



AbstractLinkedMap
protected AbstractLinkedMap(int initialCapacity)(Code)
Constructs a new, empty map with the specified initial capacity.
Parameters:
  initialCapacity - the initial capacity
throws:
  IllegalArgumentException - if the initial capacity is less than one



AbstractLinkedMap
protected AbstractLinkedMap(int initialCapacity, float loadFactor)(Code)
Constructs a new, empty map with the specified initial capacity and load factor.
Parameters:
  initialCapacity - the initial capacity
Parameters:
  loadFactor - the load factor
throws:
  IllegalArgumentException - if the initial capacity is less than one
throws:
  IllegalArgumentException - if the load factor is less than zero



AbstractLinkedMap
protected AbstractLinkedMap(Map map)(Code)
Constructor copying elements from another map.
Parameters:
  map - the map to copy
throws:
  NullPointerException - if the map is null




Method Detail
addEntry
protected void addEntry(HashEntry entry, int hashIndex)(Code)
Adds an entry into this map, maintaining insertion order.

This implementation adds the entry to the data storage table and to the end of the linked list.
Parameters:
  entry - the entry to add
Parameters:
  hashIndex - the index into the data array to store at




clear
public void clear()(Code)
Clears the map, resetting the size to zero and nullifying references to avoid garbage collection issues.



containsValue
public boolean containsValue(Object value)(Code)
Checks whether the map contains the specified value.
Parameters:
  value - the value to search for true if the map contains the value



createEntry
protected HashEntry createEntry(HashEntry next, int hashCode, Object key, Object value)(Code)
Creates an entry to store the data.

This implementation creates a new LinkEntry instance.
Parameters:
  next - the next entry in sequence
Parameters:
  hashCode - the hash code to use
Parameters:
  key - the key to store
Parameters:
  value - the value to store the newly created entry




createEntrySetIterator
protected Iterator createEntrySetIterator()(Code)
Creates an entry set iterator. Subclasses can override this to return iterators with different properties. the entrySet iterator



createKeySetIterator
protected Iterator createKeySetIterator()(Code)
Creates a key set iterator. Subclasses can override this to return iterators with different properties. the keySet iterator



createValuesIterator
protected Iterator createValuesIterator()(Code)
Creates a values iterator. Subclasses can override this to return iterators with different properties. the values iterator



entryAfter
protected LinkEntry entryAfter(LinkEntry entry)(Code)
Gets the after field from a LinkEntry. Used in subclasses that have no visibility of the field.
Parameters:
  entry - the entry to query, must not be null the after field of the entry
throws:
  NullPointerException - if the entry is null
since:
   Commons Collections 3.1



entryBefore
protected LinkEntry entryBefore(LinkEntry entry)(Code)
Gets the before field from a LinkEntry. Used in subclasses that have no visibility of the field.
Parameters:
  entry - the entry to query, must not be null the before field of the entry
throws:
  NullPointerException - if the entry is null
since:
   Commons Collections 3.1



firstKey
public Object firstKey()(Code)
Gets the first key in the map, which is the most recently inserted. the most recently inserted key



getEntry
protected LinkEntry getEntry(int index)(Code)
Gets the key at the specified index.
Parameters:
  index - the index to retrieve the key at the specified index
throws:
  IndexOutOfBoundsException - if the index is invalid



init
protected void init()(Code)
Initialise this subclass during construction.

NOTE: As from v3.2 this method calls AbstractLinkedMap.createEntry(HashEntry,int,Object,Object) to create the map entry object.




lastKey
public Object lastKey()(Code)
Gets the last key in the map, which is the first inserted. the eldest key



mapIterator
public MapIterator mapIterator()(Code)
Gets an iterator over the map. Changes made to the iterator affect this map.

A MapIterator returns the keys in the map. It also provides convenient methods to get the key and value, and set the value. It avoids the need to create an entrySet/keySet/values object. the map iterator




nextKey
public Object nextKey(Object key)(Code)
Gets the next key in sequence.
Parameters:
  key - the key to get after the next key



orderedMapIterator
public OrderedMapIterator orderedMapIterator()(Code)
Gets a bidirectional iterator over the map. Changes made to the iterator affect this map.

A MapIterator returns the keys in the map. It also provides convenient methods to get the key and value, and set the value. It avoids the need to create an entrySet/keySet/values object. the map iterator




previousKey
public Object previousKey(Object key)(Code)
Gets the previous key in sequence.
Parameters:
  key - the key to get before the previous key



removeEntry
protected void removeEntry(HashEntry entry, int hashIndex, HashEntry previous)(Code)
Removes an entry from the map and the linked list.

This implementation removes the entry from the linked list chain, then calls the superclass implementation.
Parameters:
  entry - the entry to remove
Parameters:
  hashIndex - the index into the data structure
Parameters:
  previous - the previous entry in the chain




Fields inherited from org.apache.commons.collections.map.AbstractHashedMap
final protected static int DEFAULT_CAPACITY(Code)(Java Doc)
final protected static float DEFAULT_LOAD_FACTOR(Code)(Java Doc)
final protected static int DEFAULT_THRESHOLD(Code)(Java Doc)
final protected static String GETKEY_INVALID(Code)(Java Doc)
final protected static String GETVALUE_INVALID(Code)(Java Doc)
final protected static int MAXIMUM_CAPACITY(Code)(Java Doc)
final protected static String NO_NEXT_ENTRY(Code)(Java Doc)
final protected static String NO_PREVIOUS_ENTRY(Code)(Java Doc)
final protected static Object NULL(Code)(Java Doc)
final protected static String REMOVE_INVALID(Code)(Java Doc)
final protected static String SETVALUE_INVALID(Code)(Java Doc)
protected transient HashEntry[] data(Code)(Java Doc)
protected transient EntrySet entrySet(Code)(Java Doc)
protected transient KeySet keySet(Code)(Java Doc)
protected transient float loadFactor(Code)(Java Doc)
protected transient int modCount(Code)(Java Doc)
protected transient int size(Code)(Java Doc)
protected transient int threshold(Code)(Java Doc)
protected transient Values values(Code)(Java Doc)

Methods inherited from org.apache.commons.collections.map.AbstractHashedMap
protected void addEntry(HashEntry entry, int hashIndex)(Code)(Java Doc)
protected void addMapping(int hashIndex, int hashCode, Object key, Object value)(Code)(Java Doc)
protected int calculateNewCapacity(int proposedCapacity)(Code)(Java Doc)
protected int calculateThreshold(int newCapacity, float factor)(Code)(Java Doc)
protected void checkCapacity()(Code)(Java Doc)
public void clear()(Code)(Java Doc)
protected Object clone()(Code)(Java Doc)
public boolean containsKey(Object key)(Code)(Java Doc)
public boolean containsValue(Object value)(Code)(Java Doc)
protected Object convertKey(Object key)(Code)(Java Doc)
protected HashEntry createEntry(HashEntry next, int hashCode, Object key, Object value)(Code)(Java Doc)
protected Iterator createEntrySetIterator()(Code)(Java Doc)
protected Iterator createKeySetIterator()(Code)(Java Doc)
protected Iterator createValuesIterator()(Code)(Java Doc)
protected void destroyEntry(HashEntry entry)(Code)(Java Doc)
protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException(Code)(Java Doc)
protected void doWriteObject(ObjectOutputStream out) throws IOException(Code)(Java Doc)
protected void ensureCapacity(int newCapacity)(Code)(Java Doc)
protected int entryHashCode(HashEntry entry)(Code)(Java Doc)
protected Object entryKey(HashEntry entry)(Code)(Java Doc)
protected HashEntry entryNext(HashEntry entry)(Code)(Java Doc)
public Set entrySet()(Code)(Java Doc)
protected Object entryValue(HashEntry entry)(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
public Object get(Object key)(Code)(Java Doc)
protected HashEntry getEntry(Object key)(Code)(Java Doc)
protected int hash(Object key)(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
protected int hashIndex(int hashCode, int dataSize)(Code)(Java Doc)
protected void init()(Code)(Java Doc)
public boolean isEmpty()(Code)(Java Doc)
protected boolean isEqualKey(Object key1, Object key2)(Code)(Java Doc)
protected boolean isEqualValue(Object value1, Object value2)(Code)(Java Doc)
public Set keySet()(Code)(Java Doc)
public MapIterator mapIterator()(Code)(Java Doc)
public Object put(Object key, Object value)(Code)(Java Doc)
public void putAll(Map map)(Code)(Java Doc)
public Object remove(Object key)(Code)(Java Doc)
protected void removeEntry(HashEntry entry, int hashIndex, HashEntry previous)(Code)(Java Doc)
protected void removeMapping(HashEntry entry, int hashIndex, HashEntry previous)(Code)(Java Doc)
protected void reuseEntry(HashEntry entry, int hashIndex, int hashCode, Object key, Object value)(Code)(Java Doc)
public int size()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
protected void updateEntry(HashEntry entry, Object newValue)(Code)(Java Doc)
public Collection values()(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.