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

MultiValueMap
public class MultiValueMap extends AbstractMapDecorator implements MultiMap(Code)
A MultiValueMap decorates another map, allowing it to have more than one value for a key.

A MultiMap is a Map with slightly different semantics. Putting a value into the map will add the value to a Collection at that key. Getting a value will return a Collection, holding all the values put to that key.

This implementation is a decorator, allowing any Map implementation to be used as the base.

In addition, this implementation allows the type of collection used for the values to be controlled. By default, an ArrayList is used, however a Class to instantiate may be specified, or a factory that returns a Collection instance.

Note that MultiValueMap is not synchronized and is not thread-safe. If you wish to use this map from multiple threads concurrently, you must use appropriate synchronization. This class may throw exceptions when accessed by concurrent threads without synchronization.
author:
   James Carman
author:
   Christopher Berry
author:
   James Strachan
author:
   Steve Downey
author:
   Stephen Colebourne
author:
   Julien Buret
author:
   Serhiy Yevtushenko
version:
   $Revision: 348007 $ $Date: 2005-11-21 22:52:57 +0000 (Mon, 21 Nov 2005) $
since:
   Commons Collections 3.2




Constructor Summary
public  MultiValueMap()
     Creates a MultiValueMap based on a HashMap and storing the multiple values in an ArrayList.
protected  MultiValueMap(Map map, Factory collectionFactory)
     Creates a MultiValueMap which decorates the given map and creates the value collections using the supplied collectionFactory.

Method Summary
public  voidclear()
     Clear the map.
public  booleancontainsValue(Object value)
     Checks whether the map contains the value specified.
public  booleancontainsValue(Object key, Object value)
     Checks whether the collection at the specified key contains the value.
protected  CollectioncreateCollection(int size)
     Creates a new instance of the map value Collection container using the factory.
public static  MultiValueMapdecorate(Map map)
     Creates a map which wraps the given map and maps keys to ArrayLists.
public static  MultiValueMapdecorate(Map map, Class collectionClass)
     Creates a map which decorates the given map and maps keys to collections of type collectionClass.
public static  MultiValueMapdecorate(Map map, Factory collectionFactory)
     Creates a map which decorates the given map and creates the value collections using the supplied collectionFactory.
public  CollectiongetCollection(Object key)
     Gets the collection mapped to the specified key.
public  Iteratoriterator(Object key)
     Gets an iterator for the collection mapped to the specified key.
public  Objectput(Object key, Object value)
     Adds the value to the collection associated with the specified key.
public  voidputAll(Map map)
     Override superclass to ensure that MultiMap instances are correctly handled.
public  booleanputAll(Object key, Collection values)
     Adds a collection of values to the collection associated with the specified key.
public  Objectremove(Object key, Object value)
     Removes a specific value from map.
public  intsize(Object key)
     Gets the size of the collection mapped to the specified key.
public  inttotalSize()
     Gets the total size of the map by counting all the values.
public  Collectionvalues()
     Gets a collection containing all the values in the map.


Constructor Detail
MultiValueMap
public MultiValueMap()(Code)
Creates a MultiValueMap based on a HashMap and storing the multiple values in an ArrayList.



MultiValueMap
protected MultiValueMap(Map map, Factory collectionFactory)(Code)
Creates a MultiValueMap which decorates the given map and creates the value collections using the supplied collectionFactory.
Parameters:
  map - the map to decorate
Parameters:
  collectionFactory - the collection factory which must return a Collection instance




Method Detail
clear
public void clear()(Code)
Clear the map.



containsValue
public boolean containsValue(Object value)(Code)
Checks whether the map contains the value specified.

This checks all collections against all keys for the value, and thus could be slow.
Parameters:
  value - the value to search for true if the map contains the value




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



createCollection
protected Collection createCollection(int size)(Code)
Creates a new instance of the map value Collection container using the factory.

This method can be overridden to perform your own processing instead of using the factory.
Parameters:
  size - the collection size that is about to be added the new collection




decorate
public static MultiValueMap decorate(Map map)(Code)
Creates a map which wraps the given map and maps keys to ArrayLists.
Parameters:
  map - the map to wrap



decorate
public static MultiValueMap decorate(Map map, Class collectionClass)(Code)
Creates a map which decorates the given map and maps keys to collections of type collectionClass.
Parameters:
  map - the map to wrap
Parameters:
  collectionClass - the type of the collection class



decorate
public static MultiValueMap decorate(Map map, Factory collectionFactory)(Code)
Creates a map which decorates the given map and creates the value collections using the supplied collectionFactory.
Parameters:
  map - the map to decorate
Parameters:
  collectionFactory - the collection factory (must return a Collection object).



getCollection
public Collection getCollection(Object key)(Code)
Gets the collection mapped to the specified key. This method is a convenience method to typecast the result of get(key).
Parameters:
  key - the key to retrieve the collection mapped to the key, null if no mapping



iterator
public Iterator iterator(Object key)(Code)
Gets an iterator for the collection mapped to the specified key.
Parameters:
  key - the key to get an iterator for the iterator of the collection at the key, empty iterator if key not in map



put
public Object put(Object key, Object value)(Code)
Adds the value to the collection associated with the specified key.

Unlike a normal Map the previous value is not replaced. Instead the new value is added to the collection stored against the key.
Parameters:
  key - the key to store against
Parameters:
  value - the value to add to the collection at the key the value added if the map changed and null if the map did not change




putAll
public void putAll(Map map)(Code)
Override superclass to ensure that MultiMap instances are correctly handled.

If you call this method with a normal map, each entry is added using put(Object,Object). If you call this method with a multi map, each entry is added using putAll(Object,Collection).
Parameters:
  map - the map to copy (either a normal or multi map)




putAll
public boolean putAll(Object key, Collection values)(Code)
Adds a collection of values to the collection associated with the specified key.
Parameters:
  key - the key to store against
Parameters:
  values - the values to add to the collection at the key, null ignored true if this map changed



remove
public Object remove(Object key, Object value)(Code)
Removes a specific value from map.

The item is removed from the collection mapped to the specified key. Other values attached to that key are unaffected.

If the last value for a key is removed, null will be returned from a subsequant get(key).
Parameters:
  key - the key to remove from
Parameters:
  value - the value to remove the value removed (which was passed in), null if nothing removed




size
public int size(Object key)(Code)
Gets the size of the collection mapped to the specified key.
Parameters:
  key - the key to get size for the size of the collection at the key, zero if key not in map



totalSize
public int totalSize()(Code)
Gets the total size of the map by counting all the values. the total size of the map counting all values



values
public Collection values()(Code)
Gets a collection containing all the values in the map.

This returns a collection containing the combination of values from all keys. a collection view of the values contained in this map




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.