1 30 package org.objectweb.asm.tree; 31 32 import org.objectweb.asm.Label; 33 import org.objectweb.asm.Opcodes; 34 import org.objectweb.asm.MethodVisitor; 35 36 import java.util.List ; 37 import java.util.ArrayList ; 38 import java.util.Arrays ; 39 40 45 public class LookupSwitchInsnNode extends AbstractInsnNode { 46 47 50 public Label dflt; 51 52 55 public final List keys; 56 57 61 public final List labels; 62 63 71 public LookupSwitchInsnNode( 72 final Label dflt, 73 final int[] keys, 74 final Label[] labels) 75 { 76 super(Opcodes.LOOKUPSWITCH); 77 this.dflt = dflt; 78 this.keys = new ArrayList (keys == null ? 0 : keys.length); 79 this.labels = new ArrayList (labels == null ? 0 : labels.length); 80 if (keys != null) { 81 for (int i = 0; i < keys.length; ++i) { 82 this.keys.add(new Integer (keys[i])); 83 } 84 } 85 if (labels != null) { 86 this.labels.addAll(Arrays.asList(labels)); 87 } 88 } 89 90 public void accept(final MethodVisitor mv) { 91 int[] keys = new int[this.keys.size()]; 92 for (int i = 0; i < keys.length; ++i) { 93 keys[i] = ((Integer ) this.keys.get(i)).intValue(); 94 } 95 Label[] labels = new Label[this.labels.size()]; 96 this.labels.toArray(labels); 97 mv.visitLookupSwitchInsn(dflt, keys, labels); 98 } 99 100 public int getType() { 101 return LOOKUPSWITCH_INSN; 102 } 103 } 104 | Popular Tags |