1 2 12 13 package com.versant.core.ejb.query; 14 15 public class TokenMgrError extends Error 16 { 17 20 21 24 static final int LEXICAL_ERROR = 0; 25 26 29 static final int STATIC_LEXER_ERROR = 1; 30 31 34 static final int INVALID_LEXICAL_STATE = 2; 35 36 39 static final int LOOP_DETECTED = 3; 40 41 45 int errorCode; 46 47 51 protected static final String addEscapes(String str) { 52 StringBuffer retval = new StringBuffer (); 53 char ch; 54 for (int i = 0; i < str.length(); i++) { 55 switch (str.charAt(i)) 56 { 57 case 0 : 58 continue; 59 case '\b': 60 retval.append("\\b"); 61 continue; 62 case '\t': 63 retval.append("\\t"); 64 continue; 65 case '\n': 66 retval.append("\\n"); 67 continue; 68 case '\f': 69 retval.append("\\f"); 70 continue; 71 case '\r': 72 retval.append("\\r"); 73 continue; 74 case '\"': 75 retval.append("\\\""); 76 continue; 77 case '\'': 78 retval.append("\\\'"); 79 continue; 80 case '\\': 81 retval.append("\\\\"); 82 continue; 83 default: 84 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 85 String s = "0000" + Integer.toString(ch, 16); 86 retval.append("\\u" + s.substring(s.length() - 4, s.length())); 87 } else { 88 retval.append(ch); 89 } 90 continue; 91 } 92 } 93 return retval.toString(); 94 } 95 96 108 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { 109 return("Lexical error at line " + 110 errorLine + ", column " + 111 errorColumn + ". Encountered: " + 112 (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + 113 "after : \"" + addEscapes(errorAfter) + "\""); 114 } 115 116 125 public String getMessage() { 126 return super.getMessage(); 127 } 128 129 132 133 public TokenMgrError() { 134 } 135 136 public TokenMgrError(String message, int reason) { 137 super(message); 138 errorCode = reason; 139 } 140 141 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { 142 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 143 } 144 } 145 | Popular Tags |