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


001:        /*
002:         *  Copyright 2001-2004 The Apache Software Foundation
003:         *
004:         *  Licensed under the Apache License, Version 2.0 (the "License");
005:         *  you may not use this file except in compliance with the License.
006:         *  You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         *  Unless required by applicable law or agreed to in writing, software
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */
016:        package org.apache.commons.collections;
017:
018:        import java.util.Map;
019:
020:        /**
021:         * A default implementation of {@link java.util.Map.Entry}
022:         *
023:         * @deprecated Use the version in the keyvalue subpackage. Will be removed in v4.0
024:         * @since Commons Collections 1.0
025:         * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
026:         * 
027:         * @author James Strachan
028:         * @author Michael A. Smith
029:         * @author Neil O'Toole
030:         * @author Stephen Colebourne
031:         */
032:        public class DefaultMapEntry implements  Map.Entry, KeyValue {
033:
034:            /** The key */
035:            private Object key;
036:            /** The value */
037:            private Object value;
038:
039:            /**
040:             * Constructs a new <code>DefaultMapEntry</code> with a null key
041:             * and null value.
042:             */
043:            public DefaultMapEntry() {
044:                super ();
045:            }
046:
047:            /**
048:             * Constructs a new <code>DefaultMapEntry</code> with the given
049:             * key and given value.
050:             *
051:             * @param entry  the entry to copy, must not be null
052:             * @throws NullPointerException if the entry is null
053:             */
054:            public DefaultMapEntry(Map.Entry entry) {
055:                super ();
056:                this .key = entry.getKey();
057:                this .value = entry.getValue();
058:            }
059:
060:            /**
061:             * Constructs a new <code>DefaultMapEntry</code> with the given
062:             * key and given value.
063:             *
064:             * @param key  the key for the entry, may be null
065:             * @param value  the value for the entry, may be null
066:             */
067:            public DefaultMapEntry(Object key, Object value) {
068:                super ();
069:                this .key = key;
070:                this .value = value;
071:            }
072:
073:            // Map.Entry interface
074:            //-------------------------------------------------------------------------
075:            /**
076:             * Gets the key from the Map Entry.
077:             *
078:             * @return the key 
079:             */
080:            public Object getKey() {
081:                return key;
082:            }
083:
084:            /**
085:             * Sets the key stored in this Map Entry.
086:             * <p>
087:             * This Map Entry is not connected to a Map, so only the local data is changed.
088:             *
089:             * @param key  the new key
090:             */
091:            public void setKey(Object key) {
092:                this .key = key;
093:            }
094:
095:            /**
096:             * Gets the value from the Map Entry.
097:             *
098:             * @return the value
099:             */
100:            public Object getValue() {
101:                return value;
102:            }
103:
104:            /** 
105:             * Sets the value stored in this Map Entry.
106:             * <p>
107:             * This Map Entry is not connected to a Map, so only the local data is changed.
108:             *
109:             * @param value  the new value
110:             * @return the previous value
111:             */
112:            public Object setValue(Object value) {
113:                Object answer = this .value;
114:                this .value = value;
115:                return answer;
116:            }
117:
118:            // Basics
119:            //-----------------------------------------------------------------------
120:            /**
121:             * Compares this Map Entry with another Map Entry.
122:             * <p>
123:             * Implemented per API documentation of {@link java.util.Map.Entry#equals(Object)}
124:             * 
125:             * @param obj  the object to compare to
126:             * @return true if equal key and value
127:             */
128:            public boolean equals(Object obj) {
129:                if (obj == this ) {
130:                    return true;
131:                }
132:                if (obj instanceof  Map.Entry == false) {
133:                    return false;
134:                }
135:                Map.Entry other = (Map.Entry) obj;
136:                return (getKey() == null ? other.getKey() == null : getKey()
137:                        .equals(other.getKey()))
138:                        && (getValue() == null ? other.getValue() == null
139:                                : getValue().equals(other.getValue()));
140:            }
141:
142:            /**
143:             * Gets a hashCode compatible with the equals method.
144:             * <p>
145:             * Implemented per API documentation of {@link java.util.Map.Entry#hashCode()}
146:             * 
147:             * @return a suitable hash code
148:             */
149:            public int hashCode() {
150:                return (getKey() == null ? 0 : getKey().hashCode())
151:                        ^ (getValue() == null ? 0 : getValue().hashCode());
152:            }
153:
154:            /**
155:             * Written to match the output of the Map.Entry's used in 
156:             * a {@link java.util.HashMap}. 
157:             * @since 3.0
158:             */
159:            public String toString() {
160:                return "" + getKey() + "=" + getValue();
161:            }
162:
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.