01: package org.codehaus.groovy.syntax;
02:
03: public class TokenException extends SyntaxException {
04: private Token token;
05:
06: public TokenException(String message, Token token) {
07: super ((token == null) ? message + ". No token" : message,
08: getLine(token), getColumn(token));
09: }
10:
11: public TokenException(String message, Throwable cause, int line,
12: int column) {
13: super (message, cause, line, column);
14: }
15:
16: public int getEndColumn() {
17: int length = 1;
18: if (token != null) {
19: length = token.getText().length();
20: }
21: return getStartColumn() + length;
22: }
23:
24: // Implementation methods
25: // ----------------------------------------------------------------------
26: private static int getColumn(Token token) {
27: return (token != null) ? token.getStartColumn() : -1;
28: }
29:
30: private static int getLine(Token token) {
31: return (token != null) ? token.getStartLine() : -1;
32: }
33:
34: }
|