Codebase list libxstream-java / f7420ae6-41f0-4e7f-a36a-c567055b7d28/main xstream / src / java / com / thoughtworks / xstream / core / MapBackedDataHolder.java
f7420ae6-41f0-4e7f-a36a-c567055b7d28/main

Tree @f7420ae6-41f0-4e7f-a36a-c567055b7d28/main (Download .tar.gz)

MapBackedDataHolder.java @f7420ae6-41f0-4e7f-a36a-c567055b7d28/mainraw · history · blame

/*
 * Copyright (C) 2004 Joe Walnes.
 * Copyright (C) 2006, 2007 XStream Committers.
 * All rights reserved.
 *
 * The software in this package is published under the terms of the BSD
 * style license a copy of which has been included with this distribution in
 * the LICENSE.txt file.
 * 
 * Created on 04. October 2004 by Joe Walnes
 */
package com.thoughtworks.xstream.core;

import com.thoughtworks.xstream.converters.DataHolder;

import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class MapBackedDataHolder implements DataHolder {
    private final Map map;

    public MapBackedDataHolder() {
        this(new HashMap());
    }

    public MapBackedDataHolder(Map map) {
        this.map = map;
    }

    public Object get(Object key) {
        return map.get(key);
    }

    public void put(Object key, Object value) {
        map.put(key, value);
    }

    public Iterator keys() {
        return Collections.unmodifiableCollection(map.keySet()).iterator();
    }
}