Java Doc for ListOrderedMap.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) 


java.lang.Object
   org.apache.commons.collections.map.AbstractMapDecorator
      org.apache.commons.collections.map.ListOrderedMap

ListOrderedMap
public class ListOrderedMap extends AbstractMapDecorator implements OrderedMap,Serializable(Code)
Decorates a Map to ensure that the order of addition is retained using a List to maintain order.

The order will be used via the iterators and toArray methods on the views. The order is also returned by the MapIterator. The orderedMapIterator() method accesses an iterator that can iterate both forwards and backwards through the map. In addition, non-interface methods are provided to access the map by index.

If an object is added to the Map for a second time, it will remain in the original position in the iteration.

Note that ListOrderedMap is not synchronized and is not thread-safe. If you wish to use this map from multiple threads concurrently, you must use appropriate synchronization. The simplest approach is to wrap this map using java.util.Collections.synchronizedMap(Map) . This class may throw exceptions when accessed by concurrent threads without synchronization.

This class is Serializable from Commons Collections 3.1.
since:
   Commons Collections 3.0
version:
   $Revision: 365406 $ $Date: 2006-01-02 19:34:53 +0000 (Mon, 02 Jan 2006) $
author:
   Henri Yandell
author:
   Stephen Colebourne
author:
   Matt Benson


Inner Class :static class ValuesView extends AbstractList
Inner Class :static class KeySetView extends AbstractSet
Inner Class :static class EntrySetView extends AbstractSet
Inner Class :static class ListOrderedIterator extends AbstractIteratorDecorator
Inner Class :static class ListOrderedMapEntry extends AbstractMapEntry
Inner Class :static class ListOrderedMapIterator implements OrderedMapIterator,ResettableIterator

Field Summary
final protected  ListinsertOrder
    

Constructor Summary
public  ListOrderedMap()
     Constructs a new empty ListOrderedMap that decorates a HashMap.
protected  ListOrderedMap(Map map)
     Constructor that wraps (not copies).

Method Summary
public  ListasList()
     Gets an unmodifiable List view of the keys which changes as the map changes.

The returned list is unmodifiable because changes to the values of the list (using java.util.ListIterator.set(Object) ) will effectively remove the value from the list and reinsert that value at the end of the list, which is an unexpected side effect of changing the value of a list.

public  voidclear()
    
public static  OrderedMapdecorate(Map map)
     Factory method to create an ordered map.
public  SetentrySet()
     Gets a view over the entries in the map.
public  ObjectfirstKey()
     Gets the first key in this map by insert order.
public  Objectget(int index)
     Gets the key at the specified index.
public  ObjectgetValue(int index)
     Gets the value at the specified index.
public  intindexOf(Object key)
     Gets the index of the specified key.
public  ListkeyList()
     Gets a view over the keys in the map as a List.
public  SetkeySet()
     Gets a view over the keys in the map.
public  ObjectlastKey()
     Gets the last key in this map by insert order.
public  MapIteratormapIterator()
    
public  ObjectnextKey(Object key)
     Gets the next key to the one specified using insert order.
public  OrderedMapIteratororderedMapIterator()
    
public  ObjectpreviousKey(Object key)
     Gets the previous key to the one specified using insert order.
public  Objectput(Object key, Object value)
    
public  Objectput(int index, Object key, Object value)
     Puts a key-value mapping into the map at the specified index.

If the map already contains the key, then the original mapping is removed and the new mapping added at the specified index. The remove may change the effect of the index.

public  voidputAll(Map map)
    
public  Objectremove(Object key)
    
public  Objectremove(int index)
     Removes the element at the specified index.
public  ObjectsetValue(int index, Object value)
     Sets the value at the specified index.
public  StringtoString()
     Returns the Map as a string.
public  ListvalueList()
     Gets a view over the values in the map as a List.
public  Collectionvalues()
     Gets a view over the values in the map.

Field Detail
insertOrder
final protected List insertOrder(Code)
Internal list to hold the sequence of objects




Constructor Detail
ListOrderedMap
public ListOrderedMap()(Code)
Constructs a new empty ListOrderedMap that decorates a HashMap.
since:
   Commons Collections 3.1



ListOrderedMap
protected ListOrderedMap(Map map)(Code)
Constructor that wraps (not copies).
Parameters:
  map - the map to decorate, must not be null
throws:
  IllegalArgumentException - if map is null




Method Detail
asList
public List asList()(Code)
Gets an unmodifiable List view of the keys which changes as the map changes.

The returned list is unmodifiable because changes to the values of the list (using java.util.ListIterator.set(Object) ) will effectively remove the value from the list and reinsert that value at the end of the list, which is an unexpected side effect of changing the value of a list. This occurs because changing the key, changes when the mapping is added to the map and thus where it appears in the list.

An alternative to this method is to use the better named ListOrderedMap.keyList() or ListOrderedMap.keySet() .
See Also:   ListOrderedMap.keyList()
See Also:   ListOrderedMap.keySet() The ordered list of keys.




