gnu.mapping

Class Namespace

Implemented Interfaces:
Externalizable
Known Direct Subclasses:
LispPackage

public class Namespace
extends java.lang.Object
implements 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.

Field Summary

static Namespace
EmptyNamespace
The Namespace with the empty name.
protected gnu.mapping.SymbolRef[]
table

Constructor Summary

Namespace()
Namespace(String name, int dummy)
A kludge used for serializing SName.
Namespace(int capacity)

Method Summary

Symbol
add(Symbol sym, int hash)
static Namespace
getDefault()
static Symbol
getDefaultSymbol(String name)
static Namespace
getInstance(String name)
String
getName()
Get the name of this Namespace.
Symbol
getSymbol(String key)
Get a Symbol matching the given name.
Symbol
lookup(String key)
Get a Symbol matching the given name.
Symbol
lookup(String key, int hash, boolean create)
protected Symbol
lookupInternal(String key, int hash)
void
readExternal(ObjectInput in)
Object
readResolve()
protected void
rehash()
boolean
remove(Symbol symbol)
void
setName(String name)
Set the name of this Namespace.
String
toString()
void
writeExternal(ObjectOutput out)

Field Details

EmptyNamespace

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

table

protected gnu.mapping.SymbolRef[] table

Constructor Details

Namespace

public Namespace()

Namespace

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

Namespace

public Namespace(int capacity)

Method Details

add

public Symbol add(Symbol sym,
                  int hash)

getDefault

public static Namespace getDefault()

getDefaultSymbol

public static Symbol getDefaultSymbol(String name)

getInstance

public static Namespace getInstance(String name)

getName

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

getSymbol

public Symbol getSymbol(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(String key)
Get a Symbol matching the given name. Returns null if one is not found.

lookup

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

lookupInternal

protected final Symbol lookupInternal(String key,
                                      int hash)

readExternal

public void readExternal(ObjectInput in)
            throws IOException,
                   ClassNotFoundException

readResolve

public Object readResolve()
            throws ObjectStreamException

rehash

protected void rehash()

remove

public boolean remove(Symbol symbol)

setName

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

toString

public String toString()

writeExternal

public void writeExternal(ObjectOutput out)
            throws IOException