|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdanbikel.lisp.Sexp
danbikel.lisp.Symbol
public abstract class Symbol
Symbol
objects associate strings or integers with
unique references. This abstract base class, from which
StringSymbol
and IntSymbol
are derived,
allows for Symbol
objects that contain either an int
or a String
.
N.B.: The values in the
internal map maintained by this class are actually weak references
to unique Symbol
objects. This allows the reclamation
of symbols that are unreachable via strong (or soft) references.
In this way, the programmer need never be concerned about the symbol
map monotonically growing simply because the program continues to
instantiate new symbols.
StringSymbol
,
IntSymbol
,
Serialized FormConstructor Summary | |
---|---|
Symbol()
|
Method Summary | |
---|---|
static Symbol |
add(int intValue)
A convenience method for add(Integer) : the specified
int is first wrapped in an Integer object and
then added to the internal symbol map. |
static Symbol |
add(Integer intKey)
A synonym for get(Integer) . |
static Symbol |
add(String str)
A synonym for get(String) . |
static void |
clean()
Cleans the internal symbol map by removing all symbols to which there are no hard or soft references. |
Sexp |
deepCopy()
Returns a deep copy of this S-expression. |
static Symbol |
get(int intValue)
A convenience method for add(Integer) : the specified
int is first wrapped in an Integer object and
then added to the internal symbol map. |
static Symbol |
get(Integer intKey)
Returns the unique Symbol whose integer value is that of
intKey . |
static Symbol |
get(String str)
Returns the unique Symbol whose string key is
str . |
abstract Integer |
getInteger()
Gets the Integer object associated with this Symbol. |
protected abstract Object |
getSymKey()
Gets the unique key for this symbol used by the internal symbol map. |
boolean |
isList()
Returns false , as no instance of a subclass of this abstract
base class can be a list. |
boolean |
isSymbol()
Returns true , as any instance of a subclass of this abstract
base class is a symbol. |
abstract String |
toString()
Gets the string representation of this symbol. |
Methods inherited from class danbikel.lisp.Sexp |
---|
getCanonical, list, main, read, read, read, readExternal, symbol, writeExternal |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Symbol()
Method Detail |
---|
public abstract Integer getInteger()
Integer
object associated with this Symbol.
Integer
object associated with this Symbol
if it's an instance of IntSymbol
, else null
.public abstract String toString()
toString
in class Object
protected abstract Object getSymKey()
public final Sexp deepCopy()
Sexp
deepCopy
in class Sexp
public final boolean isList()
false
, as no instance of a subclass of this abstract
base class can be a list.
isList
in class Sexp
false
, as no instance of a subclass of this abstract
base class can be a list.public final boolean isSymbol()
true
, as any instance of a subclass of this abstract
base class is a symbol.
isSymbol
in class Sexp
true
, as any instance of a subclass of this abstract
base class is a symbol.public static final Symbol get(String str)
Symbol
whose string key is
str
. If the symbol does not already exist in the internal
symbol map, it is added and returned.
str
- the print name of the string symbol to get
Symbol
whose string key is
str
.public static final Symbol add(String str)
get(String)
.
str
- the print name of the string symbol to get
Symbol
whose string key is
str
.public static final Symbol get(Integer intKey)
Symbol
whose integer value is that of
intKey
. If the symbol does not already exist in the internal
symbol map, it is added and returned.
intKey
- the integer value of the symbol to get
Symbol
whose integer value is that of
intKey
.public static final Symbol add(Integer intKey)
get(Integer)
.
intKey
- the integer value of the symbol to get
Symbol
whose integer value is that of
intKey
.public static final Symbol add(int intValue)
add(Integer)
: the specified
int
is first wrapped in an Integer
object and
then added to the internal symbol map.
intValue
- the integer value to be wrapped with an
Integer
and added to the symbol map
Symbol
whose integer value is that of
intValue
.public static final Symbol get(int intValue)
add(Integer)
: the specified
int
is first wrapped in an Integer
object and
then added to the internal symbol map.
intValue
- the integer value to be wrapped with an
Integer
and added to the symbol map
Symbol
whose integer value is that of
intValue
.public static final void clean()
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |