package com.ht.data.script;

import java.util.Map;

import javax.script.SimpleBindings;

import com.ht.data.RealTimeDataManager;

public class RealtimeDataBinding extends SimpleBindings {

	public RealtimeDataBinding(Map<String, Object> m) {
		super(m);
	}

	@Override
	public Object put(String name, Object value) {
		Object ret = super.put(name, value);
		if (ret == null || !ret.equals(value)) {
			RealTimeDataManager.INSTANCE.varDataChanged(name);
		}
		return ret;
	}
	@Override
	public void putAll(Map<? extends String, ? extends Object> toMerge) {
		if (toMerge == null) {
            throw new NullPointerException("toMerge map is null");
        }
        for (Map.Entry<? extends String, ? extends Object> entry : toMerge.entrySet()) { 
            this.put(entry.getKey(), entry.getValue());
        }
	}
}
