classnamespace.java

来自「A framework written in Java for implemen」· Java 代码 · 共 76 行

JAVA
76
字号
package gnu.kawa.lispexpr;import gnu.mapping.*;import java.io.*;import gnu.bytecode.ClassType;import gnu.kawa.functions.GetNamedPart;public class ClassNamespace extends Namespace implements Externalizable{  ClassType ctype;  public ClassType getClassType ()  {    return ctype;  }  public static ClassNamespace getInstance (String name, ClassType ctype)  {    synchronized (nsTable)      {	Object old = nsTable.get(name);	if (old instanceof ClassNamespace)	  return (ClassNamespace) old;	ClassNamespace ns = new ClassNamespace(ctype);	nsTable.put(name, ns);	return ns;      }  }  public ClassNamespace ()  {  }  public ClassNamespace (ClassType ctype)  {    this.setName("class:"+ctype.getName());    this.ctype = ctype;  }  public Object get (String name)  {    try      {        return GetNamedPart.getTypePart(ctype, name);      }    catch (Throwable ex)      {        throw WrappedException.wrapIfNeeded(ex);      }  }  public void writeExternal(ObjectOutput out) throws IOException  {    out.writeObject(ctype);  }  public void readExternal(ObjectInput in)    throws IOException, ClassNotFoundException  {    ctype = (ClassType) in.readObject();    setName("class:"+ctype.getName());  }  public Object readResolve() throws ObjectStreamException  {    String name = getName();    if (name != null)      {	Namespace ns = (Namespace) nsTable.get(name);	if (ns instanceof ClassNamespace)	  return ns;	nsTable.put(name, this);      }    return this;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?