Revision 36624 trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/rendering/filter/parser/TokenMgrError.java

View differences:

TokenMgrError.java
1
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */

1
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
2 2
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
3 3
 *
4 4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
38 38
 *
39 39
 *   +34 963163400
40 40
 *   dac@iver.es
41
 */
42
package org.gvsig.symbology.fmap.rendering.filter.parser;
43

  
44
public class TokenMgrError extends Error
45
{
46
   /*
47
    * Ordinals for various reasons why an Error of this type can be thrown.
48
    */
49

  
50
   /**
51
    * Lexical error occurred.
52
    */
53
   static final int LEXICAL_ERROR = 0;
54

  
55
   /**
56
    * An attempt was made to create a second instance of a static token manager.
57
    */
58
   static final int STATIC_LEXER_ERROR = 1;
59

  
60
   /**
61
    * Tried to change to an invalid lexical state.
62
    */
63
   static final int INVALID_LEXICAL_STATE = 2;
64

  
65
   /**
66
    * Detected (and bailed out of) an infinite loop in the token manager.
67
    */
68
   static final int LOOP_DETECTED = 3;
69

  
70
   /**
71
    * Indicates the reason why the exception is thrown. It will have
72
    * one of the above 4 values.
73
    */
74
   int errorCode;
75

  
76
   /**
77
    * Replaces unprintable characters by their escaped (or unicode escaped)
78
    * equivalents in the given string
79
    */
80
   protected static final String addEscapes(String str) {
81
      StringBuffer retval = new StringBuffer();
82
      char ch;
83
      for (int i = 0; i < str.length(); i++) {
84
        switch (str.charAt(i))
85
        {
86
           case 0 :
87
              continue;
88
           case '\b':
89
              retval.append("\\b");
90
              continue;
91
           case '\t':
92
              retval.append("\\t");
93
              continue;
94
           case '\n':
95
              retval.append("\\n");
96
              continue;
97
           case '\f':
98
              retval.append("\\f");
99
              continue;
100
           case '\r':
101
              retval.append("\\r");
102
              continue;
103
           case '\"':
104
              retval.append("\\\"");
105
              continue;
106
           case '\'':
107
              retval.append("\\\'");
108
              continue;
109
           case '\\':
110
              retval.append("\\\\");
111
              continue;
112
           default:
113
              if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
114
                 String s = "0000" + Integer.toString(ch, 16);
115
                 retval.append("\\u" + s.substring(s.length() - 4, s.length()));
116
              } else {
117
                 retval.append(ch);
118
              }
119
              continue;
120
        }
121
      }
122
      return retval.toString();
123
   }
124

  
125
   /**
126
    * Returns a detailed message for the Error when it is thrown by the
127
    * token manager to indicate a lexical error.
128
    * Parameters : 
129
    *    EOFSeen     : indicates if EOF caused the lexical error
130
    *    curLexState : lexical state in which this error occurred
131
    *    errorLine   : line number when the error occurred
132
    *    errorColumn : column number when the error occurred
133
    *    errorAfter  : prefix that was seen before this error occurred
134
    *    curchar     : the offending character
135
    * Note: You can customize the lexical error message by modifying this method.
136
    */
137
   protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
138
      return("Lexical error at line " +
139
           errorLine + ", column " +
140
           errorColumn + ".  Encountered: " +
141
           (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
142
           "after : \"" + addEscapes(errorAfter) + "\"");
143
   }
144

  
145
   /**
146
    * You can also modify the body of this method to customize your error messages.
147
    * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
148
    * of end-users concern, so you can return something like : 
149
    *
150
    *     "Internal Error : Please file a bug report .... "
151
    *
152
    * from this method for such cases in the release version of your parser.
153
    */
154
   public String getMessage() {
155
      return super.getMessage();
156
   }
157

  
158
   /*
159
    * Constructors of various flavors follow.
160
    */
161

  
162
   public TokenMgrError() {
163
   }
