1 7 8 9 package com.sun.jmx.snmp.IPAcl; 10 11 class TokenMgrError extends Error 12 { 13 16 17 20 static final int LEXICAL_ERROR = 0; 21 22 25 static final int STATIC_LEXER_ERROR = 1; 26 27 30 static final int INVALID_LEXICAL_STATE = 2; 31 32 35 static final int LOOP_DETECTED = 3; 36 37 41 int errorCode; 42 43 47 protected static final String addEscapes(String str) { 48 StringBuffer retval = new StringBuffer (); 49 char ch; 50 for (int i = 0; i < str.length(); i++) { 51 switch (str.charAt(i)) 52 { 53 case 0 : 54 continue; 55 case '\b': 56 retval.append("\\b"); 57 continue; 58 case '\t': 59 retval.append("\\t"); 60 continue; 61 case '\n': 62 retval.append("\\n"); 63 continue; 64 case '\f': 65 retval.append("\\f"); 66 continue; 67 case '\r': 68 retval.append("\\r"); 69 continue; 70 case '\"': 71 retval.append("\\\""); 72 continue; 73 case '\'': 74 retval.append("\\\'"); 75 continue; 76 case '\\': 77 retval.append("\\\\"); 78 continue; 79 default: 80 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 81 String s = "0000" + Integer.toString(ch, 16); 82 retval.append("\\u" + s.substring(s.length() - 4, s.length())); 83 } else { 84 retval.append(ch); 85 } 86 continue; 87 } 88 } 89 return retval.toString(); 90 } 91 92 104 private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { 105 return("Lexical error at line " + 106 errorLine + ", column " + 107 errorColumn + ". Encountered: " + 108 (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + 109 "after : \"" + addEscapes(errorAfter) + "\""); 110 } 111 112 121 public String getMessage() { 122 return super.getMessage(); 123 } 124 125 128 129 public TokenMgrError() { 130 } 131 132 public TokenMgrError(String message, int reason) { 133 super(message); 134 errorCode = reason; 135 } 136 137 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { 138 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 139 } 140 } 141 | Popular Tags |