gnu.mapping
Class Namespace

java.lang.Object
  extended by gnu.mapping.Namespace
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
LispPackage

public class Namespace
extends java.lang.Object
implements java.io.Externalizable

A mapping from strings ("print names") to Symbols. Namespaces are normally named and can be accessed from a global table. They correspond to Common Lisp "packages" (which are implemented using gnu.kawa.lispexpr.LispPackage, which extends Namespace). A Namespace is a "weak" mapping in the sense that a Symbol can be garbage collected even though it is referenced from a Namespace.

See Also:
Serialized Form

Field Summary
static Namespace EmptyNamespace
          The Namespace with the empty name.
protected  gnu.mapping.SymbolRef[] table
           
 
Constructor Summary
  Namespace()
           
  Namespace(int capacity)
           
protected Namespace(java.lang.String name, int dummy)
          A kludge used for serializing SName.
 
Method Summary
 Symbol add(Symbol sym, int hash)
           
static Namespace getDefault()
           
static Symbol getDefaultSymbol(java.lang.String name)
           
static Namespace getInstance(java.lang.String name)
           
 java.lang.String getName()
          Get the name of this Namespace.
 Symbol getSymbol(java.lang.String key)
          Get a Symbol matching the given name.
 Symbol lookup(java.lang.String key)
          Get a Symbol matching the given name.
 Symbol lookup(java.lang.String key, int hash, boolean create)
           
protected  Symbol lookupInternal(java.lang.String key, int hash)
           
 void readExternal(java.io.ObjectInput in)
           
 java.lang.Object readResolve()
           
protected  void rehash()
           
 boolean remove(Symbol symbol)
           
 void setName(java.lang.String name)
          Set the name of this Namespace.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EmptyNamespace

public static final Namespace EmptyNamespace
The Namespace with the empty name.


table

protected gnu.mapping.SymbolRef[] table
Constructor Detail

Namespace

public Namespace()

Namespace

public Namespace(int capacity)

Namespace

protected Namespace(java.lang.String name,
                    int dummy)
A kludge used for serializing SName.

Method Detail

getName

public final java.lang.String getName()
Get the name of this Namespace.


setName

public final void setName(java.lang.String name)
Set the name of this Namespace.


getDefault

public static Namespace getDefault()

getDefaultSymbol

public static Symbol getDefaultSymbol(java.lang.String name)

getInstance

public static Namespace getInstance(java.lang.String name)

getSymbol

public Symbol getSymbol(java.lang.String key)
Get a Symbol matching the given name. Creates a new Symbol if one is not found. Equivalent to Common Lisp's "intern" function.


lookup

public Symbol lookup(java.lang.String key)
Get a Symbol matching the given name. Returns null if one is not found.


lookupInternal

protected final Symbol lookupInternal(java.lang.String key,
                                      int hash)

add

public Symbol add(Symbol sym,
                  int hash)

lookup

public Symbol lookup(java.lang.String key,
                     int hash,
                     boolean create)

remove

public boolean remove(Symbol symbol)

rehash

protected void rehash()

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readResolve

public java.lang.Object readResolve()
                             throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object