Class SchemeObject

java.lang.Object
  |
  +--SchemeObject
Direct Known Subclasses:
SchemeBoolean, SchemeList, SchemeNumber, SchemeString, SchemeSymbol

public abstract class SchemeObject
extends java.lang.Object

This is the abstract base class for the SchemeObject hierarchy.


Constructor Summary
SchemeObject()
           
 
Method Summary
 SchemeObject cadddr()
          This calls getCar() and/or getCdr()
 SchemeObject caddr()
          This calls getCar() and/or getCdr()
 SchemeObject cadr()
          This calls getCar() and/or getCdr()
 SchemeObject car()
          This calls getCar() and/or getCdr()
 SchemeObject cdar()
          This calls getCar() and/or getCdr()
 SchemeObject cddr()
          This calls getCar() and/or getCdr()
 SchemeObject cdr()
          This calls getCar() and/or getCdr()
 SchemeObject getCar()
          Dealing with the static type system of Java is not convenient when manipulating SchemeObjects because Scheme itself is denamically typed.
 SchemeObject getCdr()
          Dealing with the static type system of Java is not convenient when manipulating SchemeObjects because Scheme itself is denamically typed.
static SchemeObject read(java.io.InputStream inputStream)
          This reads in a SchemeObject from the InputStream that is passed in.
static SchemeObject read(java.lang.String s)
          This reads in a SchemeObject from the String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemeObject

public SchemeObject()
Method Detail

getCar

public SchemeObject getCar()
Dealing with the static type system of Java is not convenient when manipulating SchemeObjects because Scheme itself is denamically typed. To make manipulating Scheme objects and lists in particular more convenient we make all SchemeObjects provide a getCar() and getCdr() method. If the object is not a SchemePair then these methods should through a ClassCastException. As such, the following are equivalent:
 SchemeObject o = ...;

 System.out.println(o.getCar());
 
and
 SchemeObject o = ...;

 Scheme.out.println(((SchemePair)o).getCar());
 
Returns:
The car of the SchemePair.
Throws:
ClassCastException - if this object does not override this method.
See Also:
SchemePair

getCdr

public SchemeObject getCdr()
Dealing with the static type system of Java is not convenient when manipulating SchemeObjects because Scheme itself is denamically typed. To make manipulating Scheme objects and lists in particular more convenient we make all SchemeObjects provide a getCar() and getCdr() method. If the object is not a SchemePair then these methods should through a ClassCastException. As such, the following are equivalent:
 SchemeObject o = ...;

 System.out.println(o.getCdr());
 
and
 SchemeObject o = ...;

 Scheme.out.println(((SchemePair)o).getCdr());
 
Returns:
The cdr of the SchemePair.
Throws:
ClassCastException - if this object does not override this method.
See Also:
SchemePair

car

public SchemeObject car()
This calls getCar() and/or getCdr()
Returns:
The car of the SchemePair.
Throws:
ClassCastException - if this object does not override this method.
See Also:
SchemePair, getCar(), getCdr()

cdr

public SchemeObject cdr()
This calls getCar() and/or getCdr()
Returns:
The cdr of the SchemePair.
Throws:
ClassCastException - if this object does not override this method.
See Also:
SchemePair, getCar(), getCdr()

cadr

public SchemeObject cadr()
This calls getCar() and/or getCdr()
Returns:
The cadr of the SchemePair.
Throws:
ClassCastException - if this object does not override this method.
See Also:
SchemePair, getCar(), getCdr()

caddr

public SchemeObject caddr()
This calls getCar() and/or getCdr()
Returns:
The caddr of the SchemePair.
Throws:
ClassCastException - if this object does not override this method.
See Also:
SchemePair, getCar(), getCdr()

cddr

public SchemeObject cddr()
This calls getCar() and/or getCdr()
Returns:
The cddr of the SchemePair.
Throws:
ClassCastException - if this object does not override this method.
See Also:
SchemePair, getCar(), getCdr()

cadddr

public SchemeObject cadddr()
This calls getCar() and/or getCdr()
Returns:
The cadddr of the SchemePair.
Throws:
ClassCastException - if this object does not override this method.
See Also:
SchemePair, getCar(), getCdr()

cdar

public SchemeObject cdar()
This calls getCar() and/or getCdr()
Returns:
The cdar of the SchemePair.
Throws:
ClassCastException - if this object does not override this method.
See Also:
SchemePair, getCar(), getCdr()

read

public static SchemeObject read(java.lang.String s)
                         throws java.io.IOException,
                                EndOfSchemeListException
This reads in a SchemeObject from the String.
Parameters:
s - String to read a SchemeObject from.
See Also:
read(InputStream inputStream), StringInputStream

read

public static SchemeObject read(java.io.InputStream inputStream)
                         throws java.io.IOException,
                                EndOfSchemeListException
This reads in a SchemeObject from the InputStream that is passed in. Subsequent calls to read with this InputStream are only guaranteed to work correctly if this InputStream is in fact a PushbackInputStream. To get a PushbackInputStream from an InputStream (for example System.in) use new PushbackInputStream(System.in).
Parameters:
inputStream - The InputStream to read the SchemeObject from.
Returns:
SchemeObject represting what was read in.
Throws:
java.io.IOException - if an there is an error reading from the stream.
EndOfSchemeListException - if there is an unexpected end of a list expression. For example: ")".
See Also:
InputStream, java.io.PushbackInputStream