| 1 9 package com.vladium.jcd.cls.constant; 10 11 import java.io.IOException ; 12 13 import com.vladium.jcd.compiler.IClassFormatOutput; 14 import com.vladium.jcd.lib.UDataInputStream; 15 import com.vladium.jcd.lib.UDataOutputStream; 16 17 24 public 25 abstract class CONSTANT_info implements Cloneable , IClassFormatOutput 26 { 27 29 30 34 public abstract byte tag (); 35 36 38 public abstract Object accept (ICONSTANTVisitor visitor, Object ctx); 39 40 public abstract String toString (); 41 42 51 public int width () 52 { 53 return 1; 54 } 55 56 57 60 public static CONSTANT_info new_CONSTANT_info (final UDataInputStream bytes) 61 throws IOException  62 { 63 byte tag = bytes.readByte (); 64 65 switch (tag) 66 { 67 case CONSTANT_Utf8_info.TAG: 68 return new CONSTANT_Utf8_info (bytes); 69 70 case CONSTANT_Integer_info.TAG: 71 return new CONSTANT_Integer_info (bytes); 72 73 case CONSTANT_Float_info.TAG: 74 return new CONSTANT_Float_info (bytes); 75 76 case CONSTANT_Long_info.TAG: 77 return new CONSTANT_Long_info (bytes); 78 79 case CONSTANT_Double_info.TAG: 80 return new CONSTANT_Double_info (bytes); 81 82 83 case CONSTANT_Class_info.TAG: 84 return new CONSTANT_Class_info (bytes); 85 86 case CONSTANT_String_info.TAG: 87 return new CONSTANT_String_info (bytes); 88 89 90 case CONSTANT_Fieldref_info.TAG: 91 return new CONSTANT_Fieldref_info (bytes); 92 93 case CONSTANT_Methodref_info.TAG: 94 return new CONSTANT_Methodref_info (bytes); 95 96 case CONSTANT_InterfaceMethodref_info.TAG: 97 return new CONSTANT_InterfaceMethodref_info (bytes); 98 99 100 case CONSTANT_NameAndType_info.TAG: 101 return new CONSTANT_NameAndType_info (bytes); 102 103 default: throw new IllegalStateException ("CONSTANT_info: invalid tag value [" + tag + ']'); 104 105 } } 107 108 110 114 public Object clone () 115 { 116 try 117 { 118 return super.clone (); 119 } 120 catch (CloneNotSupportedException e) 121 { 122 throw new InternalError (e.toString ()); 123 } 124 } 125 126 128 public void writeInClassFormat (final UDataOutputStream out) throws IOException  129 { 130 out.writeByte (tag ()); 131 } 132 133 public static String tagToString (final CONSTANT_info constant) 134 { 135 switch (constant.tag ()) 136 { 137 case CONSTANT_Utf8_info.TAG: 138 return "CONSTANT_Utf8"; 139 140 case CONSTANT_Integer_info.TAG: 141 return "CONSTANT_Integer"; 142 143 case CONSTANT_Float_info.TAG: 144 return "CONSTANT_Float"; 145 146 case CONSTANT_Long_info.TAG: 147 return "CONSTANT_Long"; 148 149 case CONSTANT_Double_info.TAG: 150 return "CONSTANT_Double"; 151 152 153 case CONSTANT_Class_info.TAG: 154 return "CONSTANT_Class"; 155 156 case CONSTANT_String_info.TAG: 157 return "CONSTANT_String"; 158 159 160 case CONSTANT_Fieldref_info.TAG: 161 return "CONSTANT_Fieldref"; 162 163 case CONSTANT_Methodref_info.TAG: 164 return "CONSTANT_Methodref"; 165 166 case CONSTANT_InterfaceMethodref_info.TAG: 167 return "CONSTANT_InterfaceMethodref"; 168 169 170 case CONSTANT_NameAndType_info.TAG: 171 return "CONSTANT_NameAndType"; 172 173 default: throw new IllegalStateException ("CONSTANT_info: invalid tag value [" + constant.tag () + ']'); 174 175 } } 177 178 180 193 194 protected CONSTANT_info () 195 { 196 } 197 198 200 202 } | Popular Tags |