Package java.util.regex
Class PatternSyntaxException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- java.lang.IllegalArgumentException
-
- java.util.regex.PatternSyntaxException
-
- All Implemented Interfaces:
Serializable
public class PatternSyntaxException extends IllegalArgumentException
Encapsulates a syntax error that occurred during the compilation of aPattern. Might include a detailed description, the original regular expression, and the index at which the error occurred.
-
-
Constructor Summary
Constructors Constructor Description PatternSyntaxException(String description, String pattern, int index)Creates a new PatternSyntaxException for a given message, pattern, and error index.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDescription()Returns the description of the syntax error, ornullif the description is not known.intgetIndex()Returns the character index around which the error occurred, or -1 if the index is not known.StringgetMessage()Returns a detailed error message for the exception.StringgetPattern()Returns the syntactically incorrect regular expression.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
PatternSyntaxException
public PatternSyntaxException(String description, String pattern, int index)
Creates a new PatternSyntaxException for a given message, pattern, and error index.- Parameters:
description- the description of the syntax error, ornullif the description is not known.pattern- the syntactically incorrect regular expression, ornullif the regular expression is not known.index- the character index around which the error occurred, or -1 if the index is not known.
-
-
Method Detail
-
getPattern
public String getPattern()
Returns the syntactically incorrect regular expression.- Returns:
- the regular expression.
-
getMessage
public String getMessage()
Returns a detailed error message for the exception. The message is potentially multi-line, and it might include a detailed description, the original regular expression, and the index at which the error occurred.- Overrides:
getMessagein classThrowable- Returns:
- the error message.
-
getDescription
public String getDescription()
Returns the description of the syntax error, ornullif the description is not known.- Returns:
- the description.
-
getIndex
public int getIndex()
Returns the character index around which the error occurred, or -1 if the index is not known.- Returns:
- the index.
-
-