KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > type > NullType


1 /* NullType Copyright (C) 1999-2002 Jochen Hoenicke.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; see the file COPYING. If not, write to
15  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: NullType.java,v 1.7.4.2 2002/05/28 17:34:22 hoenicke Exp $
18  */

19
20 package jode.type;
21 import jode.AssertError;
22
23 /**
24  * This class represents the NullType. The null type is special as it
25  * may only occur as top type in a range type. It represents the type
26  * of the null constant, which may be casted to any object. <br>
27  *
28  * Question: Should we replace tUObject = tRange(tObject, tNull) by tNull?
29  * Question2: if not, should null have type tNull?
30  *
31  * @author Jochen Hoenicke
32  */

33 public class NullType extends ReferenceType {
34     public NullType() {
35     super(TC_NULL);
36     }
37
38     public Type getSubType() {
39     return this;
40     }
41
42     public Type createRangeType(ReferenceType bottomType) {
43     return tRange(bottomType, this);
44     }
45
46     /**
47      * Returns the generalized type of this and type. We have two
48      * classes and multiple interfaces. The result should be the
49      * object that is the the super class of both objects and all
50      * interfaces, that one class or interface of each type
51      * implements.
52      */

53     public Type getGeneralizedType(Type type) {
54     if (type.typecode == TC_RANGE)
55         type = ((RangeType) type).getTop();
56     return type;
57     }
58
59     /**
60      * Returns the specialized type of this and type.
61      * We have two classes and multiple interfaces. The result
62      * should be the object that extends both objects
63      * and the union of all interfaces.
64      */

65     public Type getSpecializedType(Type type) {
66     if (type.typecode == TC_RANGE)
67         type = ((RangeType) type).getBottom();
68     return type;
69     }
70
71     public String JavaDoc toString() {
72     return "tNull";
73     }
74 }
75
Popular Tags