clear
public void clear()(Code)



decorate
public static OrderedMap decorate(Map map)(Code)
Factory method to create an ordered map.

An ArrayList is used to retain order.
Parameters:
  map - the map to decorate, must not be null
throws:
  IllegalArgumentException - if map is null




entrySet
public Set entrySet()(Code)
Gets a view over the entries in the map.

The Set will be ordered by object insertion into the map. the fully modifiable set view over the entries




firstKey
public Object firstKey()(Code)
Gets the first key in this map by insert order. the first key currently in this map
throws:
  NoSuchElementException - if this map is empty



get
public Object get(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



getValue
public Object getValue(int index)(Code)
Gets the value at the specified index.
Parameters:
  index - the index to retrieve the key at the specified index
throws:
  IndexOutOfBoundsException - if the index is invalid



indexOf
public int indexOf(Object key)(Code)
Gets the index of the specified key.
Parameters:
  key - the key to find the index of the index, or -1 if not found



keyList
public List keyList()(Code)
Gets a view over the keys in the map as a List.

The List will be ordered by object insertion into the map. The List is unmodifiable.
See Also:   ListOrderedMap.keySet() the unmodifiable list view over the keys
since:
   Commons Collections 3.2




keySet
public Set keySet()(Code)
Gets a view over the keys in the map.

The Collection will be ordered by object insertion into the map.
See Also:   ListOrderedMap.keyList() the fully modifiable collection view over the keys




lastKey
public Object lastKey()(Code)
Gets the last key in this map by insert order. the last key currently in this map
throws:
  NoSuchElementException - if this map is empty



mapIterator
public MapIterator mapIterator()(Code)



nextKey
public Object nextKey(Object key)(Code)
Gets the next key to the one specified using insert order. This method performs a list search to find the key and is O(n).
Parameters:
  key - the key to find previous for the next key, null if no match or at start



orderedMapIterator
public OrderedMapIterator orderedMapIterator()(Code)



previousKey
public Object previousKey(Object key)(Code)
Gets the previous key to the one specified using insert order. This method performs a list search to find the key and is O(n).
Parameters:
  key - the key to find previous for the previous key, null if no match or at start



put
public Object put(Object key, Object value)(Code)



put
public Object put(int index, Object key, Object value)(Code)
Puts a key-value mapping into the map at the specified index.

If the map already contains the key, then the original mapping is removed and the new mapping added at the specified index. The remove may change the effect of the index. The index is always calculated relative to the original state of the map.

Thus the steps are: (1) remove the existing key-value mapping, then (2) insert the new key-value mapping at the position it would have been inserted had the remove not ocurred.
Parameters:
  index - the index at which the mapping should be inserted
Parameters:
  key - the key
Parameters:
  value - the value the value previously mapped to the key
throws:
  IndexOutOfBoundsException - if the index is out of range
since:
   Commons Collections 3.2




putAll
public void putAll(Map map)(Code)



remove
public Object remove(Object key)(Code)



remove
public Object remove(int index)(Code)
Removes the element at the specified index.
Parameters:
  index - the index of the object to remove the removed value, or null if none existed
throws:
  IndexOutOfBoundsException - if the index is invalid



setValue
public Object setValue(int index, Object value)(Code)
Sets the value at the specified index.
Parameters:
  index - the index of the value to set the previous value at that index
throws:
  IndexOutOfBoundsException - if the index is invalid
since:
   Commons Collections 3.2



toString
public String toString()(Code)
Returns the Map as a string. the Map as a String



valueList
public List valueList()(Code)
Gets a view over the values in the map as a List.

The List will be ordered by object insertion into the map. The List supports remove and set, but does not support add.
See Also:   ListOrderedMap.values() the partially modifiable list view over the values
since:
   Commons Collections 3.2




values
public Collection values()(Code)
Gets a view over the values in the map.

The Collection will be ordered by object insertion into the map.

From Commons Collections 3.2, this Collection can be cast to a list, see ListOrderedMap.valueList()
See Also:   ListOrderedMap.valueList() the fully modifiable collection view over the values




Fields inherited from org.apache.commons.collections.map.AbstractMapDecorator
protected transient Map map(Code)(Java Doc)

Methods inherited from org.apache.commons.collections.map.AbstractMapDecorator
public void clear()(Code)(Java Doc)
public boolean containsKey(Object key)(Code)(Java Doc)
public boolean containsValue(Object value)(Code)(Java Doc)
public Set entrySet()(Code)(Java Doc)
public boolean equals(Object object)(Code)(Java Doc)
public Object get(Object key)(Code)(Java Doc)
protected Map getMap()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
public boolean isEmpty()(Code)(Java Doc)
public Set keySet()(Code)(Java Doc)
public Object put(Object key, Object value)(Code)(Java Doc)
public void putAll(Map mapToCopy)(Code)(Java Doc)
public Object remove(Object key)(Code)(Java Doc)
public int size()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
public Collection 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.