View Javadoc

    1   package org.codehaus.groovy.syntax;
    2
    3
    4   public class TokenException extends SyntaxException {
    5       private Token token;
    6
    7       public TokenException(String message, Token token) {
    8           super(
    9               (token == null)
    10                  ? message + ". No token"
    11                  : message,
    12              getLine(token),
    13              getColumn(token));
    14      }
    15
    16      public TokenException(String message, Throwable cause, int line, int column) {
    17          super(message, cause, line, column);
    18      }
    19
    20      public int getEndColumn() {
    21          int length = 1;
    22          if (token != null) {
    23              length = token.getText().length();
    24          }
    25          return getStartColumn() + length;
    26      }
    27
    28
    29      // Implementation methods
    30      // ----------------------------------------------------------------------
    31      private static int getColumn(Token token) {
    32          return (token != null) ? token.getStartColumn() : -1;
    33      }
    34
    35      private static int getLine(Token token) {
    36          return (token != null) ? token.getStartLine() : -1;
    37      }
    38
    39  }