1 2 package org.alfresco.repo.search.impl.lucene; 3 4 public class TokenMgrError extends Error 5 { 6 9 10 13 static final int LEXICAL_ERROR = 0; 14 15 18 static final int STATIC_LEXER_ERROR = 1; 19 20 23 static final int INVALID_LEXICAL_STATE = 2; 24 25 28 static final int LOOP_DETECTED = 3; 29 30 34 int errorCode; 35 36 40 protected static final String addEscapes(String str) { 41 StringBuilder retval = new StringBuilder (str.length() + 8); 42 char ch; 43 for (int i = 0; i < str.length(); i++) { 44 switch (str.charAt(i)) 45 { 46 case 0 : 47 continue; 48 case '\b': 49 retval.append("\\b"); 50 continue; 51 case '\t': 52 retval.append("\\t"); 53 continue; 54 case '\n': 55 retval.append("\\n"); 56 continue; 57 case '\f': 58 retval.append("\\f"); 59 continue; 60 case '\r': 61 retval.append("\\r"); 62 continue; 63 case '\"': 64 retval.append("\\\""); 65 continue; 66 case '\'': 67 retval.append("\\\'"); 68 continue; 69 case '\\': 70 retval.append("\\\\"); 71 continue; 72 default: 73 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 74 String s = "0000" + Integer.toString(ch, 16); 75 retval.append("\\u" + s.substring(s.length() - 4, s.length())); 76 } else { 77 retval.append(ch); 78 } 79 continue; 80 } 81 } 82 return retval.toString(); 83 } 84 85 97 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { 98 return("Lexical error at line " + 99 errorLine + ", column " + 100 errorColumn + ". Encountered: " + 101 (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + 102 "after : \"" + addEscapes(errorAfter) + "\""); 103 } 104 105 114 public String getMessage() { 115 return super.getMessage(); 116 } 117 118 121 122 public TokenMgrError() { 123 } 124 125 public TokenMgrError(String message, int reason) { 126 super(message); 127 errorCode = reason; 128 } 129 130 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { 131 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 132 } 133 } 134 | Popular Tags |