/* Author: Jeff Dalton * Updated: Sun May 27 04:37:52 2001 by Jeff Dalton */ package ix.util.lisp; import java.util.*; import ix.util.*; /** The class of Lisp.NIL, and of nothing else. */ public final class Null extends LList { Null() { // package visibility Debug.assert(Lisp.NIL == null); // only one can be made } private static NullEnumeration enumeration = new NullEnumeration(); public boolean isNull() { return true; } public Object car() { return Lisp.NIL; } public LList cdr() { return Lisp.NIL; } public int length() { return 0; } public Object elementAt(int i) { return Lisp.NIL; } public Enumeration elements() { return enumeration; } public boolean equal(LList l) { return l == Lisp.NIL; } public boolean find(Object a) { return false; } public LList append(LList tail) { return tail; } protected Object readResolve() throws java.io.ObjectStreamException { // Deserialization magic to avoid multiple (visible) // instances of Null. The instances are created (it seems) // but then this method is called ... return Lisp.NIL; } // public String toString() { return "()"; } public String toString() { return "nil"; } } /** Null enumerations. */ final class NullEnumeration extends LListEnumeration implements Enumeration { public boolean hasMoreElements() { return false; } public Object nextElement() { return Lisp.NIL; } // return null? }