01: /*
02: * ClassSpec.java
03: *
04: * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09:
10: package pnuts.compiler;
11:
12: import pnuts.lang.Context;
13:
14: public class ClassSpec {
15: Class compileTimeClass;
16: String className;
17:
18: private ClassSpec() {
19: }
20:
21: public static ClassSpec create(Class compileTimeClass) {
22: ClassSpec c = new ClassSpec();
23: c.compileTimeClass = compileTimeClass;
24: c.className = compileTimeClass.getName();
25: return c;
26: }
27:
28: public static ClassSpec create(String className, Context context) {
29: ClassSpec c = new ClassSpec();
30: c.compileTimeClass = context.resolveClass(className);
31: if (c.compileTimeClass != null) {
32: c.className = c.compileTimeClass.getName();
33: } else {
34: c.className = className;
35: }
36: return c;
37: }
38: }
|