Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

BasicType.java

00001 package de.fub.bytecode.generic;
00002 
00003 import de.fub.bytecode.Constants;
00004 
00005 /** 
00006  * Denotes basic type such as int.
00007  *
00008  * @version $Id: BasicType.java,v 1.1.1.1 2002/01/24 03:41:38 pserver Exp $
00009  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00010  */
00011 public final class BasicType extends Type {
00012   /**
00013    * Constructor for basic types such as int, long, `void'
00014    *
00015    * @param type one of T_INT, T_BOOLEAN, ..., T_VOID
00016    * @see de.fub.bytecode.Constants
00017    */
00018   BasicType(byte type) {
00019     super(type, Constants.SHORT_TYPE_NAMES[type]);
00020 
00021     if((type < Constants.T_BOOLEAN) || (type > Constants.T_VOID))
00022       throw new ClassGenException("Invalid type: " + type);
00023   }  
00024   /** @return true if both type objects refer to the same type
00025    */
00026   public boolean equals(Object type) {
00027     return (type instanceof BasicType)?
00028       ((BasicType)type).type == this.type : false;
00029   }  
00030   public static final BasicType getType(byte type) {
00031     switch(type) {
00032     case Constants.T_VOID:    return VOID;
00033     case Constants.T_BOOLEAN: return BOOLEAN;
00034     case Constants.T_BYTE:    return BYTE;
00035     case Constants.T_SHORT:   return SHORT;
00036     case Constants.T_CHAR:    return CHAR;
00037     case Constants.T_INT:     return INT;
00038     case Constants.T_LONG:    return LONG;
00039     case Constants.T_DOUBLE:  return DOUBLE;
00040     case Constants.T_FLOAT:   return FLOAT;
00041 
00042     default:
00043       throw new ClassGenException("Invalid type: " + type);
00044     }
00045   }  
00046 }

Generated at Thu Feb 7 06:40:35 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001