| 1 | |
package org.webslinger.javacc.support; |
| 2 | |
|
| 3 | |
public class LocatedException extends GenericParseException { |
| 4 | |
protected final String location; |
| 5 | |
protected final int line; |
| 6 | |
protected final int column; |
| 7 | |
protected final boolean at; |
| 8 | |
|
| 9 | |
public LocatedException(String location, String message, int line, int column) { |
| 10 | 0 | this(location, message, line, column, true); |
| 11 | 0 | } |
| 12 | |
|
| 13 | |
public LocatedException(String location, String message, int line, int column, boolean at) { |
| 14 | 0 | super(message); |
| 15 | 0 | this.location = location; |
| 16 | 0 | this.line = line; |
| 17 | 0 | this.column = column; |
| 18 | 0 | this.at = at; |
| 19 | 0 | } |
| 20 | |
|
| 21 | |
public boolean getAt() { |
| 22 | 0 | return at; |
| 23 | |
} |
| 24 | |
public String getLocation() { |
| 25 | 0 | return location; |
| 26 | |
} |
| 27 | |
|
| 28 | |
public int getColumn() { |
| 29 | 0 | return column; |
| 30 | |
} |
| 31 | |
|
| 32 | |
public int getLine() { |
| 33 | 0 | return line; |
| 34 | |
} |
| 35 | |
|
| 36 | |
public String getRawMessage() { |
| 37 | 0 | return super.getMessage(); |
| 38 | |
} |
| 39 | |
|
| 40 | |
public String getMessage() { |
| 41 | 0 | StringBuilder sb = new StringBuilder(); |
| 42 | 0 | sb.append(super.getMessage()); |
| 43 | 0 | if (getLocation() != null) sb.append(" in ").append(getLocation()); |
| 44 | 0 | sb.append(getAt() ? " at" : " after"); |
| 45 | 0 | sb.append(" line ").append(getLine()).append(", column ").append(getColumn()); |
| 46 | 0 | return sb.toString(); |
| 47 | |
} |
| 48 | |
} |