1 19 20 package gnu.regexp; 21 22 import java.text.MessageFormat ; 23 24 37 38 public class REException extends Exception { 39 private int type; 40 private int pos; 41 42 44 49 public static final int REG_BADRPT = 1; 50 51 55 public static final int REG_BADBR = 2; 56 57 61 public static final int REG_EBRACE = 3; 62 63 67 public static final int REG_EBRACK = 4; 68 69 75 public static final int REG_ERANGE = 5; 76 77 81 public static final int REG_ECTYPE = 6; 82 83 87 public static final int REG_EPAREN = 7; 88 89 93 public static final int REG_ESUBREG = 8; 94 95 99 public static final int REG_EEND = 9; 100 101 105 public static final int REG_ESCAPE = 10; 106 107 111 public static final int REG_BADPAT = 11; 112 113 118 public static final int REG_ESIZE = 12; 119 120 124 public static final int REG_ESPACE = 13; 125 126 REException(String msg, int type, int position) { 127 super(msg); 128 this.type = type; 129 this.pos = position; 130 } 131 132 135 136 public int getType() { 137 return type; 138 } 139 140 146 public int getPosition() { 147 return pos; 148 } 149 150 155 public String getMessage() { 156 Object [] args = {new Integer (pos)}; 157 StringBuffer sb = new StringBuffer (); 158 String prefix = RE.getLocalizedMessage("error.prefix"); 159 sb.append(MessageFormat.format(prefix, args)); 160 sb.append('\n'); 161 sb.append(super.getMessage()); 162 return sb.toString(); 163 } 164 } 165 | Popular Tags |