KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gcc > generator > JReturnType


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

19 package gcc.generator;
20
21 public class JReturnType
22 {
23     protected Class _type;
24     protected String _typeName;
25     protected boolean _isArray;
26
27     public JReturnType( Class type)
28     {
29         this( type, false );
30     }
31
32     public JReturnType( Class type, boolean isArray )
33     {
34         _type = type;
35         _typeName = type.getName();
36         _isArray = isArray;
37     }
38
39     public JReturnType( String typeName )
40     {
41         this( typeName, false );
42     }
43
44     public JReturnType( String typeName, boolean isArray )
45     {
46         _typeName = typeName;
47         _isArray = isArray;
48
49         try
50         {
51             _type = Class.forName(_typeName);
52         }
53         catch( Exception e )
54         {
55             // Ignore;
56
}
57     }
58
59     public void setType( Class type )
60     {
61         _type = type;
62         _typeName = type.getName();
63     }
64
65     public Class getType()
66     {
67         return _type;
68     }
69
70     public void setTypeName( String typeName )
71     {
72         _type = null;
73         _typeName = typeName;
74     }
75
76     public String getTypeName()
77     {
78         return _typeName;
79     }
80
81     public boolean isArray()
82     {
83         return _isArray;
84     }
85
86     public int hashCode()
87     {
88         return _type.hashCode();
89     }
90
91     public boolean equals( Object other )
92     {
93         boolean rc = false;
94
95         if (other == this)
96         {
97             rc = true;
98         }
99         else if (other instanceof gcc.generator.JReturnType)
100         {
101             gcc.generator.JReturnType jr = (gcc.generator.JReturnType)other;
102
103             rc = jr._typeName.equals(_typeName);
104         }
105
106         return rc;
107     }
108 }
109
Popular Tags