1 32 package net.sf.retrotranslator.runtime.impl; 33 34 import java.util.regex.MatchResult ; 35 36 39 public class MatchResultImpl implements MatchResult { 40 41 private final boolean available; 42 private final int groupCount; 43 private final int[] starts; 44 private final int[] ends; 45 private final String [] groups; 46 47 public MatchResultImpl(boolean available, int groupCount, 48 int[] starts, int[] ends, String [] groups) { 49 this.available = available; 50 this.groupCount = groupCount; 51 this.starts = starts; 52 this.ends = ends; 53 this.groups = groups; 54 } 55 56 public int start() { 57 return start(0); 58 } 59 60 public int start(int group) { 61 if (!available) throw new IllegalStateException (); 62 return starts[group]; 63 } 64 65 public int end() { 66 return end(0); 67 } 68 69 public int end(int group) { 70 if (!available) throw new IllegalStateException (); 71 return ends[group]; 72 } 73 74 public String group() { 75 return group(0); 76 } 77 78 public String group(int group) { 79 if (!available) throw new IllegalStateException (); 80 return groups[group]; 81 } 82 83 public int groupCount() { 84 return groupCount; 85 } 86 87 } 88 | Popular Tags |