1 2 package org.apache.lucene.demo.html; 3 4 public class TokenMgrError extends Error 5 { 6 7 private static final long serialVersionUID = 1L; 8 9 12 13 16 static final int LEXICAL_ERROR = 0; 17 18 21 static final int STATIC_LEXER_ERROR = 1; 22 23 26 static final int INVALID_LEXICAL_STATE = 2; 27 28 31 static final int LOOP_DETECTED = 3; 32 33 37 int errorCode; 38 39 43 protected static final String addEscapes(String str) { 44 StringBuffer retval = new StringBuffer (); 45 char ch; 46 for (int i = 0; i < str.length(); i++) { 47 switch (str.charAt(i)) 48 { 49 case 0 : 50 continue; 51 case '\b': 52 retval.append("\\b"); continue; 54 case '\t': 55 retval.append("\\t"); continue; 57 case '\n': 58 retval.append("\\n"); continue; 60 case '\f': 61 retval.append("\\f"); continue; 63 case '\r': 64 retval.append("\\r"); continue; 66 case '\"': 67 retval.append("\\\""); continue; 69 case '\'': 70 retval.append("\\\'"); continue; 72 case '\\': 73 retval.append("\\\\"); continue; 75 default: 76 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 77 String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { 80 retval.append(ch); 81 } 82 continue; 83 } 84 } 85 return retval.toString(); 86 } 87 88 100 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { 101 return("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } 107 108 117 public String getMessage() { 118 return super.getMessage(); 119 } 120 121 124 125 public TokenMgrError() { 126 } 127 128 public TokenMgrError(String message, int reason) { 129 super(message); 130 errorCode = reason; 131 } 132 133 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { 134 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 135 } 136 } 137 | Popular Tags |