Package gnu.expr
Class Keyword
- java.lang.Object
-
- gnu.mapping.Symbol
-
- gnu.expr.Keyword
-
- All Implemented Interfaces:
EnvironmentKey,java.io.Externalizable,java.io.Serializable,java.lang.Comparable
public class Keyword extends Symbol implements java.io.Externalizable
Implementation of Lisp keywords. Keywords are symbolic identifiers that evaluate to themselves, as opposed to symbols which generally name other values.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SymbolasSymbol()Get the corresponding non-keyword symbol.static booleanisKeyword(java.lang.Object obj)Test whether an object is a keyword.static Keywordmake(java.lang.String name)Create or find a Keyword with a given name (without ':').voidreadExternal(java.io.ObjectInput in)java.lang.ObjectreadResolve()static java.lang.ObjectsearchForKeyword(java.lang.Object[] vals, int offset, java.lang.Object keyword)Search vals[0:offset-1] for a keyword.static java.lang.ObjectsearchForKeyword(java.lang.Object[] vals, int offset, java.lang.Object keyword, java.lang.Object dfault)Search vals[0:offset-1] for a keyword.java.lang.StringtoString()voidwriteExternal(java.io.ObjectOutput out)-
Methods inherited from class gnu.mapping.Symbol
compareTo, equals, equals, getKeyProperty, getKeySymbol, getLocalName, getLocalPart, getName, getNamespace, getNamespaceURI, getPrefix, hasEmptyNamespace, hashCode, hasUnknownNamespace, make, make, makeUninterned, makeUninterned, makeWithUnknownNamespace, matches, matches, parse, setNamespace, toString, valueOf, valueOf, valueOf
-
-
-
-
Field Detail
-
keywordNamespace
public static final Namespace keywordNamespace
-
-
Constructor Detail
-
Keyword
public Keyword()
-
Keyword
public Keyword(Namespace namespace, java.lang.String name)
Used for constructing literals (int gnu.expr.LitTable).
-
-
Method Detail
-
asSymbol
public Symbol asSymbol()
Get the corresponding non-keyword symbol. Informally, the symbol corresponding to dropping the ':'.
-
make
public static Keyword make(java.lang.String name)
Create or find a Keyword with a given name (without ':').- Parameters:
name- the print-name of the desired Keyword- Returns:
- a Keyword with the given name, newly created iff none such exist
-
isKeyword
public static boolean isKeyword(java.lang.Object obj)
Test whether an object is a keyword.- Parameters:
obj- the object to test.- Returns:
trueif the object is a keyword,falseotherwise.
-
searchForKeyword
public static java.lang.Object searchForKeyword(java.lang.Object[] vals, int offset, java.lang.Object keyword)Search vals[0:offset-1] for a keyword. Each key at vals[i] is followed by a value at keys[i+1]. (This is used to search for a keyword parameter in an argument list.)- Parameters:
vals- the list to search inoffset- the index in vals to start the search atkeyword- the keyword to search for- Returns:
- vals[i+1] such that vals[i]==keyword (and (i-offset) is even and non-negative); if there is no such i, return Special.dfault.
-
searchForKeyword
public static java.lang.Object searchForKeyword(java.lang.Object[] vals, int offset, java.lang.Object keyword, java.lang.Object dfault)Search vals[0:offset-1] for a keyword. Each key at vals[i] is followed by a value at keys[i+1]. (This is used to search for a keyword parameter in an argument list.)- Parameters:
vals- the list to search inoffset- the index in vals to start the search atkeyword- the keyword to search fordfault- the value to return if there is no match- Returns:
- vals[i+1] such that vals[i]==keyword (and (i-offset) is even and non-negative); if there is no such i, return dfault.
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Overrides:
writeExternalin classSymbol- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Overrides:
readExternalin classSymbol- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
readResolve
public java.lang.Object readResolve() throws java.io.ObjectStreamException- Overrides:
readResolvein classSymbol- Throws:
java.io.ObjectStreamException
-
-