EMMA Coverage Report (generated Tue May 16 15:34:38 CDT 2006)
[all classes][com.mysql.management.util]

COVERAGE SUMMARY FOR SOURCE FILE [MapEntry.java]

nameclass, %method, %block, %line, %
MapEntry.java100% (1/1)100% (8/8)99%  (106/107)100% (22/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MapEntry100% (1/1)100% (8/8)99%  (106/107)100% (22/22)
equals (Map$Entry): boolean 100% (1/1)97%  (33/34)99%  (5/5)
MapEntry (Object, Object): void 100% (1/1)100% (14/14)100% (5/5)
equals (Object): boolean 100% (1/1)100% (10/10)100% (3/3)
getKey (): Object 100% (1/1)100% (3/3)100% (1/1)
getValue (): Object 100% (1/1)100% (3/3)100% (1/1)
hashCode (): int 100% (1/1)100% (22/22)100% (3/3)
setValue (Object): Object 100% (1/1)100% (8/8)100% (3/3)
toString (): String 100% (1/1)100% (13/13)100% (1/1)

1/*
2 Copyright (C) 2004 MySQL AB
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License version 2 as 
6 published by the Free Software Foundation.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16 
17 */
18package com.mysql.management.util;
19 
20import java.util.Map;
21 
22/**
23 * Simple (and obvious) implementation of java.util.Map.Entry
24 * 
25 * This class is final simply as a hint to the compiler, it may be un-finalized
26 * safely.
27 * 
28 * @author Eric Herman <eric@mysql.com>
29 * @version $Id: MapEntry.java,v 1.5 2005/09/22 20:41:36 eherman Exp $
30 */
31public final class MapEntry implements Map.Entry {
32    private Object key;
33 
34    private Object value;
35 
36    private Equals equals;
37 
38    public MapEntry(Object key, Object value) {
39        this.key = key;
40        this.value = value;
41        this.equals = new Equals();
42    }
43 
44    public Object getKey() {
45        return key;
46    }
47 
48    public Object getValue() {
49        return value;
50    }
51 
52    public Object setValue(Object value) {
53        Object oldVal = this.value;
54        this.value = value;
55        return oldVal;
56    }
57 
58    public boolean equals(Object obj) {
59        if (!(obj instanceof Map.Entry)) {
60            return false;
61        }
62        return equals((Map.Entry) obj);
63    }
64 
65    public boolean equals(Map.Entry other) {
66        if (other == this) {
67            return true;
68        }
69 
70        if ((other == null) || (hashCode() != other.hashCode())) {
71            return false;
72        }
73 
74        return equals.nullSafe(key, other.getKey())
75                && equals.nullSafe(value, other.getValue());
76    }
77 
78    /**
79     * XOR of the key and value hashCodes. (Zero used for nulls) as defined by
80     * Map.Entry java doc.
81     */
82    public int hashCode() {
83        int keyHashCode = (key == null) ? 0 : key.hashCode();
84        int valHashCode = (value == null) ? 0 : value.hashCode();
85        return keyHashCode ^ valHashCode;
86    }
87 
88    public String toString() {
89        return getKey() + "=" + getValue();
90    }
91}

[all classes][com.mysql.management.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov