From: adam Date: Sun, 3 Jul 2005 21:57:19 +0000 (+0000) Subject: added Context.java X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=commitdiff_plain;h=e364eb71c265255d2843ef8752a30c854f56fefb;ds=sidebyside added Context.java darcs-hash:20050703215719-5007d-a726caa366b23bf9ba1b5f4ae6d20f2ab24e3b05.gz --- diff --git a/src/org/ibex/classgen/Context.java b/src/org/ibex/classgen/Context.java new file mode 100644 index 0000000..99d9819 --- /dev/null +++ b/src/org/ibex/classgen/Context.java @@ -0,0 +1,20 @@ +package org.ibex.classgen; +import java.util.*; + +/** + * a Context is like a ClassLoader in that it maps from class names + * to bytecode-implementations of classes, except that it doesn't + * actually load the resolved class -- it simply creates a (cached) + * ClassFile for it. + */ +public class Context { + + private Hashtable cache = new Hashtable(); + + public Context() { } + + public void add(ClassFile cf) { cache.put(cf.getType().getName(), cf); } + public Collection enumerateClassFiles() { return cache.values(); } + public ClassFile resolve(String classname) { return (ClassFile)cache.get(classname); } + +}