gnu.mapping
Class Symbol

java.lang.Object
  extended by gnu.mapping.Symbol
All Implemented Interfaces:
EnvironmentKey, java.io.Externalizable, java.io.Serializable, java.lang.Comparable
Direct Known Subclasses:
Keyword

public class Symbol
extends java.lang.Object
implements EnvironmentKey, java.lang.Comparable, java.io.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.

See Also:
Serialized Form

Field Summary
static java.lang.Object FUNCTION
          Conventional value used as a property key for function bindings.
protected  java.lang.String name
           
static Symbol PLIST
          Conventional value used as a Symbol name to access an Object's property list.
 
Constructor Summary
Symbol()
           
Symbol(java.lang.String name)
           
Symbol(java.lang.String name, Namespace ns)
           
 
Method Summary
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object o)
          Just tests for identity.
 java.lang.Object getKeyProperty()
           
 Symbol getKeySymbol()
           
 java.lang.String getLocalName()
          Synonym for getName - the "print name" of the symbol without Namespace.
 java.lang.String getName()
           
 Namespace getNamespace()
           
 java.lang.String getNamespaceURI()
           
 boolean hasEmptyNamespace()
           
 int hashCode()
           
static Symbol make(java.lang.Object namespace, java.lang.String name)
          Find or create a symbol in a specificed environment.
 boolean matches(EnvironmentKey key)
           
 boolean matches(Symbol symbol, java.lang.Object property)
           
 void print(java.io.PrintWriter ps)
           
 void readExternal(java.io.ObjectInput in)
           
 java.lang.Object readResolve()
           
 void setNamespace(Namespace ns)
           
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

FUNCTION

public static final java.lang.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.)

Constructor Detail

Symbol

public Symbol()

Symbol

public Symbol(java.lang.String name)

Symbol

public Symbol(java.lang.String name,
              Namespace ns)
Method Detail

getKeySymbol

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

getKeyProperty

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

matches

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

matches

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

getNamespaceURI

public final java.lang.String getNamespaceURI()

hasEmptyNamespace

public final boolean hasEmptyNamespace()

getLocalName

public final java.lang.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 java.lang.String getName()

make

public static Symbol make(java.lang.Object namespace,
                          java.lang.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.

print

public void print(java.io.PrintWriter ps)

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

equals

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

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getNamespace

public final Namespace getNamespace()

setNamespace

public final void setNamespace(Namespace ns)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readResolve

public java.lang.Object readResolve()
                             throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException