01: /*
02: * Copyright (C) 2004 Joe Walnes.
03: * Copyright (C) 2006, 2007 XStream Committers.
04: * All rights reserved.
05: *
06: * The software in this package is published under the terms of the BSD
07: * style license a copy of which has been included with this distribution in
08: * the LICENSE.txt file.
09: *
10: * Created on 04. October 2004 by Joe Walnes
11: */
12: package com.thoughtworks.xstream.core;
13:
14: import com.thoughtworks.xstream.converters.DataHolder;
15:
16: import java.util.Collections;
17: import java.util.HashMap;
18: import java.util.Iterator;
19: import java.util.Map;
20:
21: public class MapBackedDataHolder implements DataHolder {
22: private final Map map;
23:
24: public MapBackedDataHolder() {
25: this (new HashMap());
26: }
27:
28: public MapBackedDataHolder(Map map) {
29: this .map = map;
30: }
31:
32: public Object get(Object key) {
33: return map.get(key);
34: }
35:
36: public void put(Object key, Object value) {
37: map.put(key, value);
38: }
39:
40: public Iterator keys() {
41: return Collections.unmodifiableCollection(map.keySet())
42: .iterator();
43: }
44: }
|