1 9 package com.vladium.jcd.cls.attribute; 10 11 import java.io.IOException ; 12 import java.util.ArrayList ; 13 import java.util.List ; 14 15 import com.vladium.jcd.lib.UDataOutputStream; 16 17 21 final class ExceptionHandlerTable implements IExceptionHandlerTable 22 { 23 25 27 public Exception_info get (final int offset) 28 { 29 return (Exception_info) m_exceptions.get (offset); 30 } 31 32 public int size () 33 { 34 return m_exceptions.size (); 35 } 36 37 public long length () 38 { 39 return 2 + (m_exceptions.size () << 3); } 41 42 44 47 public Object clone () 48 { 49 try 50 { 51 final ExceptionHandlerTable _clone = (ExceptionHandlerTable) super.clone (); 52 53 final int exceptions_count = m_exceptions.size (); _clone.m_exceptions = new ArrayList (exceptions_count); 56 for (int e = 0; e < exceptions_count; ++ e) 57 { 58 _clone.m_exceptions.add (((Exception_info) m_exceptions.get (e)).clone ()); 59 } 60 61 return _clone; 62 } 63 catch (CloneNotSupportedException e) 64 { 65 throw new InternalError (e.toString ()); 66 } 67 } 68 69 71 public void writeInClassFormat (final UDataOutputStream out) throws IOException 72 { 73 int exception_table_length = m_exceptions.size (); out.writeU2 (exception_table_length); 75 76 for (int i = 0; i < exception_table_length; i++) 77 { 78 get (i).writeInClassFormat (out); 79 } 80 } 81 82 83 85 public int add (final Exception_info exception) 86 { 87 final int newoffset = m_exceptions.size (); m_exceptions.add (exception); 89 90 return newoffset; 91 } 92 93 public Exception_info set (final int offset, final Exception_info exception) 94 { 95 return (Exception_info) m_exceptions.set (offset, exception); 96 } 97 98 100 102 103 ExceptionHandlerTable (final int capacity) 104 { 105 m_exceptions = capacity < 0 ? new ArrayList () : new ArrayList (capacity); 106 } 107 108 110 111 private List m_exceptions; 112 113 } | Popular Tags |