1 9 package com.vladium.jcd.cls.attribute; 10 11 import java.io.IOException ; 12 13 import com.vladium.jcd.lib.UDataOutputStream; 14 import com.vladium.util.IntVector; 15 16 20 final class DeclaredExceptionTable implements IDeclaredExceptionTable 21 { 22 24 26 public int get (final int offset) 27 { 28 return m_exceptions.get (offset); 29 } 30 31 public int size () 32 { 33 return m_exceptions.size (); 34 } 35 36 public long length () 37 { 38 return (1 + m_exceptions.size ()) << 1; } 40 41 43 46 public Object clone () 47 { 48 try 49 { 50 final DeclaredExceptionTable _clone = (DeclaredExceptionTable) super.clone (); 51 52 _clone.m_exceptions = (IntVector) m_exceptions.clone (); 54 55 return _clone; 56 } 57 catch (CloneNotSupportedException e) 58 { 59 throw new InternalError (e.toString ()); 60 } 61 } 62 63 65 public void writeInClassFormat (final UDataOutputStream out) throws IOException 66 { 67 int number_of_exceptions = m_exceptions.size (); out.writeU2 (number_of_exceptions); 69 70 for (int i = 0; i < number_of_exceptions; i++) 71 { 72 out.writeU2 (get (i)); 73 } 74 } 75 76 77 79 public int add (final int exception_index) 80 { 81 final int newoffset = m_exceptions.size (); m_exceptions.add (exception_index); 83 84 return newoffset; 85 } 86 87 public int set (final int offset, final int exception_index) 88 { 89 return m_exceptions.set (offset, exception_index); 90 } 91 92 94 96 97 DeclaredExceptionTable (final int capacity) 98 { 99 m_exceptions = capacity < 0 ? new IntVector () : new IntVector (capacity); 100 } 101 102 104 105 private IntVector m_exceptions; 106 107 } | Popular Tags |