|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdanbikel.lisp.Sexp
public abstract class Sexp
This class provides the abstract base type for S-epxressions, which are either symbols or lists.
Symbol
,
SexpList
,
Serialized FormMethod Summary | |
---|---|
abstract Sexp |
deepCopy()
Returns a deep copy of this S-expression. |
Sexp |
getCanonical(Map map)
Returns a canonical version of this S-expression. |
abstract boolean |
isList()
Returns true if this is an instance of a
SexpList , false otherwise. |
abstract boolean |
isSymbol()
Returns true if this is an instance of a Symbol ,
false otherwise. |
SexpList |
list()
Returns this object cast to a SexpList . |
static void |
main(String[] args)
A (very simple) test driver for this class. |
static Sexp |
read(SexpTokenizer tok)
Returns the S-expression contained in the stream held by tok . |
static Sexp |
read(SexpTokenizer tok,
char open,
char close)
|
static Sexp |
read(String in)
Returns the S-expression contained in the specified string. |
abstract void |
readExternal(ObjectInput oi)
Reads this Sexp object from the specified object stream (to be
implemented by all concrete subclasses). |
Symbol |
symbol()
Returns this object cast to a Symbol . |
abstract void |
writeExternal(ObjectOutput oo)
Writes this Sexp object from the specified object stream (to be
implemented by all concrete subclasses). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public final Symbol symbol()
Symbol
.
Symbol
.
ClassCastException
- if this object is not type-compatible with
Symbol
public final SexpList list()
SexpList
.
SexpList
.
ClassCastException
- if this object is not type-compatible with
SexpList
public abstract boolean isList()
true
if this is an instance of a
SexpList
, false
otherwise.
true
if this is an instance of a
SexpList
, false
otherwise.public abstract boolean isSymbol()
true
if this is an instance of a Symbol
,
false
otherwise.
true
if this is an instance of a Symbol
,
false
otherwise.public abstract Sexp deepCopy()
public final Sexp getCanonical(Map map)
SexpList.emptyList
is returned; otherwise, if it is
a key in map
, the map's value for this list is
returned; otherwise, this list is added as a reflexive key-value
pair in map
, after its trimToSize
method
has been invoked. Note that this method has a superset of
the functionality of SexpList.getCanonical(SexpList)
.
map
- the reflexive map of SexpList
objects with
which to canonicalize this Sexp
object
SexpList.getCanonical(SexpList)
,
SexpList.trimToSize()
public static Sexp read(SexpTokenizer tok) throws IOException
tok
.
If there are no tokens remaining in tok
, this method returns
null
.
tok
- the tokenizer from which to read an S-expression
IOException
- if there is an unexpected end of stream, mismatched
parentheses or an unexpected characterpublic static Sexp read(SexpTokenizer tok, char open, char close) throws IOException
IOException
public static Sexp read(String in) throws IOException
null
.
in
- the string from which to read an S-expression
IOException
- if there was an underlying problem reading from
the specified stringpublic abstract void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException
Sexp
object from the specified object stream (to be
implemented by all concrete subclasses).
readExternal
in interface Externalizable
oi
- the object input stream
IOException
- if the underlying stream has an exception
ClassNotFoundException
- if the class of the object that is read
cannot be foundpublic abstract void writeExternal(ObjectOutput oo) throws IOException
Sexp
object from the specified object stream (to be
implemented by all concrete subclasses).
writeExternal
in interface Externalizable
oo
- the object output stream to which this object will be written
IOException
- if the underlying stream thrown an exceptionpublic static void main(String[] args)
args
- arguments (all currently ignored)
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |