Package net.morimekta.util.lexer
Class LexerException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.io.IOException
-
- net.morimekta.util.lexer.LexerException
-
- All Implemented Interfaces:
java.io.Serializable
,Displayable
public class LexerException extends java.io.IOException implements Displayable
Exception representing problems parsing tokens or other problems with returned tokens from theLexer
, or how a token interacts with other in the whole structure. This exception is not meant to represent problems that solely comes from the interaction between tokens in an otherwise sound document, e.g. where the problem can not be pinned to a single token causing the problem.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description LexerException(java.lang.CharSequence line, int lineNo, int linePos, int length, java.lang.String message)
Make exception representing a tokenizing problem at a specific position in the input.protected
LexerException(java.lang.String message)
Make exception cause by secondary problems.protected
LexerException(java.lang.Throwable cause, java.lang.String message)
Make exception cause by secondary problems.LexerException(Token token, java.lang.String message)
Make exception representing problems with a parsed token.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
displayString()
protected java.lang.String
getError()
int
getLength()
java.lang.CharSequence
getLine()
int
getLineNo()
int
getLinePos()
LexerException
initCause(java.lang.Throwable cause)
static java.lang.String
replaceNonPrintable(java.lang.CharSequence str, char replacement)
Replace non-printable chars in a string with something else.java.lang.String
toString()
-
-
-
Constructor Detail
-
LexerException
protected LexerException(@Nonnull java.lang.String message)
Make exception cause by secondary problems.- Parameters:
message
- Exception message.
-
LexerException
protected LexerException(@Nonnull java.lang.Throwable cause, @Nonnull java.lang.String message)
Make exception cause by secondary problems.- Parameters:
cause
- The cause of the exception.message
- Exception message.
-
LexerException
public LexerException(@Nonnull Token token, @Nonnull java.lang.String message)
Make exception representing problems with a parsed token.- Parameters:
token
- The problematic token.message
- The exception message.
-
LexerException
public LexerException(@Nonnull java.lang.CharSequence line, int lineNo, int linePos, int length, @Nonnull java.lang.String message)
Make exception representing a tokenizing problem at a specific position in the input.- Parameters:
line
- The line the problem is located.lineNo
- The line number where the problem is (1-N).linePos
- The position in the line where the problem is (0-N).length
- Length of the error.message
- The exception message.
-
-
Method Detail
-
initCause
public LexerException initCause(java.lang.Throwable cause)
- Overrides:
initCause
in classjava.lang.Throwable
-
getLine
@Nullable public java.lang.CharSequence getLine()
- Returns:
- The line string where the problem occurred.
-
getLineNo
public int getLineNo()
- Returns:
- The line number where the problem occurred.
-
getLinePos
public int getLinePos()
- Returns:
- The line position where the problem occurred.
-
getLength
public int getLength()
- Returns:
- Length of match where fault lies.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Throwable
-
replaceNonPrintable
public static java.lang.String replaceNonPrintable(java.lang.CharSequence str, char replacement)
Replace non-printable chars in a string with something else. The replacement is static and only meant as a place-holder. It is advised to use a non-standard char as the replacement, as otherwise it will not be distinguishable from the standard "printable".- Parameters:
str
- The string to escape.replacement
- Char to replace non-printable with.- Returns:
- The escaped char string.
-
getError
protected java.lang.String getError()
-
displayString
@Nonnull public java.lang.String displayString()
- Specified by:
displayString
in interfaceDisplayable
- Returns:
- A displayable string value for the object. This is meant to be printed e.g. to console output and interpreted by a human.
-
-