00001 package de.fub.bytecode.generic;
00002
00003 import de.fub.bytecode.Constants;
00004
00005
00006
00007
00008
00009
00010
00011 public final class BasicType extends Type {
00012
00013
00014
00015
00016
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
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 }