164

  
165
   public TokenMgrError(String message, int reason) {
166
      super(message);
167
      errorCode = reason;
168
   }
169

  
170
   public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
171
      this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
172
   }
173
}
41
 */
42
package org.gvsig.symbology.fmap.rendering.filter.parser;
43

  
44
public class TokenMgrError extends Error
45
{
46
   /*
47
    * Ordinals for various reasons why an Error of this type can be thrown.
48
    */
49

  
50
   /**
51
    * Lexical error occurred.
52
    */
53
   static final int LEXICAL_ERROR = 0;
54

  
55
   /**
56
    * An attempt was made to create a second instance of a static token manager.
57
    */
58
   static final int STATIC_LEXER_ERROR = 1;
59

  
60
   /**
61
    * Tried to change to an invalid lexical state.
62
    */
63
   static final int INVALID_LEXICAL_STATE = 2;
64

  
65
   /**
66
    * Detected (and bailed out of) an infinite loop in the token manager.
67
    */
68
   static final int LOOP_DETECTED = 3;
69

  
70
   /**
71
    * Indicates the reason why the exception is thrown. It will have
72
    * one of the above 4 values.
73
    */
74
   int errorCode;
75

  
76
   /**
77
    * Replaces unprintable characters by their escaped (or unicode escaped)
78
    * equivalents in the given string
79
    */
80
   protected static final String addEscapes(String str) {
81
      StringBuffer retval = new StringBuffer();
82
      char ch;
83
      for (int i = 0; i < str.length(); i++) {
84
        switch (str.charAt(i))
85
        {
86
           case 0 :
87
              continue;
88
           case '\b':
89
              retval.append("\\b");
90
              continue;
91
           case '\t':
92
              retval.append("\\t");
93
              continue;
94
           case '\n':
95
              retval.append("\\n");
96
              continue;
97
           case '\f':
98
              retval.append("\\f");
99
              continue;
100
           case '\r':
101
              retval.append("\\r");
102
              continue;
103
           case '\"':
104
              retval.append("\\\"");
105
              continue;
106
           case '\'':
107
              retval.append("\\\'");
108
              continue;
109
           case '\\':
110
              retval.append("\\\\");
111
              continue;
112
           default:
113
              if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
114
                 String s = "0000" + Integer.toString(ch, 16);
115
                 retval.append("\\u" + s.substring(s.length() - 4, s.length()));
116
              } else {
117
                 retval.append(ch);
118
              }
119
              continue;
120
        }
121
      }
122
      return retval.toString();
123
   }
124

  
125
   /**
126
    * Returns a detailed message for the Error when it is thrown by the
127
    * token manager to indicate a lexical error.
128
    * Parameters : 
129
    *    EOFSeen     : indicates if EOF caused the lexical error
130
    *    curLexState : lexical state in which this error occurred
131
    *    errorLine   : line number when the error occurred
132
    *    errorColumn : column number when the error occurred
133
    *    errorAfter  : prefix that was seen before this error occurred
134
    *    curchar     : the offending character
135
    * Note: You can customize the lexical error message by modifying this method.
136
    */
137
   protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
138
      return("Lexical error at line " +
139
           errorLine + ", column " +
140
           errorColumn + ".  Encountered: " +
141
           (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
142
           "after : \"" + addEscapes(errorAfter) + "\"");
143
   }
144

  
145
   /**
146
    * You can also modify the body of this method to customize your error messages.
147
    * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
148
    * of end-users concern, so you can return something like : 
149
    *
150
    *     "Internal Error : Please file a bug report .... "
151
    *
152
    * from this method for such cases in the release version of your parser.
153
    */
154
   public String getMessage() {
155
      return super.getMessage();
156
   }
157

  
158
   /*
159
    * Constructors of various flavors follow.
160
    */
161

  
162
   public TokenMgrError() {
163
   }
164

  
165
   public TokenMgrError(String message, int reason) {
166
      super(message);
167
      errorCode = reason;
168
   }
169

  
170
   public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
171
      this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
172
   }
173
}

Also available in: Unified diff