1 2 package com.genimen.djeneric.repository.oql.core; 3 4 public class TokenMgrError extends Error 5 { 6 9 10 private static final long serialVersionUID = 3688506584624215603L; 11 12 15 static final int LEXICAL_ERROR = 0; 16 17 20 static final int STATIC_LEXER_ERROR = 1; 21 22 25 static final int INVALID_LEXICAL_STATE = 2; 26 27 30 static final int LOOP_DETECTED = 3; 31 32 36 int errorCode; 37 public int line; 38 public int column; 39 40 44 protected static final String addEscapes(String str) 45 { 46 StringBuffer retval = new StringBuffer (); 47 char ch; 48 for (int i = 0; i < str.length(); i++) 49 { 50 switch (str.charAt(i)) 51 { 52 case 0 : 53 continue; 54 case '\b' : 55 retval.append("\\b"); 56 continue; 57 case '\t' : 58 retval.append("\\t"); 59 continue; 60 case '\n' : 61 retval.append("\\n"); 62 continue; 63 case '\f' : 64 retval.append("\\f"); 65 continue; 66 case '\r' : 67 retval.append("\\r"); 68 continue; 69 case '\"' : 70 retval.append("\\\""); 71 continue; 72 case '\'' : 73 retval.append("\\\'"); 74 continue; 75 case '\\' : 76 retval.append("\\\\"); 77 continue; 78 default : 79 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) 80 { 81 String s = "0000" + Integer.toString(ch, 16); 82 retval.append("\\u" + s.substring(s.length() - 4, s.length())); 83 } 84 else 85 { 86 retval.append(ch); 87 } 88 continue; 89 } 90 } 91 return retval.toString(); 92 } 93 94 106 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, 107 String errorAfter, char curChar) 108 { 109 return ("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " 110 + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") 111 + "after : \"" + addEscapes(errorAfter) + "\""); 112 } 113 114 123 public String getMessage() 124 { 125 return super.getMessage(); 126 } 127 128 131 132 public TokenMgrError() 133 { 134 } 135 136 public TokenMgrError(String message, int reason) 137 { 138 super(message); 139 errorCode = reason; 140 } 141 142 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, 143 int reason) 144 { 145 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 146 line = errorLine; 147 column = errorColumn; 148 } 149 } | Popular Tags |