author | mkos |
Sun, 30 Dec 2012 00:00:00 +0100 | |
changeset 22678 | ac1ea46be942 |
parent 12009 | 4abb694f273a |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
22678
ac1ea46be942
8029237: Update copyright year to match last edit in jaxws repository for 2012
mkos
parents:
12009
diff
changeset
|
2 |
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
/* |
|
26 |
* Copyright (C) 2004-2011 |
|
27 |
* |
|
28 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
29 |
* of this software and associated documentation files (the "Software"), to deal |
|
30 |
* in the Software without restriction, including without limitation the rights |
|
31 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
32 |
* copies of the Software, and to permit persons to whom the Software is |
|
33 |
* furnished to do so, subject to the following conditions: |
|
34 |
* |
|
35 |
* The above copyright notice and this permission notice shall be included in |
|
36 |
* all copies or substantial portions of the Software. |
|
37 |
* |
|
38 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
39 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
40 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
41 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
42 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
43 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
44 |
* THE SOFTWARE. |
|
45 |
*/ |
|
46 |
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ |
|
47 |
/* JavaCCOptions: */ |
|
48 |
package com.sun.xml.internal.rngom.parse.compact; |
|
49 |
||
50 |
/** Token Manager Error. */ |
|
51 |
public class TokenMgrError extends Error |
|
52 |
{ |
|
53 |
||
54 |
/** |
|
55 |
* The version identifier for this Serializable class. |
|
56 |
* Increment only if the <i>serialized</i> form of the |
|
57 |
* class changes. |
|
58 |
*/ |
|
59 |
private static final long serialVersionUID = 1L; |
|
60 |
||
61 |
/* |
|
62 |
* Ordinals for various reasons why an Error of this type can be thrown. |
|
63 |
*/ |
|
64 |
||
65 |
/** |
|
66 |
* Lexical error occurred. |
|
67 |
*/ |
|
68 |
static final int LEXICAL_ERROR = 0; |
|
69 |
||
70 |
/** |
|
71 |
* An attempt was made to create a second instance of a static token manager. |
|
72 |
*/ |
|
73 |
static final int STATIC_LEXER_ERROR = 1; |
|
74 |
||
75 |
/** |
|
76 |
* Tried to change to an invalid lexical state. |
|
77 |
*/ |
|
78 |
static final int INVALID_LEXICAL_STATE = 2; |
|
79 |
||
80 |
/** |
|
81 |
* Detected (and bailed out of) an infinite loop in the token manager. |
|
82 |
*/ |
|
83 |
static final int LOOP_DETECTED = 3; |
|
84 |
||
85 |
/** |
|
86 |
* Indicates the reason why the exception is thrown. It will have |
|
87 |
* one of the above 4 values. |
|
88 |
*/ |
|
89 |
int errorCode; |
|
90 |
||
91 |
/** |
|
92 |
* Replaces unprintable characters by their escaped (or unicode escaped) |
|
93 |
* equivalents in the given string |
|
94 |
*/ |
|
95 |
protected static final String addEscapes(String str) { |
|
96 |
StringBuffer retval = new StringBuffer(); |
|
97 |
char ch; |
|
98 |
for (int i = 0; i < str.length(); i++) { |
|
99 |
switch (str.charAt(i)) |
|
100 |
{ |
|
101 |
case 0 : |
|
102 |
continue; |
|
103 |
case '\b': |
|
104 |
retval.append("\\b"); |
|
105 |
continue; |
|
106 |
case '\t': |
|
107 |
retval.append("\\t"); |
|
108 |
continue; |
|
109 |
case '\n': |
|
110 |
retval.append("\\n"); |
|
111 |
continue; |
|
112 |
case '\f': |
|
113 |
retval.append("\\f"); |
|
114 |
continue; |
|
115 |
case '\r': |
|
116 |
retval.append("\\r"); |
|
117 |
continue; |
|
118 |
case '\"': |
|
119 |
retval.append("\\\""); |
|
120 |
continue; |
|
121 |
case '\'': |
|
122 |
retval.append("\\\'"); |
|
123 |
continue; |
|
124 |
case '\\': |
|
125 |
retval.append("\\\\"); |
|
126 |
continue; |
|
127 |
default: |
|
128 |
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { |
|
129 |
String s = "0000" + Integer.toString(ch, 16); |
|
130 |
retval.append("\\u" + s.substring(s.length() - 4, s.length())); |
|
131 |
} else { |
|
132 |
retval.append(ch); |
|
133 |
} |
|
134 |
continue; |
|
135 |
} |
|
136 |
} |
|
137 |
return retval.toString(); |
|
138 |
} |
|
139 |
||
140 |
/** |
|
141 |
* Returns a detailed message for the Error when it is thrown by the |
|
142 |
* token manager to indicate a lexical error. |
|
143 |
* Parameters : |
|
144 |
* EOFSeen : indicates if EOF caused the lexical error |
|
145 |
* curLexState : lexical state in which this error occurred |
|
146 |
* errorLine : line number when the error occurred |
|
147 |
* errorColumn : column number when the error occurred |
|
148 |
* errorAfter : prefix that was seen before this error occurred |
|
149 |
* curchar : the offending character |
|
150 |
* Note: You can customize the lexical error message by modifying this method. |
|
151 |
*/ |
|
152 |
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { |
|
153 |
return("Lexical error at line " + |
|
154 |
errorLine + ", column " + |
|
155 |
errorColumn + ". Encountered: " + |
|
156 |
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + |
|
157 |
"after : \"" + addEscapes(errorAfter) + "\""); |
|
158 |
} |
|
159 |
||
160 |
/** |
|
161 |
* You can also modify the body of this method to customize your error messages. |
|
162 |
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not |
|
163 |
* of end-users concern, so you can return something like : |
|
164 |
* |
|
165 |
* "Internal Error : Please file a bug report .... " |
|
166 |
* |
|
167 |
* from this method for such cases in the release version of your parser. |
|
168 |
*/ |
|
169 |
public String getMessage() { |
|
170 |
return super.getMessage(); |
|
171 |
} |
|
172 |
||
173 |
/* |
|
174 |
* Constructors of various flavors follow. |
|
175 |
*/ |
|
176 |
||
177 |
/** No arg constructor. */ |
|
178 |
public TokenMgrError() { |
|
179 |
} |
|
180 |
||
181 |
/** Constructor with message and reason. */ |
|
182 |
public TokenMgrError(String message, int reason) { |
|
183 |
super(message); |
|
184 |
errorCode = reason; |
|
185 |
} |
|
186 |
||
187 |
/** Full Constructor. */ |
|
188 |
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { |
|
189 |
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); |
|
190 |
} |
|
191 |
} |
|
192 |
/* JavaCC - OriginalChecksum=1d6588bf7a27100c05b06541f6175759 (do not edit this line) */ |