1 package com.mockobjects; 2 3 /* 4 * PLACE HOLDER FOR Map Type in JDK 1.1.7. THIS IS NOT THE FULL TYPE AND IS 5 * PROVIDED TO ELIMINATE COMPILE ERRORS IN VISUAL AGE JAVA. REFER TO JDK 1.2 6 * FOR THE FULL DATA TYPE. 7 */ 8 9 public interface Map { 10 public interface Entry { 11 /** 12 * Returns the key corresponding to this entry. 13 * 14 * @return the key corresponding to this entry. 15 */ 16 Object getKey(); 17 18 /** 19 * Returns the value corresponding to this entry. If the mapping 20 * has been removed from the backing map (by the iterator's 21 * <tt>remove</tt> operation), the results of this call are undefined. 22 * 23 * @return the value corresponding to this entry. 24 */ 25 Object getValue(); 26 27 /** 28 * Replaces the value corresponding to this entry with the specified 29 * value (optional operation). (Writes through to the map.) The 30 * behavior of this call is undefined if the mapping has already been 31 * removed from the map (by the iterator's <tt>remove</tt> operation). 32 * 33 * @param value new value to be stored in this entry. 34 * @return old value corresponding to the entry. 35 * 36 * @throws UnsupportedOperationException if the <tt>put</tt> operation 37 * is not supported by the backing map. 38 * @throws ClassCastException if the class of the specified value 39 * prevents it from being stored in the backing map. 40 * @throws IllegalArgumentException if some aspect of this value 41 * prevents it from being stored in the backing map. 42 * @throws NullPointerException the backing map does not permit 43 * <tt>null</tt> values, and the specified value is 44 * <tt>null</tt>. 45 */ 46 Object setValue(Object value); 47 48 /** 49 * Compares the specified object with this entry for equality. 50 * Returns <tt>true</tt> if the given object is also a map entry and 51 * the two entries represent the same mapping. More formally, two 52 * entries <tt>e1</tt> and <tt>e2</tt> represent the same mapping 53 * if<pre> 54 * (e1.getKey()==null ? 55 * e2.getKey()==null : e1.getKey().equals(e2.getKey())) && 56 * (e1.getValue()==null ? 57 * e2.getValue()==null : e1.getValue().equals(e2.getValue())) 58 * </pre> 59 * This ensures that the <tt>equals</tt> method works properly across 60 * different implementations of the <tt>Map.Entry</tt> interface. 61 * 62 * @param o object to be compared for equality with this map entry. 63 * @return <tt>true</tt> if the specified object is equal to this map 64 * entry. 65 */ 66 boolean equals(Object o); 67 68 /** 69 * Returns the hash code value for this map entry. The hash code 70 * of a map entry <tt>e</tt> is defined to be: <pre> 71 * (e.getKey()==null ? 0 : e.getKey().hashCode()) ^ 72 * (e.getValue()==null ? 0 : e.getValue().hashCode()) 73 * </pre> 74 * This ensures that <tt>e1.equals(e2)</tt> implies that 75 * <tt>e1.hashCode()==e2.hashCode()</tt> for any two Entries 76 * <tt>e1</tt> and <tt>e2</tt>, as required by the general 77 * contract of <tt>Object.hashCode</tt>. 78 * 79 * @return the hash code value for this map entry. 80 * @see Object#hashCode() 81 * @see Object#equals(Object) 82 * @see #equals(Object) 83 */ 84 int hashCode(); 85 } 86 } 87