gnu.mapping

Class Symbol

Implemented Interfaces:
Comparable, EnvironmentKey, Externalizable
Known Direct Subclasses:
Keyword

public class Symbol
extends java.lang.Object
implements EnvironmentKey, Comparable, Externalizable

A Symbol is a name, usually in a specific Namespace. A Symbol is stateless: Comon Lisp-style "value", "function" and "property list" bindings are not part of the Symbol itself, but looked up in the current Environment. A Symbol may be viewed as an EnvironmentKey with a null property component.

Field Summary

static Object
FUNCTION
Conventional value used as a property key for function bindings.
static Symbol
PLIST
Conventional value used as a Symbol name to access an Object's property list.
protected String
name

Fields inherited from interface gnu.mapping.EnvironmentKey

FUNCTION

Constructor Summary

Symbol()
Symbol(String name)
Symbol(String name, Namespace ns)

Method Summary

int
compareTo(Object o)
boolean
equals(Object o)
Just tests for identity.
Object
getKeyProperty()
Symbol
getKeySymbol()
String
getLocalName()
Synonym for getName - the "print name" of the symbol without Namespace.
String
getName()
Namespace
getNamespace()
String
getNamespaceURI()
boolean
hasEmptyNamespace()
int
hashCode()
static Symbol
make(Object namespace, String name)
Find or create a symbol in a specificed environment.
boolean
matches(EnvironmentKey key)
boolean
matches(Symbol symbol, Object property)
void
print(java.io.PrintWriter ps)
void
readExternal(ObjectInput in)
Object
readResolve()
void
setNamespace(Namespace ns)
String
toString()
void
writeExternal(ObjectOutput out)

Field Details

FUNCTION

public static final Object FUNCTION
Conventional value used as a property key for function bindings.

PLIST

public static final Symbol PLIST
Conventional value used as a Symbol name to access an Object's property list. A property list is a list with a even number of Pairs, containing alternating keys and values. They are used in Common Lisp and Emacs Lisp. Kawa (following XEmacs) allows arbitrary objects to have property lists, thus the PLIST as used as the name and the object as the property. (In the future we'll do somethingg clever so that get(SYMBOL, KEY) as the same as getf(get(PLIST, SYMBOL), KEY) - but much faster.)

name

protected String name

Constructor Details

Symbol

public Symbol()

Symbol

public Symbol(String name)

Symbol

public Symbol(String name,
              Namespace ns)

Method Details

compareTo

public int compareTo(Object o)

equals

public boolean equals(Object o)
Just tests for identity. Otherwise hashTables that have Symbols as keys will break.

getKeyProperty

public final Object getKeyProperty()
Specified by:
getKeyProperty in interface EnvironmentKey

getKeySymbol

public final Symbol getKeySymbol()
Specified by:
getKeySymbol in interface EnvironmentKey

getLocalName

public final String getLocalName()
Synonym for getName - the "print name" of the symbol without Namespace. Useful when thinking of a Symbol as an XML QName.

getName

public final String getName()

getNamespace

public final Namespace getNamespace()

getNamespaceURI

public final String getNamespaceURI()

hasEmptyNamespace

public final boolean hasEmptyNamespace()

hashCode

public int hashCode()

make

public static Symbol make(Object namespace,
                          String name)
Find or create a symbol in a specificed environment.
Parameters:
namespace - can be an Namespace, or a namespace/environment name (resolved using Environment.getInstance), or null (in which case an uninterned symbol is created).
name - The "local name" or "print name" of the desired symbol.

matches

public boolean matches(EnvironmentKey key)
Specified by:
matches in interface EnvironmentKey

matches

public boolean matches(Symbol symbol,
                       Object property)
Specified by:
matches in interface EnvironmentKey

print

public void print(java.io.PrintWriter ps)

readExternal

public void readExternal(ObjectInput in)
            throws IOException,
                   ClassNotFoundException

readResolve

public Object readResolve()
            throws ObjectStreamException

setNamespace

public final void setNamespace(Namespace ns)

toString

public String toString()

writeExternal

public void writeExternal(ObjectOutput out)
            throws IOException