01: /*
02: * SimpleCondition.java
03: *
04: * Copyright (C) 2003 Peter Graves
05: * $Id: SimpleCondition.java,v 1.8 2003/12/13 00:58:51 piso Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * 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 class SimpleCondition extends Condition {
25: public SimpleCondition() {
26: setFormatControl(NIL);
27: setFormatArguments(NIL);
28: }
29:
30: public SimpleCondition(LispObject formatControl,
31: LispObject formatArguments) {
32: setFormatControl(formatControl);
33: setFormatArguments(formatArguments);
34: }
35:
36: public SimpleCondition(LispObject initArgs)
37: throws ConditionThrowable {
38: super (initArgs);
39: }
40:
41: public SimpleCondition(String message) {
42: super (message);
43: }
44:
45: public LispObject typeOf() {
46: return Symbol.SIMPLE_CONDITION;
47: }
48:
49: public LispClass classOf() {
50: return BuiltInClass.SIMPLE_CONDITION;
51: }
52:
53: public LispObject typep(LispObject type) throws ConditionThrowable {
54: if (type == Symbol.SIMPLE_CONDITION)
55: return T;
56: if (type == BuiltInClass.SIMPLE_CONDITION)
57: return T;
58: return super .typep(type);
59: }
60:
61: // ### simple-condition-format-control
62: private static final Primitive1 SIMPLE_CONDITION_FORMAT_CONTROL = new Primitive1(
63: "simple-condition-format-control", "condition") {
64: public LispObject execute(LispObject arg)
65: throws ConditionThrowable {
66: if (arg instanceof Condition)
67: return ((Condition) arg).getFormatControl();
68: return signal(new TypeError(arg, Symbol.CONDITION));
69: }
70: };
71:
72: // ### simple-condition-format-arguments
73: private static final Primitive1 SIMPLE_CONDITION_FORMAT_ARGUMENTS = new Primitive1(
74: "simple-condition-format-arguments", "condition") {
75: public LispObject execute(LispObject arg)
76: throws ConditionThrowable {
77: if (arg instanceof Condition)
78: return ((Condition) arg).getFormatArguments();
79: return signal(new TypeError(arg, Symbol.CONDITION));
80: }
81: };
82: }
|