1 package alt.jiapi.file; 2 3 import java.io.ByteArrayOutputStream ; 4 import java.io.DataInputStream ; 5 import java.io.DataOutputStream ; 6 import java.io.IOException ; 7 import java.util.List ; 8 import java.util.LinkedList ; 9 import java.util.Iterator ; 10 11 17 public class ExceptionsAttribute extends Attribute { 18 private short[] exceptionIndexTable; 19 20 ExceptionsAttribute(short nameIndex, DataInputStream dis) throws IOException { 21 super(nameIndex); 22 23 short exceptionCount = dis.readShort(); 24 exceptionIndexTable = new short[exceptionCount]; 25 for (int i = 0; i < exceptionCount; i++) { 26 exceptionIndexTable[i] = dis.readShort(); 27 } 28 } 29 30 short[] getExceptionIndexTable() { 31 return exceptionIndexTable; 32 } 33 34 public String [] getExceptionNames() { 35 String [] eNames = new String [exceptionIndexTable.length]; 36 for (int i = 0; i < eNames.length; i++) { 37 eNames[i] = cp.getClassName(exceptionIndexTable[i]).replace('/', '.'); 38 } 39 40 return eNames; 41 } 42 43 public byte[] getBytes() { 44 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 45 DataOutputStream dos = new DataOutputStream (baos); 46 47 try { 48 dos.writeShort(exceptionIndexTable.length); 49 50 for (int i = 0; i < exceptionIndexTable.length; i++) { 51 dos.writeShort(exceptionIndexTable[i]); 52 } 53 } 54 catch(IOException ioe) { 55 throw new RuntimeException (ioe); 57 } 58 59 return baos.toByteArray(); 60 } 61 } 62 63 | Popular Tags |