1 7 8 package org.gjt.jclasslib.bytecode; 9 10 import org.gjt.jclasslib.io.ByteCodeInput; 11 import org.gjt.jclasslib.io.ByteCodeOutput; 12 13 import java.io.IOException ; 14 15 21 public class TableSwitchInstruction extends PaddedInstruction { 22 23 private int defaultOffset; 24 private int lowByte; 25 private int highByte; 26 private int[] jumpOffsets; 27 28 32 public TableSwitchInstruction(int opcode) { 33 super(opcode); 34 } 35 36 public int getSize() { 37 return super.getSize() + 12 + 4 * jumpOffsets.length; 38 } 39 40 44 public int getDefaultOffset() { 45 return defaultOffset; 46 } 47 48 52 public void setDefaultOffset(int defaultOffset) { 53 this.defaultOffset = defaultOffset; 54 } 55 56 60 public int getLowByte() { 61 return lowByte; 62 } 63 64 68 public void setLowByte(int lowByte) { 69 this.lowByte = lowByte; 70 } 71 72 76 public int getHighByte() { 77 return highByte; 78 } 79 80 84 public void setHighByte(int highByte) { 85 this.highByte = highByte; 86 } 87 88 92 public int[] getJumpOffsets() { 93 return jumpOffsets; 94 } 95 96 100 public void setJumpOffsets(int[] jumpOffsets) { 101 this.jumpOffsets = jumpOffsets; 102 } 103 104 public void read(ByteCodeInput in) throws IOException { 105 super.read(in); 106 107 defaultOffset = in.readInt(); 108 lowByte = in.readInt(); 109 highByte = in.readInt(); 110 111 int numberOfOffsets = highByte - lowByte + 1; 112 jumpOffsets = new int[numberOfOffsets]; 113 114 for (int i = 0; i < numberOfOffsets; i++) { 115 jumpOffsets[i] = in.readInt(); 116 } 117 118 } 119 120 public void write(ByteCodeOutput out) throws IOException { 121 super.write(out); 122 123 out.writeInt(defaultOffset); 124 out.writeInt(lowByte); 125 out.writeInt(highByte); 126 127 int numberOfOffsets = jumpOffsets.length; 128 129 for (int i = 0; i < numberOfOffsets; i++) { 130 out.writeInt(jumpOffsets[i]); 131 } 132 } 133 134 } 135 | Popular Tags |