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, // + " at line: " + token.getStartLine() + " column: " + token.getStartColumn(),
    12              getLine(token),
    13              getColumn(token));
    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  }