1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.commons.compress.harmony.unpack200.bytecode;
20
21 import java.io.DataOutputStream;
22 import java.io.IOException;
23
24
25
26
27 public class LineNumberTableAttribute extends BCIRenumberedAttribute {
28
29 private static CPUTF8 attributeName;
30
31 public static void setAttributeName(final CPUTF8 cpUTF8Value) {
32 attributeName = cpUTF8Value;
33 }
34
35 private final int lineNumberTableLength;
36 private final int[] startPcs;
37 private final int[] lineNumbers;
38
39 public LineNumberTableAttribute(final int lineNumberTableLength, final int[] startPcs, final int[] lineNumbers) {
40 super(attributeName);
41 this.lineNumberTableLength = lineNumberTableLength;
42 this.startPcs = startPcs;
43 this.lineNumbers = lineNumbers;
44 }
45
46 @Override
47 public boolean equals(final Object obj) {
48 return this == obj;
49 }
50
51 @Override
52 protected int getLength() {
53 return 2 + 4 * lineNumberTableLength;
54 }
55
56
57
58
59
60
61 @Override
62 protected ClassFileEntry[] getNestedClassFileEntries() {
63 return new ClassFileEntry[] { getAttributeName() };
64 }
65
66 @Override
67 protected int[] getStartPCs() {
68 return startPcs;
69 }
70
71
72
73
74
75
76 @Override
77 public String toString() {
78 return "LineNumberTable: " + lineNumberTableLength + " lines";
79 }
80
81 @Override
82 protected void writeBody(final DataOutputStream dos) throws IOException {
83 dos.writeShort(lineNumberTableLength);
84 for (int i = 0; i < lineNumberTableLength; i++) {
85 dos.writeShort(startPcs[i]);
86 dos.writeShort(lineNumbers[i]);
87 }
88 }
89 }