KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > compiler > typesystem > type > PrimitiveType


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.compiler.typesystem.type;
19
20 public interface PrimitiveType
21         extends TypeInstance
22 {
23     Kind getKind();
24     
25     public class Kind
26     {
27         public static final int INT_BOOLEAN = 0;
28         public static final int INT_BYTE = 1;
29         public static final int INT_SHORT = 2;
30         public static final int INT_INT = 3;
31         public static final int INT_LONG = 4;
32         public static final int INT_CHAR = 5;
33         public static final int INT_FLOAT = 6;
34         public static final int INT_DOUBLE = 7;
35         
36         public static final Kind BOOLEAN = new Kind( INT_BOOLEAN );
37         public static final Kind BYTE = new Kind( INT_BYTE );
38         public static final Kind SHORT = new Kind( INT_SHORT );
39         public static final Kind INT = new Kind( INT_INT );
40         public static final Kind LONG = new Kind( INT_LONG );
41         public static final Kind CHAR = new Kind( INT_CHAR );
42         public static final Kind FLOAT = new Kind( INT_FLOAT );
43         public static final Kind DOUBLE = new Kind( INT_DOUBLE );
44         
45         private int _val;
46         
47         private Kind( int val )
48         {
49             _val = val;
50         }
51         
52         public String JavaDoc toString()
53         {
54             switch ( _val )
55             {
56                 case INT_BOOLEAN: return "boolean";
57                 case INT_BYTE: return "byte";
58                 case INT_SHORT: return "short";
59                 case INT_INT: return "int";
60                 case INT_LONG: return "long";
61                 case INT_CHAR: return "char";
62                 case INT_FLOAT: return "float";
63                 case INT_DOUBLE: return "double";
64             }
65             
66             assert false : _val;
67             return "<unknown Kind>";
68         }
69         
70         public boolean equals( Object JavaDoc o )
71         {
72             if ( o == null ) return false;
73             if ( o == this ) return true;
74             if ( ! ( o instanceof Kind ) ) return false;
75             return ( ( Kind ) o )._val == _val;
76         }
77         
78         public final int asInt()
79         {
80             return _val;
81         }
82         
83         public final int hashCode()
84         {
85             return _val;
86         }
87         
88         protected Kind()
89         {
90             _val = -1;
91         }
92         
93         protected void setVal( int val )
94         {
95             _val = val;
96         }
97     }}
98
Popular Tags