public class Namespace extends AbstractHashTable<gnu.mapping.SymbolRef,java.lang.String,Symbol> implements java.io.Externalizable, HasNamedParts
Symbol
s.
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
.Modifier and Type | Field and Description |
---|---|
static Namespace |
EmptyNamespace
The Namespace with the empty name.
|
protected static java.util.Hashtable |
nsTable
Map namepsace names (and nick-names) to Namespaces.
|
protected java.lang.String |
prefix |
static java.lang.String |
UNKNOWN_NAMESPACE |
DEFAULT_INITIAL_SIZE, mask, num_bindings, table
Modifier | Constructor and Description |
---|---|
|
Namespace() |
protected |
Namespace(int capacity) |
Modifier and Type | Method and Description |
---|---|
Symbol |
add(Symbol sym,
int hash) |
protected gnu.mapping.SymbolRef[] |
allocEntries(int n)
Allocate Entry[n].
|
static Namespace |
create() |
static Namespace |
create(int capacity) |
Symbol |
get(java.lang.Object key,
Symbol defaultValue)
Find value for given key.
|
java.lang.Object |
get(java.lang.String key) |
static Namespace |
getDefault() |
static Symbol |
getDefaultSymbol(java.lang.String name) |
protected int |
getEntryHashCode(gnu.mapping.SymbolRef entry)
Extract hash-code from Entry.
|
protected gnu.mapping.SymbolRef |
getEntryNext(gnu.mapping.SymbolRef entry)
Extract next Entry in same hash-bucket.
|
java.lang.String |
getName()
Get the name of this Namespace.
|
java.lang.String |
getPrefix() |
Symbol |
getSymbol(java.lang.String key)
Get a Symbol matching the given name.
|
boolean |
isConstant(java.lang.String key) |
boolean |
isUnknownNamespace()
A namespace with known prefix but unknown uri.
|
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)
Search for an existing Symbol with the give name.
|
protected gnu.mapping.SymbolRef |
makeEntry(java.lang.String key,
int hash,
Symbol value)
Allocate a new node in the hash table.
|
static Namespace |
makeUnknownNamespace(java.lang.String prefix)
Create a "placeholder" for a namespace with a known prefix
but unknown uri.
|
void |
readExternal(java.io.ObjectInput in) |
java.lang.Object |
readResolve() |
boolean |
remove(Symbol symbol) |
protected void |
setEntryNext(gnu.mapping.SymbolRef entry,
gnu.mapping.SymbolRef next)
Set next Entry in same hash-bucket.
|
void |
setName(java.lang.String name)
Set the name of this Namespace.
|
java.lang.String |
toString() |
static Namespace |
valueOf() |
static Namespace |
valueOf(java.lang.String name)
Return Namespace with the given name (namespace-URI).
|
static Namespace |
valueOf(java.lang.String uri,
SimpleSymbol prefix) |
static Namespace |
valueOf(java.lang.String uri,
java.lang.String prefix) |
static Namespace |
valueOfNoCreate(java.lang.String name)
Return Namespace with the given name (namespace-URI), if it exists.
|
void |
writeExternal(java.io.ObjectOutput out) |
clear, entrySet, get, getNode, getOrDefault, hash, hashToIndex, matches, matches, put, put, rehash, remove, size
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, values
protected static final java.util.Hashtable nsTable
public static final Namespace EmptyNamespace
protected java.lang.String prefix
public static final java.lang.String UNKNOWN_NAMESPACE
public final java.lang.String getName()
public final void setName(java.lang.String name)
public final java.lang.String getPrefix()
public static Namespace create(int capacity)
public static Namespace create()
public static Namespace getDefault()
public static Symbol getDefaultSymbol(java.lang.String name)
public static Namespace valueOf()
public static Namespace valueOf(java.lang.String name)
public static Namespace valueOfNoCreate(java.lang.String name)
public static Namespace valueOf(java.lang.String uri, java.lang.String prefix)
public static Namespace valueOf(java.lang.String uri, SimpleSymbol prefix)
public boolean isUnknownNamespace()
public static Namespace makeUnknownNamespace(java.lang.String prefix)
public java.lang.Object get(java.lang.String key)
get
in interface HasNamedParts
public boolean isConstant(java.lang.String key)
isConstant
in interface HasNamedParts
public Symbol getSymbol(java.lang.String key)
public Symbol lookup(java.lang.String key)
protected final Symbol lookupInternal(java.lang.String key, int hash)
key
- String - does not need to be interned.public Symbol get(java.lang.Object key, Symbol defaultValue)
AbstractHashTable
get
in class AbstractHashTable<gnu.mapping.SymbolRef,java.lang.String,Symbol>
public Symbol lookup(java.lang.String key, int hash, boolean create)
public boolean remove(Symbol symbol)
protected int getEntryHashCode(gnu.mapping.SymbolRef entry)
AbstractHashTable
getEntryHashCode
in class AbstractHashTable<gnu.mapping.SymbolRef,java.lang.String,Symbol>
protected gnu.mapping.SymbolRef getEntryNext(gnu.mapping.SymbolRef entry)
getEntryNext
in class AbstractHashTable<gnu.mapping.SymbolRef,java.lang.String,Symbol>
protected void setEntryNext(gnu.mapping.SymbolRef entry, gnu.mapping.SymbolRef next)
setEntryNext
in class AbstractHashTable<gnu.mapping.SymbolRef,java.lang.String,Symbol>
protected gnu.mapping.SymbolRef[] allocEntries(int n)
allocEntries
in class AbstractHashTable<gnu.mapping.SymbolRef,java.lang.String,Symbol>
protected gnu.mapping.SymbolRef makeEntry(java.lang.String key, int hash, Symbol value)
AbstractHashTable
makeEntry
in class AbstractHashTable<gnu.mapping.SymbolRef,java.lang.String,Symbol>
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
public java.lang.Object readResolve() throws java.io.ObjectStreamException
java.io.ObjectStreamException
public java.lang.String toString()
toString
in class java.util.AbstractMap<java.lang.String,Symbol>