gnu.expr

Class Keyword

Implemented Interfaces:
Comparable, Externalizable, EnvironmentKey, Externalizable, Printable

public class Keyword
extends Symbol
implements Printable, Externalizable

Field Summary

static Namespace
keywordNamespace

Fields inherited from class gnu.mapping.Symbol

FUNCTION, PLIST, name

Fields inherited from interface gnu.mapping.EnvironmentKey

FUNCTION

Constructor Summary

Keyword()
Keyword(Namespace namespace, String name)
Used for constructing literals (int gnu.expr.LitTable).

Method Summary

Symbol
asSymbol()
Get the corresponding non-keyword symbol.
static boolean
isKeyword(Object obj)
static Keyword
make(String name)
Create or find a Keyword with a given name (without final ':').
void
print(Consumer out)
void
readExternal(ObjectInput in)
Object
readResolve()
static Object
searchForKeyword(Object[] vals, int offset, Object keyword)
Search vals[0:offset-1] for a keyword.
static Object
searchForKeyword(Object[] vals, int offset, Object keyword, Object dfault)
Search vals[0:offset-1] for a keyword.
String
toString()
void
writeExternal(ObjectOutput out)

Methods inherited from class gnu.mapping.Symbol

compareTo, equals, equals, getKeyProperty, getKeySymbol, getLocalName, getLocalPart, getName, getNamespace, getNamespaceURI, getPrefix, hasEmptyNamespace, hashCode, make, make, makeUninterned, makeWithUnknownNamespace, matches, matches, parse, readExternal, readResolve, setNamespace, toString, writeExternal

Field Details

keywordNamespace

public static final Namespace keywordNamespace

Constructor Details

Keyword

public Keyword()

Keyword

public Keyword(Namespace namespace,
               String name)
Used for constructing literals (int gnu.expr.LitTable).

Method Details

asSymbol

public Symbol asSymbol()
Get the corresponding non-keyword symbol. Informally, the symbol corresponding to dropping the ':'.

isKeyword

public static boolean isKeyword(Object obj)

make

public static Keyword make(String name)
Create or find a Keyword with a given name (without final ':').
Parameters:
name - the print-name of the desired Keyword
Returns:
a Keyword with the given name, newly created iff none such exist

print

public void print(Consumer out)
Specified by:
print in interface Printable

readExternal

public void readExternal(ObjectInput in)
            throws IOException,
                   ClassNotFoundException
Overrides:
readExternal in interface Symbol

readResolve

public Object readResolve()
            throws ObjectStreamException
Overrides:
readResolve in interface Symbol

searchForKeyword

public static Object searchForKeyword(Object[] vals,
                                      int offset,
                                      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 in
offset - the index in vals to start the search at
keyword - 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 Object searchForKeyword(Object[] vals,
                                      int offset,
                                      Object keyword,
                                      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 in
offset - the index in vals to start the search at
keyword - the keyword to search for
dfault - 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.

toString

public final String toString()
Overrides:
toString in interface Symbol

writeExternal

public void writeExternal(ObjectOutput out)
            throws IOException
Overrides:
writeExternal in interface Symbol