public class Symbol extends java.lang.Object implements EnvironmentKey, java.lang.Comparable, java.io.Externalizable
Symbol
may be viewed as an EnvironmentKey
with a null
property component.Modifier and Type | Field and Description |
---|---|
static Symbol |
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. |
Modifier | Constructor and Description |
---|---|
|
Symbol() |
protected |
Symbol(java.lang.String name,
Namespace ns)
Create new Symbol in a given namespace.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object o) |
boolean |
equals(java.lang.Object o)
Just tests for identity.
|
static boolean |
equals(Symbol sym1,
Symbol sym2) |
java.lang.Object |
getKeyProperty() |
Symbol |
getKeySymbol() |
java.lang.String |
getLocalName()
Synonym for getName - the "print name" of the symbol without Namespace.
|
java.lang.String |
getLocalPart() |
java.lang.String |
getName() |
Namespace |
getNamespace() |
java.lang.String |
getNamespaceURI() |
java.lang.String |
getPrefix() |
boolean |
hasEmptyNamespace() |
int |
hashCode() |
boolean |
hasUnknownNamespace() |
static Symbol |
make(java.lang.Object namespace,
java.lang.String name)
Find or create a symbol in a specificed namespace.
|
static Symbol |
make(java.lang.String uri,
java.lang.String name,
java.lang.String prefix)
Find or create a symbol in a specificed namespace.
|
static Symbol |
makeUninterned(java.lang.String name) |
static Symbol |
makeUninterned(java.lang.String name,
Namespace namespace) |
static Symbol |
makeWithUnknownNamespace(java.lang.String local,
java.lang.String prefix)
Make a placeholder symbol with a known prefix and unknown namespace-uri.
|
boolean |
matches(EnvironmentKey key) |
boolean |
matches(Symbol symbol,
java.lang.Object property) |
static Symbol |
parse(java.lang.String symbol)
Parse a String as a Symbol.
|
void |
readExternal(java.io.ObjectInput in) |
java.lang.Object |
readResolve() |
void |
setNamespace(Namespace ns) |
java.lang.String |
toString() |
java.lang.String |
toString(char style)
Convert a Symbol to a printable String.
|
static SimpleSymbol |
valueOf(java.lang.String name) |
static Symbol |
valueOf(java.lang.String name,
java.lang.Object spec) |
static Symbol |
valueOf(java.lang.String name,
java.lang.String namespace,
java.lang.String prefix) |
void |
writeExternal(java.io.ObjectOutput out) |
protected java.lang.String name
public static final Symbol FUNCTION
public static final Symbol PLIST
Symbol
name to
access an Object
's property list.
A property list is a list with a even number of
Pair
s, 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.)public Symbol()
protected Symbol(java.lang.String name, Namespace ns)
name
- an interned Stringpublic final Symbol getKeySymbol()
getKeySymbol
in interface EnvironmentKey
public final java.lang.Object getKeyProperty()
getKeyProperty
in interface EnvironmentKey
public boolean matches(EnvironmentKey key)
matches
in interface EnvironmentKey
public boolean matches(Symbol symbol, java.lang.Object property)
matches
in interface EnvironmentKey
public final java.lang.String getNamespaceURI()
public final java.lang.String getLocalPart()
public final java.lang.String getPrefix()
public final boolean hasEmptyNamespace()
public final boolean hasUnknownNamespace()
public final java.lang.String getLocalName()
public final java.lang.String getName()
public static Symbol make(java.lang.String uri, java.lang.String name, java.lang.String prefix)
uri
- a namespace uri.name
- The "local name" or "print name" of the desired symbol.prefix
- namespace prefix, or ""
public static Symbol make(java.lang.Object namespace, java.lang.String name)
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.public static SimpleSymbol valueOf(java.lang.String name)
public static Symbol valueOf(java.lang.String name, java.lang.Object spec)
public static Symbol valueOf(java.lang.String name, java.lang.String namespace, java.lang.String prefix)
public static Symbol parse(java.lang.String symbol)
"{namespace-uri}:local-name"
- which creates a
symbol with that namespace-uri and an empty prefix;
"{namespace-uri}local-name"
- which is the same as above
"prefix{namespace-uri}:local-name"
- which creates a
symbok with that prefix and namespace-uri
"prefix:local-name"
- which creates a symbol with that prefix
and an "unknown" namespace-uri, using makeWithUnknownNamespace(java.lang.String, java.lang.String)
;
"local-name"
- which creates a symbol in
Namespace.EmptyNamespace
.
public static Symbol makeWithUnknownNamespace(java.lang.String local, java.lang.String prefix)
"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
the prefix combined with Namespace.makeUnknownNamespace(String)
.public static Symbol makeUninterned(java.lang.String name)
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public final boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public final Namespace getNamespace()
public final void setNamespace(Namespace ns)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(char style)
style
- if 'P' then print prefix if available (otherwise Uri),
if 'U' then print Uri if available (otherwise prefix),
if '+' then print both if available.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