// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package jcademo.raoutbound.multcp_cci;

import java.util.AbstractMap;
import java.util.HashSet;
import java.util.Set;

import javax.resource.cci.MappedRecord;

@SuppressWarnings("rawtypes")
public class CCI_C_MappedRecord extends AbstractMap implements MappedRecord {
	private static final long serialVersionUID = 1L;
	private int c;
	// record name and description
	@Override
	public String getRecordName() {
		return "C";
	}
	@Override
	public void setRecordName(String name) {
		// name is fixed
	}
	@Override
	public String getRecordShortDescription() {
		return "C (output)";
	}
	@Override
	public void setRecordShortDescription(String description) {
		// description is fixed
	}
	// core methods
	@Override
	public Set entrySet() {
		Set res = new HashSet();
		res.add(new AbstractMap.SimpleEntry("C", (Integer)c));
		return res;
	}
	@Override
	public Object put(Object key, Object value) {
		if(key.equals("C")) {
			int oldc = c;
			c = (Integer) value;
			return oldc;
		} else {
			throw new IllegalArgumentException("Bad key: " + key);
		}
	}
	// required
	@Override
	public Object clone() throws CloneNotSupportedException {
		return super.clone();
	}
}
