1 18 package org.apache.beehive.netui.script.common; 19 20 import java.util.AbstractMap ; 21 import java.util.AbstractSet ; 22 import java.util.Collection ; 23 import java.util.Iterator ; 24 import java.util.Map ; 25 26 import org.apache.beehive.netui.util.iterator.IteratorFactory; 27 28 33 public abstract class AbstractScriptableMap 34 extends AbstractMap { 35 36 41 class EntrySet 42 extends AbstractSet { 43 44 private Entry[] _entries = null; 45 46 public EntrySet(Entry[] entries) { 47 _entries = entries; 48 } 49 50 public Iterator iterator() { 51 return IteratorFactory.createIterator(_entries); 52 } 53 54 public int size() { 55 return _entries != null ? _entries.length : 0; 56 } 57 58 public boolean add(Object object) { 59 throw new UnsupportedOperationException (); 60 } 61 62 public boolean addAll(Collection coll) { 63 throw new UnsupportedOperationException (); 64 } 65 66 public void clear() { 67 throw new UnsupportedOperationException (); 68 } 69 70 public boolean remove(Object object) { 71 throw new UnsupportedOperationException (); 72 } 73 74 public boolean removeAll(Collection coll) { 75 throw new UnsupportedOperationException (); 76 } 77 78 public boolean retainAll(Collection coll) { 79 throw new UnsupportedOperationException (); 80 } 81 } 82 83 89 class Entry 90 implements Map.Entry { 91 92 private final Object _key; 93 private final Object _value; 94 95 Entry(Object key, Object value) { 96 _key = key; 97 _value = value; 98 } 99 100 public Object getKey() { 101 return _key; 102 } 103 104 public Object getValue() { 105 return _value; 106 } 107 108 public Object setValue(Object value) { 109 throw new UnsupportedOperationException (); 110 } 111 112 public int hashCode() { 113 return ((_key == null ? 0 : _key.hashCode()) ^ (_value == null ? 0 : _value.hashCode())); 114 } 115 116 public boolean equals(Object obj) { 117 if(obj == null || !(obj instanceof Map.Entry )) 118 return false; 119 120 Map.Entry entry = (Map.Entry )obj; 121 Object key = entry.getKey(); 122 Object value = entry.getValue(); 123 if((key == null || (key != null && key.equals(_key))) && 124 (value == null || (value != null && value.equals(_value)))) 125 return true; 126 127 return false; 128 } 129 } 130 } 131 | Popular Tags |