/* Author: Jeff Dalton * Updated: Mon May 7 18:37:19 2001 by Jeff Dalton * Copyright: (c) 2001, AIAI, University of Edinburgh */ package ix.util.context; import java.util.*; /** * An object that contains a single context-dependent value. */ public class ContextValue { ContextHolder holder; ContextLink link; public ContextValue(Object value) { this(Context.getContextHolder(), value); } public ContextValue(ContextHolder holder, Object value) { this.holder = holder; this.link = new ContextLink(holder.getContext(), value); } public Object get() { return Context.getInContext(link, holder.getContext()); } public void set(Object new_value) { Context.setInContext(link, holder.getContext(), new_value); } }