1 2 package com.genimen.djeneric.repository.sqlparser.core; 3 4 public class TokenMgrError extends Error 5 { 6 private static final long serialVersionUID = 1L; 7 8 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 38 42 protected static final String addEscapes(String str) 43 { 44 StringBuffer retval = new StringBuffer (); 45 char ch; 46 for (int i = 0; i < str.length(); i++) 47 { 48 switch (str.charAt(i)) 49 { 50 case 0 : 51 continue; 52 case '\b' : 53 retval.append("\\b"); 54 continue; 55 case '\t' : 56 retval.append("\\t"); 57 continue; 58 case '\n' : 59 retval.append("\\n"); 60 continue; 61 case '\f' : 62 retval.append("\\f"); 63 continue; 64 case '\r' : 65 retval.append("\\r"); 66 continue; 67 case '\"' : 68 retval.append("\\\""); 69 continue; 70 case '\'' : 71 retval.append("\\\'"); 72 continue; 73 case '\\' : 74 retval.append("\\\\"); 75 continue; 76 default : 77 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) 78 { 79 String s = "0000" + Integer.toString(ch, 16); 80 retval.append("\\u" + s.substring(s.length() - 4, s.length())); 81 } 82 else 83 { 84 retval.append(ch); 85 } 86 continue; 87 } 88 } 89 return retval.toString(); 90 } 91 92 104 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, 105 String errorAfter, char curChar) 106 { 107 return ("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " 108 + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") 109 + "after : \"" + addEscapes(errorAfter) + "\""); 110 } 111 112 121 public String getMessage() 122 { 123 return super.getMessage(); 124 } 125 126 129 130 public TokenMgrError() 131 { 132 } 133 134 public TokenMgrError(String message, int reason) 135 { 136 super(message); 137 errorCode = reason; 138 } 139 140 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, 141 int reason) 142 { 143 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 144 } 145 } | Popular Tags |