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.UDataInputStream; 16 import com.vladium.jcd.lib.UDataOutputStream; 17 18 70 public 71 final class LineNumberTableAttribute_info extends Attribute_info 72 { 73 75 77 86 public LineNumber_info get (final int offset) 87 { 88 return (LineNumber_info) m_lines.get (offset); 89 } 90 91 94 public int size () 95 { 96 return m_lines.size (); 97 } 98 99 public long length () 100 { 101 return 8 + (m_lines.size () << 2); } 103 104 106 public void accept (final IAttributeVisitor visitor, final Object ctx) 107 { 108 visitor.visit (this, ctx); 109 } 110 111 public String toString () 112 { 113 final StringBuffer s = new StringBuffer ("LineNumberTableAttribute_info: [attribute_name_index = " + m_name_index + ", attribute_length = " + length () + "]\n"); 114 115 for (int l = 0; l < size (); ++ l) 116 { 117 s.append (" " + get (l)); 118 s.append ("\n"); } 120 121 return s.toString (); 122 } 123 124 126 129 public Object clone () 130 { 131 final LineNumberTableAttribute_info _clone = (LineNumberTableAttribute_info) super.clone (); 132 133 final int lines_count = m_lines.size (); _clone.m_lines = new ArrayList (lines_count); 136 for (int e = 0; e < lines_count; ++ e) 137 { 138 _clone.m_lines.add (((LineNumber_info) m_lines.get (e)).clone ()); 139 } 140 141 return _clone; 142 } 143 144 146 public void writeInClassFormat (final UDataOutputStream out) throws IOException 147 { 148 super.writeInClassFormat (out); 149 150 final int lines_count = m_lines.size (); out.writeU2 (lines_count); 152 153 for (int l = 0; l < lines_count; ++ l) 154 { 155 ((LineNumber_info) m_lines.get (l)).writeInClassFormat (out); 156 } 157 } 158 159 161 163 164 LineNumberTableAttribute_info (final int attribute_name_index, final long attribute_length, 165 final UDataInputStream bytes) 166 throws IOException 167 { 168 super (attribute_name_index, attribute_length); 169 170 final int lines_count = bytes.readU2 (); 171 m_lines = new ArrayList (lines_count); 172 173 for (int i = 0; i < lines_count; i++) 174 { 175 m_lines.add (new LineNumber_info (bytes)); 176 } 177 } 178 179 181 182 private List m_lines; 184 } | Popular Tags |