1 23 package com.tc.jrexx.regex; 24 25 public class InvalidExpression extends RuntimeException { 26 27 private String expression; 28 private String illegalToken; 29 private int tokenPosition = -1; 30 31 private static String makeMessage(String expression, String illegalToken, int tokenPosition) { 32 try { 33 String message = "Token \"" + illegalToken + "\" not allowed at this position: "; 34 message+= expression.substring( 0,tokenPosition ); 35 message+= "\u0010" + illegalToken + "\u0011"; 36 message+= expression.substring( tokenPosition+illegalToken.length() ); 37 return message; 38 } catch ( Exception e) { 39 System.out.println( e); 40 System.out.println( "EXPRESSION="+expression+" TOKENPOS="+tokenPosition+ " ILLEGALTOKEN="+illegalToken); 41 } 42 throw new RuntimeException (); 43 } 44 45 InvalidExpression() {}; 46 47 public InvalidExpression(String message) {super(message);} 48 49 public InvalidExpression(String expression,String illegalToken,int tokenPosition) { 50 super (InvalidExpression.makeMessage(expression,illegalToken,tokenPosition)); 51 this.expression = expression; 52 this.illegalToken = illegalToken; 53 this.tokenPosition = tokenPosition; 54 } 55 56 public String getExpression() { 57 return this.expression; 58 } 59 60 public String getIllegalToken() { 61 return this.illegalToken; 62 } 63 64 public int getIllegalTokenPosition() { 65 return this.tokenPosition; 66 } 67 68 } | Popular Tags |