gnu.mapping

Class Symbol

public class Symbol extends 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 SymbolFUNCTION
Conventional value used as a property key for function bindings.
protected Stringname
static SymbolPLIST
Conventional value used as a Symbol name to access an Object's property list.
Constructor Summary
Symbol()
Symbol(Namespace ns, String name)
Create new Symbol in a given namespace.
Method Summary
intcompareTo(Object o)
static booleanequals(Symbol sym1, Symbol sym2)
booleanequals(Object o)
Just tests for identity.
ObjectgetKeyProperty()
SymbolgetKeySymbol()
StringgetLocalName()
Synonym for getName - the "print name" of the symbol without Namespace.
StringgetLocalPart()
StringgetName()
NamespacegetNamespace()
StringgetNamespaceURI()
StringgetPrefix()
booleanhasEmptyNamespace()
inthashCode()
static Symbolmake(String uri, String name, String prefix)
Find or create a symbol in a specificed namespace.
static Symbolmake(Object namespace, String name)
Find or create a symbol in a specificed namespace.
static SymbolmakeUninterned(String name)
static SymbolmakeWithUnknownNamespace(String local, String prefix)
Make a placeholder symbol with a known prefix and unknown namespace-uri.
booleanmatches(EnvironmentKey key)
booleanmatches(Symbol symbol, Object property)
static Symbolparse(String symbol)
Parse a String as a Symbol.
voidreadExternal(ObjectInput in)
ObjectreadResolve()
voidsetNamespace(Namespace ns)
StringtoString()
voidwriteExternal(ObjectOutput out)

Field Detail

FUNCTION

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

name

protected String name

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.)

Constructor Detail

Symbol

public Symbol()

Symbol

public Symbol(Namespace ns, String name)
Create new Symbol in a given namespace. Does not enter the result in the namespace's symbol table.

Parameters: name an interned String

Method Detail

compareTo

public int compareTo(Object o)

equals

public static boolean equals(Symbol sym1, Symbol sym2)

equals

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

getKeyProperty

public final Object getKeyProperty()

getKeySymbol

public final Symbol getKeySymbol()

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.

getLocalPart

public final String getLocalPart()

getName

public final String getName()

getNamespace

public final Namespace getNamespace()

getNamespaceURI

public final String getNamespaceURI()

getPrefix

public final String getPrefix()

hasEmptyNamespace

public final boolean hasEmptyNamespace()

hashCode

public int hashCode()

make

public static Symbol make(String uri, String name, String prefix)
Find or create a symbol in a specificed namespace.

Parameters: uri a namespace uri. name The "local name" or "print name" of the desired symbol. prefix namespace prefix, or {@code ""}

make

public static Symbol make(Object namespace, String name)
Find or create a symbol in a specificed namespace.

Parameters: namespace can be an Namespace, or a namespace/environment name (resolved using Namespace.getInstance), or null (in which case an uninterned symbol is created). name The "local name" or "print name" of the desired symbol.

makeUninterned

public static Symbol makeUninterned(String name)

makeWithUnknownNamespace

public static Symbol makeWithUnknownNamespace(String local, String prefix)
Make a placeholder symbol with a known prefix and unknown namespace-uri. This is convenient for processing definition commands like {@code "prefix:name=value"} - such as on the Kawa command-line - where we don't yet know the namespace-uri. Code that later looks for a value should look both under the true namespace-uri and less LOG.JA * using this method (or {@link Namespace#makeUnknownNamespace}).

matches

public boolean matches(EnvironmentKey key)

matches

public boolean matches(Symbol symbol, Object property)

parse

public static Symbol parse(String symbol)
Parse a String as a Symbol. Recognizes:

readExternal

public void readExternal(ObjectInput in)

readResolve

public Object readResolve()

setNamespace

public final void setNamespace(Namespace ns)

toString

public String toString()

writeExternal

public void writeExternal(ObjectOutput out)