java.util.regex
public class: PatternSyntaxException [javadoc |
source]
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.IllegalArgumentException
java.util.regex.PatternSyntaxException
All Implemented Interfaces:
Serializable
Unchecked exception thrown to indicate a syntax error in a
regular-expression pattern.
- author:
unascribed -
- since:
1.4 -
- spec:
JSR-51 -
| Constructor: |
public PatternSyntaxException(String desc,
String regex,
int index) {
this.desc = desc;
this.pattern = regex;
this.index = index;
}
Constructs a new instance of this class. Parameters:
desc -
A description of the error
regex -
The erroneous pattern
index -
The approximate index in the pattern of the error,
or -1 if the index is not known
|
| Methods from java.lang.Throwable: |
|---|
|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from java.util.regex.PatternSyntaxException Detail: |
public String getDescription() {
return desc;
}
Retrieves the description of the error. |
public int getIndex() {
return index;
}
Retrieves the error index. |
public String getMessage() {
StringBuffer sb = new StringBuffer();
sb.append(desc);
if (index >= 0) {
sb.append(" near index ");
sb.append(index);
}
sb.append(nl);
sb.append(pattern);
if (index >= 0) {
sb.append(nl);
for (int i = 0; i < index; i++) sb.append(' ");
sb.append('^");
}
return sb.toString();
}
Returns a multi-line string containing the description of the syntax
error and its index, the erroneous regular-expression pattern, and a
visual indication of the error index within the pattern. |
public String getPattern() {
return pattern;
}
Retrieves the erroneous regular-expression pattern. |