KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * UnboundSlot.java
3  *
4  * Copyright (C) 2003-2004 Peter Graves
5  * $Id: UnboundSlot.java,v 1.3 2004/05/25 15:53:50 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 UnboundSlot extends CellError
25 {
26     private LispObject instance = NIL;
27
28     public UnboundSlot(LispObject initArgs) throws ConditionThrowable
29     {
30         super(initArgs);
31         LispObject first, second;
32         while (initArgs != NIL) {
33             first = initArgs.car();
34             initArgs = initArgs.cdr();
35             second = initArgs.car();
36             if (first == Keyword.INSTANCE) {
37                 instance = second;
38                 break;
39             }
40             initArgs = initArgs.cdr();
41         }
42     }
43
44     public LispObject getInstance()
45     {
46         return instance;
47     }
48
49     public String JavaDoc getMessage()
50     {
51         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("The slot ");
52         sb.append(safeWriteToString(getCellName()));
53         sb.append(" is unbound in the object ");
54         sb.append(safeWriteToString(instance));
55         sb.append('.');
56         return sb.toString();
57     }
58
59     public LispObject typeOf()
60     {
61         return Symbol.UNBOUND_SLOT;
62     }
63
64     public LispClass classOf()
65     {
66         return BuiltInClass.UNBOUND_SLOT;
67     }
68
69     public LispObject typep(LispObject type) throws ConditionThrowable
70     {
71         if (type == Symbol.UNBOUND_SLOT)
72             return T;
73         if (type == BuiltInClass.UNBOUND_SLOT)
74             return T;
75         return super.typep(type);
76     }
77 }
78
Popular Tags