gnu.mapping

Class Namespace

public class Namespace extends Object implements Externalizable, HasNamedParts

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 NamespaceEmptyNamespace
The Namespace with the empty name.
protected static HashtablensTable
Map namepsace names (and nick-names) to Namespaces.
protected Stringprefix
protected SymbolRef[]table
Constructor Summary
Namespace()
Namespace(int capacity)
Method Summary
Symboladd(Symbol sym, int hash)
Objectget(String key)
static NamespacegetDefault()
static SymbolgetDefaultSymbol(String name)
static NamespacegetInstance(String name)
StringgetName()
Get the name of this Namespace.
SymbolgetSymbol(String key)
Get a Symbol matching the given name.
booleanisConstant(String key)
Symbollookup(String key)
Get a Symbol matching the given name.
Symbollookup(String key, int hash, boolean create)
protected SymbollookupInternal(String key, int hash)
static Namespacemake(String name)
static Namespacemake(String uri, String prefix)
static NamespacemakeUnknownNamespace(String prefix)
Create a "placeholder" for a namespace with a known prefix but unknown uri.
voidreadExternal(ObjectInput in)
ObjectreadResolve()
protected voidrehash()
booleanremove(Symbol symbol)
voidsetName(String name)
Set the name of this Namespace.
StringtoString()
voidwriteExternal(ObjectOutput out)

Field Detail

EmptyNamespace

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

nsTable

protected static final Hashtable nsTable
Map namepsace names (and nick-names) to Namespaces.

prefix

protected String prefix

table

protected SymbolRef[] table

Constructor Detail

Namespace

public Namespace()

Namespace

public Namespace(int capacity)

Method Detail

add

public Symbol add(Symbol sym, int hash)

get

public Object get(String key)

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.

isConstant

public boolean isConstant(String key)

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)

make

public static Namespace make(String name)

make

public static Namespace make(String uri, String prefix)

makeUnknownNamespace

public static Namespace makeUnknownNamespace(String prefix)
Create a "placeholder" for a namespace with a known prefix but unknown uri.

See Also: Symbol

readExternal

public void readExternal(ObjectInput in)

readResolve

public Object readResolve()

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)