KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > util > TokenMgrError


1 /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
2 /*-----------------------------------------------------------------------------
3  * ConfigParser (DO NOT EDIT - MACHINE GENERATED)
4  * JavaCC-generated parser for processing a Multiserver
5  * standard configuration file.
6  *
7  * !! DO NOT EDIT !! DO NOT EDIT !! DO NOT EDIT !! DO NOT EDIT !!
8  *
9  * There. Now that I've gotten your attention...
10  *
11  * DO NOT EDIT THIS FILE. THIS IS NOT A SOURCE FILE.
12  * THIS IS A MACHINE GENERATED FILE -- EDIT 'ConfigParser.jj' INSTEAD.
13  *
14  *-----------------------------------------------------------------------------
15  *-----------------------------------------------------------------------------
16  */

17 package com.lutris.util;
18
19 public class TokenMgrError extends Error JavaDoc
20 {
21    /*
22     * Ordinals for various reasons why an Error of this type can be thrown.
23     */

24
25    /**
26     * Lexical error occured.
27     */

28    static final int LEXICAL_ERROR = 0;
29
30    /**
31     * An attempt wass made to create a second instance of a static token manager.
32     */

33    static final int STATIC_LEXER_ERROR = 1;
34
35    /**
36     * Tried to change to an invalid lexical state.
37     */

38    static final int INVALID_LEXICAL_STATE = 2;
39
40    /**
41     * Detected (and bailed out of) an infinite loop in the token manager.
42     */

43    static final int LOOP_DETECTED = 3;
44
45    /**
46     * Indicates the reason why the exception is thrown. It will have
47     * one of the above 4 values.
48     */

49    int errorCode;
50
51    /**
52     * Replaces unprintable characters by their espaced (or unicode escaped)
53     * equivalents in the given string
54     */

55    protected static final String JavaDoc addEscapes(String JavaDoc str) {
56       StringBuffer JavaDoc retval = new StringBuffer JavaDoc();
57       char ch;
58       for (int i = 0; i < str.length(); i++) {
59         switch (str.charAt(i))
60         {
61            case 0 :
62               continue;
63            case '\b':
64               retval.append("\\b");
65               continue;
66            case '\t':
67               retval.append("\\t");
68               continue;
69            case '\n':
70               retval.append("\\n");
71               continue;
72            case '\f':
73               retval.append("\\f");
74               continue;
75            case '\r':
76               retval.append("\\r");
77               continue;
78            case '\"':
79               retval.append("\\\"");
80               continue;
81            case '\'':
82               retval.append("\\\'");
83               continue;
84            case '\\':
85               retval.append("\\\\");
86               continue;
87            default:
88               if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
89                  String JavaDoc s = "0000" + Integer.toString(ch, 16);
90                  retval.append("\\u" + s.substring(s.length() - 4, s.length()));
91               } else {
92                  retval.append(ch);
93               }
94               continue;
95         }
96       }
97       return retval.toString();
98    }
99
100    /**
101     * Returns a detailed message for the Error when it is thrown by the
102     * token manager to indicate a lexical error.
103     * Parameters :
104     * EOFSeen : indicates if EOF caused the lexicl error
105     * curLexState : lexical state in which this error occured
106     * errorLine : line number when the error occured
107     * errorColumn : column number when the error occured
108     * errorAfter : prefix that was seen before this error occured
109     * curchar : the offending character
110     * Note: You can customize the lexical error message by modifying this method.
111     */

112    protected static String JavaDoc LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String JavaDoc errorAfter, char curChar) {
113       return("Lexical error at line " +
114            errorLine + ", column " +
115            errorColumn + ". Encountered: " +
116            (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
117            "after : \"" + addEscapes(errorAfter) + "\"");
118    }
119
120    /**
121     * You can also modify the body of this method to customize your error messages.
122     * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
123     * of end-users concern, so you can return something like :
124     *
125     * "Internal Error : Please file a bug report .... "
126     *
127     * from this method for such cases in the release version of your parser.
128     */

129    public String JavaDoc getMessage() {
130       return super.getMessage();
131    }
132
133    /*
134     * Constructors of various flavors follow.
135     */

136
137    public TokenMgrError() {
138    }
139
140    public TokenMgrError(String JavaDoc message, int reason) {
141       super(message);
142       errorCode = reason;
143    }
144
145    public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String JavaDoc errorAfter, char curChar, int reason) {
146       this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
147    }
148 }
149
Popular Tags