KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > core > MapBackedDataHolder


1 package com.thoughtworks.xstream.core;
2
3 import com.thoughtworks.xstream.converters.DataHolder;
4
5 import java.util.Collections JavaDoc;
6 import java.util.HashMap JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.Map JavaDoc;
9
10 public class MapBackedDataHolder implements DataHolder {
11     private final Map JavaDoc map;
12
13     public MapBackedDataHolder() {
14         this(new HashMap JavaDoc());
15     }
16
17     public MapBackedDataHolder(Map JavaDoc map) {
18         this.map = map;
19     }
20
21     public Object JavaDoc get(Object JavaDoc key) {
22         return map.get(key);
23     }
24
25     public void put(Object JavaDoc key, Object JavaDoc value) {
26         map.put(key, value);
27     }
28
29     public Iterator JavaDoc keys() {
30         return Collections.unmodifiableCollection(map.keySet()).iterator();
31     }
32 }
33
Popular Tags