Source Code Cross Referenced for SimpleEntry.java in  » Profiler » MessAdmin » clime » messadmin » utils » 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 » Profiler » MessAdmin » clime.messadmin.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package clime.messadmin.utils;
004:
005:        import java.io.Serializable;
006:        import java.util.Map;
007:
008:        /**
009:         * An Entry maintaining a key and a value.  The value may be
010:         * changed using the <tt>setValue</tt> method.  This class
011:         * facilitates the process of building custom map
012:         * implementations. For example, it may be convenient to return
013:         * arrays of <tt>SimpleEntry</tt> instances in method
014:         * <tt>Map.entrySet().toArray</tt>.
015:         *
016:         * @since 1.6
017:         * @author C&eacute;drik LIME
018:         */
019:        public class SimpleEntry implements  Map.Entry, Serializable {
020:            private final Object key;
021:            private Object value;
022:
023:            /**
024:             * Creates an entry representing a mapping from the specified
025:             * key to the specified value.
026:             *
027:             * @param key the key represented by this entry
028:             * @param value the value represented by this entry
029:             */
030:            public SimpleEntry(Object key, Object value) {
031:                this .key = key;
032:                this .value = value;
033:            }
034:
035:            /**
036:             * Creates an entry representing the same mapping as the
037:             * specified entry.
038:             *
039:             * @param entry the entry to copy
040:             */
041:            public SimpleEntry(Map.Entry entry) {
042:                this .key = entry.getKey();
043:                this .value = entry.getValue();
044:            }
045:
046:            /**
047:             * @return the key corresponding to this entry
048:             */
049:            public Object getKey() {
050:                return key;
051:            }
052:
053:            /**
054:             * @return the value corresponding to this entry
055:             */
056:            public Object getValue() {
057:                return value;
058:            }
059:
060:            /**
061:             * Replaces the value corresponding to this entry with the specified
062:             * value.
063:             *
064:             * @param value new value to be stored in this entry
065:             * @return the old value corresponding to the entry
066:             */
067:            public Object setValue(Object value) {
068:                Object oldValue = this .value;
069:                this .value = value;
070:                return oldValue;
071:            }
072:
073:            /**
074:             * Compares the specified object with this entry for equality.
075:             * Returns {@code true} if the given object is also a map entry and
076:             * the two entries represent the same mapping.	More formally, two
077:             * entries {@code e1} and {@code e2} represent the same mapping
078:             * if<pre>
079:             *   (e1.getKey()==null ?
080:             *	  e2.getKey()==null :
081:             *	  e1.getKey().equals(e2.getKey()))
082:             *   &amp;&amp;
083:             *   (e1.getValue()==null ?
084:             *	  e2.getValue()==null :
085:             *	  e1.getValue().equals(e2.getValue()))</pre>
086:             * This ensures that the {@code equals} method works properly across
087:             * different implementations of the {@code Map.Entry} interface.
088:             *
089:             * @param o object to be compared for equality with this map entry
090:             * @return {@code true} if the specified object is equal to this map
091:             *	   entry
092:             * @see	#hashCode
093:             */
094:            public boolean equals(Object o) {
095:                if (!(o instanceof  Map.Entry))
096:                    return false;
097:                Map.Entry e = (Map.Entry) o;
098:                return eq(key, e.getKey()) && eq(value, e.getValue());
099:            }
100:
101:            /**
102:             * Returns the hash code value for this map entry.  The hash code
103:             * of a map entry {@code e} is defined to be: <pre>
104:             *   (e.getKey()==null   ? 0 : e.getKey().hashCode()) ^
105:             *   (e.getValue()==null ? 0 : e.getValue().hashCode())</pre>
106:             * This ensures that {@code e1.equals(e2)} implies that
107:             * {@code e1.hashCode()==e2.hashCode()} for any two Entries
108:             * {@code e1} and {@code e2}, as required by the general
109:             * contract of {@link Object#hashCode}.
110:             *
111:             * @return the hash code value for this map entry
112:             * @see	#equals
113:             */
114:            public int hashCode() {
115:                return (key == null ? 0 : key.hashCode())
116:                        ^ (value == null ? 0 : value.hashCode());
117:            }
118:
119:            /**
120:             * Returns a String representation of this map entry.  This
121:             * implementation returns the string representation of this
122:             * entry's key followed by the equals character ("<tt>=</tt>")
123:             * followed by the string representation of this entry's value.
124:             *
125:             * @return a String representation of this map entry
126:             */
127:            public String toString() {
128:                return key + "=" + value;//$NON-NLS-1$
129:            }
130:
131:            /**
132:             * Utility method for SimpleEntry and SimpleImmutableEntry.
133:             * Test for equality, checking for nulls.
134:             */
135:            private static boolean eq(Object o1, Object o2) {
136:                return o1 == null ? o2 == null : o1.equals(o2);
137:            }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.