org.w3c.tools.sexpr
Class Cons

java.lang.Object
  extended by org.w3c.tools.sexpr.Cons
All Implemented Interfaces:
SExpr

public class Cons
extends java.lang.Object
implements SExpr

Basic class for implementing linked lists a la Lisp.


Constructor Summary
Cons(java.lang.Object left)
          Initializes a Cons cell with a left subtree only.
Cons(java.lang.Object left, java.lang.Object right)
          Initializes a Cons cell with the left and right "subtrees".
 
Method Summary
 java.util.Enumeration elements()
           
 java.lang.Object left()
          Returns the left subtree (i.e.
 void printExpr(java.io.PrintStream stream)
          Print a representation of the s-expression into the output stream.
 Cons rest()
          Returns the tail of a cons cell if it is a list.
 java.lang.Object right()
          Returns the right subtree (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cons

public Cons(java.lang.Object left,
            java.lang.Object right)
Initializes a Cons cell with the left and right "subtrees".


Cons

public Cons(java.lang.Object left)
Initializes a Cons cell with a left subtree only. Right subtree will be set to null.

Method Detail

left

public java.lang.Object left()
Returns the left subtree (i.e. the head) of a cons cell.


right

public java.lang.Object right()
Returns the right subtree (i.e. the tail) of a cons cell.


rest

public Cons rest()
          throws SExprParserException
Returns the tail of a cons cell if it is a list. Signals an error otherwise (no dotted pairs allowed).

Throws:
SExprParserException - if the tail is not a Cons or null

elements

public java.util.Enumeration elements()

printExpr

public void printExpr(java.io.PrintStream stream)
Description copied from interface: SExpr
Print a representation of the s-expression into the output stream.

Specified by:
printExpr in interface SExpr