1 6 package de.uka.ipd.coverage.recording; 7 8 import org.apache.bcel.generic.NOP; 9 10 18 class BlockDelimiter extends NOP { 19 20 public final static int BLOCK_START = 0; 21 public final static int BLOCK_END = 4; 22 23 private int boundary; 24 private int position; 25 private int[] targets = new int[2]; 26 private int targetsMaxIndex = -1; 27 28 29 35 public BlockDelimiter(int boundary, int position) { 36 if (boundary != BLOCK_START && boundary != BLOCK_END) { 37 throw new IllegalArgumentException ( 38 "Boundary must be one of BLOCK_START or BLOCK_END"); } 40 this.boundary = boundary; 41 this.position = position; 42 } 43 44 47 public boolean isEndBlock() { 48 return boundary == BLOCK_END; 49 } 50 51 54 public boolean isStartBlock() { 55 return boundary == BLOCK_START; 56 } 57 58 61 public int getPosition() { 62 return position; 63 } 64 65 public void addTarget(int targetPosition) { 66 67 for (int i = 0; i <= targetsMaxIndex; i++) 68 if (targets[i] == targetPosition) return; 69 70 targetsMaxIndex++; 71 if (targetsMaxIndex >= targets.length) { 72 int[] newTargets = new int[targetsMaxIndex * 4]; 73 System.arraycopy(targets, 0, newTargets, 0, targets.length); 74 targets = newTargets; 75 } 76 targets[targetsMaxIndex] = targetPosition; 77 } 78 79 public int[] getTargets() { 80 if (targetsMaxIndex < targets.length) { 81 int[] newTargets = new int[targetsMaxIndex + 1]; 82 System.arraycopy(targets, 0, newTargets, 0, newTargets.length); 83 return newTargets; 84 } 85 return targets; 86 } 87 } 88 | Popular Tags |