KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > lisp > Nil


1 /*
2  * Nil.java
3  *
4  * Copyright (C) 2002-2004 Peter Graves
5  * $Id: Nil.java,v 1.37 2004/05/22 19:31:00 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */

21
22 package org.armedbear.lisp;
23
24 public final class Nil extends Symbol
25 {
26     public Nil(Package JavaDoc pkg)
27     {
28         super("NIL", pkg);
29         pkg.addSymbol(this);
30         setSymbolValue(this);
31         setSpecial(true);
32         setConstant(true);
33     }
34
35     public LispObject typeOf()
36     {
37         return Symbol.NULL;
38     }
39
40     public LispClass classOf()
41     {
42         return BuiltInClass.NULL;
43     }
44
45     public LispObject getDescription()
46     {
47         return new SimpleString("The symbol NIL");
48     }
49
50     public boolean getBooleanValue()
51     {
52         return false;
53     }
54
55     public LispObject typep(LispObject typeSpecifier) throws ConditionThrowable
56     {
57         if (typeSpecifier == Symbol.NULL)
58             return T;
59         if (typeSpecifier == Symbol.LIST)
60             return T;
61         if (typeSpecifier == Symbol.SEQUENCE)
62             return T;
63         if (typeSpecifier == Symbol.SYMBOL)
64             return T;
65         if (typeSpecifier == Symbol.BOOLEAN)
66             return T;
67         if (typeSpecifier == BuiltInClass.NULL)
68             return T;
69         if (typeSpecifier == BuiltInClass.LIST)
70             return T;
71         if (typeSpecifier == BuiltInClass.SEQUENCE)
72             return T;
73         if (typeSpecifier == BuiltInClass.SYMBOL)
74             return T;
75         return super.typep(typeSpecifier);
76     }
77
78     public boolean constantp()
79     {
80         return true;
81     }
82
83     public final LispObject getSymbolValue()
84     {
85         return this;
86     }
87
88     public LispObject car()
89     {
90         return this;
91     }
92
93     public LispObject cdr()
94     {
95         return this;
96     }
97
98     public final LispObject cadr()
99     {
100         return this;
101     }
102
103     public final LispObject cddr()
104     {
105         return this;
106     }
107
108     public int length()
109     {
110         return 0;
111     }
112
113     public LispObject push(LispObject obj)
114     {
115         return new Cons(obj);
116     }
117
118     public LispObject elt(int index) throws ConditionThrowable
119     {
120         return signal(new TypeError("ELT: invalid index " + index + " for " + this + "."));
121     }
122
123     public LispObject nreverse()
124     {
125         return this;
126     }
127
128     public LispObject[] copyToArray()
129     {
130         return new LispObject[0];
131     }
132
133     public boolean listp()
134     {
135         return true;
136     }
137
138     public LispObject LISTP()
139     {
140         return T;
141     }
142
143     public boolean endp()
144     {
145         return true;
146     }
147
148     public LispObject ENDP()
149     {
150         return T;
151     }
152
153     public LispObject NOT()
154     {
155         return T;
156     }
157
158     public final LispObject getSymbolFunction()
159     {
160         return null;
161     }
162
163     public String JavaDoc toString()
164     {
165         if (_PRINT_READABLY_.symbolValueNoThrow() != NIL)
166             return "|COMMON-LISP|::|NIL|";
167         return "NIL";
168     }
169 }
170
Popular Tags