001: package com.mockrunner.mock.connector.cci;
002:
003: import java.util.Collection;
004: import java.util.HashMap;
005: import java.util.Map;
006: import java.util.Set;
007:
008: import javax.resource.cci.MappedRecord;
009:
010: import com.mockrunner.base.NestedApplicationException;
011:
012: /**
013: * Mock implementation of <code>MappedRecord</code>.
014: */
015: public class MockMappedRecord extends MockRecord implements
016: MappedRecord {
017: private Map backingMap;
018:
019: public MockMappedRecord() {
020: this ("MockrunnerGenericMappedRecord");
021: }
022:
023: public MockMappedRecord(String name) {
024: this (name, name);
025: }
026:
027: public MockMappedRecord(String name, String description) {
028: super (name, description);
029: backingMap = new HashMap();
030: }
031:
032: public int size() {
033: return backingMap.size();
034: }
035:
036: public boolean isEmpty() {
037: return backingMap.isEmpty();
038: }
039:
040: public boolean containsKey(Object key) {
041: return backingMap.containsKey(key);
042: }
043:
044: public boolean containsValue(Object value) {
045: return backingMap.containsValue(value);
046: }
047:
048: public Object get(Object key) {
049: return backingMap.get(key);
050: }
051:
052: public Object put(Object key, Object value) {
053: return backingMap.put(key, value);
054: }
055:
056: public Object remove(Object key) {
057: return backingMap.remove(key);
058: }
059:
060: public void putAll(Map map) {
061: backingMap.putAll(map);
062: }
063:
064: public void clear() {
065: backingMap.clear();
066: }
067:
068: public Set keySet() {
069: return backingMap.keySet();
070: }
071:
072: public Collection values() {
073: return backingMap.values();
074: }
075:
076: public Set entrySet() {
077: return backingMap.entrySet();
078: }
079:
080: public boolean equals(Object object) {
081: if (!super .equals(object))
082: return false;
083: MockMappedRecord other = (MockMappedRecord) object;
084: return backingMap.equals(other.backingMap);
085: }
086:
087: public int hashCode() {
088: return super .hashCode() * 31 + backingMap.hashCode();
089: }
090:
091: public String toString() {
092: return super .toString() + "\n" + backingMap.toString();
093: }
094:
095: public Object clone() {
096: try {
097: MockMappedRecord clone = (MockMappedRecord) super .clone();
098: clone.backingMap = new HashMap(this .backingMap);
099: return clone;
100: } catch (Exception exc) {
101: throw new NestedApplicationException(exc);
102: }
103: }
104: }
|