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


java.lang.Object
   org.apache.commons.collections.keyvalue.MultiKey

MultiKey
public class MultiKey implements Serializable(Code)
A MultiKey allows multiple map keys to be merged together.

The purpose of this class is to avoid the need to write code to handle maps of maps. An example might be the need to lookup a filename by key and locale. The typical solution might be nested maps. This class can be used instead by creating an instance passing in the key and locale.

Example usage:

 // populate map with data mapping key+locale to localizedText
 Map map = new HashMap();
 MultiKey multiKey = new MultiKey(key, locale);
 map.put(multiKey, localizedText);
 // later retireve the localized text
 MultiKey multiKey = new MultiKey(key, locale);
 String localizedText = (String) map.get(multiKey);
 

since:
   Commons Collections 3.0
version:
   $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
author:
   Howard Lewis Ship
author:
   Stephen Colebourne



Constructor Summary
public  MultiKey(Object key1, Object key2)
     Constructor taking two keys.
public  MultiKey(Object key1, Object key2, Object key3)
     Constructor taking three keys.
public  MultiKey(Object key1, Object key2, Object key3, Object key4)
     Constructor taking four keys.
public  MultiKey(Object key1, Object key2, Object key3, Object key4, Object key5)
     Constructor taking five keys.
public  MultiKey(Object[] keys)
     Constructor taking an array of keys which is cloned.
public  MultiKey(Object[] keys, boolean makeClone)
     Constructor taking an array of keys, optionally choosing whether to clone.

Method Summary
public  booleanequals(Object other)
     Compares this object to another.
public  ObjectgetKey(int index)
     Gets the key at the specified index.
public  Object[]getKeys()
     Gets a clone of the array of keys.
public  inthashCode()
     Gets the combined hash code that is computed from all the keys.
public  intsize()
     Gets the size of the list of keys.
public  StringtoString()
     Gets a debugging string version of the key.


Constructor Detail
MultiKey
public MultiKey(Object key1, Object key2)(Code)
Constructor taking two keys.

The keys should be immutable If they are not then they must not be changed after adding to the MultiKey.
Parameters:
  key1 - the first key
Parameters:
  key2 - the second key




MultiKey
public MultiKey(Object key1, Object key2, Object key3)(Code)
Constructor taking three keys.

The keys should be immutable If they are not then they must not be changed after adding to the MultiKey.
Parameters:
  key1 - the first key
Parameters:
  key2 - the second key
Parameters:
  key3 - the third key




MultiKey
public MultiKey(Object key1, Object key2, Object key3, Object key4)(Code)
Constructor taking four keys.

The keys should be immutable If they are not then they must not be changed after adding to the MultiKey.
Parameters:
  key1 - the first key
Parameters:
  key2 - the second key
Parameters:
  key3 - the third key
Parameters:
  key4 - the fourth key




MultiKey
public MultiKey(Object key1, Object key2, Object key3, Object key4, Object key5)(Code)
Constructor taking five keys.

The keys should be immutable If they are not then they must not be changed after adding to the MultiKey.
Parameters:
  key1 - the first key
Parameters:
  key2 - the second key
Parameters:
  key3 - the third key
Parameters:
  key4 - the fourth key
Parameters:
  key5 - the fifth key




MultiKey
public MultiKey(Object[] keys)(Code)
Constructor taking an array of keys which is cloned.

The keys should be immutable If they are not then they must not be changed after adding to the MultiKey.

This is equivalent to new MultiKey(keys, true).
Parameters:
  keys - the array of keys, not null
throws:
  IllegalArgumentException - if the key array is null




MultiKey
public MultiKey(Object[] keys, boolean makeClone)(Code)
Constructor taking an array of keys, optionally choosing whether to clone.

If the array is not cloned, then it must not be modified.

This method is public for performance reasons only, to avoid a clone. The hashcode is calculated once here in this method. Therefore, changing the array passed in would not change the hashcode but would change the equals method, which is a bug.

This is the only fully safe usage of this constructor, as the object array is never made available in a variable:

 new MultiKey(new Object[] {...}, false);
 

The keys should be immutable If they are not then they must not be changed after adding to the MultiKey.
Parameters:
  keys - the array of keys, not null
Parameters:
  makeClone - true to clone the array, false to assign it
throws:
  IllegalArgumentException - if the key array is null
since:
   Commons Collections 3.1





Method Detail
equals
public boolean equals(Object other)(Code)
Compares this object to another.

To be equal, the other object must be a MultiKey with the same number of keys which are also equal.
Parameters:
  other - the other object to compare to true if equal




getKey
public Object getKey(int index)(Code)
Gets the key at the specified index.

The key should be immutable. If it is not then it must not be changed.
Parameters:
  index - the index to retrieve the key at the index
throws:
  IndexOutOfBoundsException - if the index is invalid
since:
   Commons Collections 3.1




getKeys
public Object[] getKeys()(Code)
Gets a clone of the array of keys.

The keys should be immutable If they are not then they must not be changed. the individual keys




hashCode
public int hashCode()(Code)
Gets the combined hash code that is computed from all the keys.

This value is computed once and then cached, so elements should not change their hash codes once created (note that this is the same constraint that would be used if the individual keys elements were themselves java.util.Map Map keys. the hash code




size
public int size()(Code)
Gets the size of the list of keys. the size of the list of keys
since:
   Commons Collections 3.1



toString
public String toString()(Code)
Gets a debugging string version of the key. a debugging string



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.