PatternSyntaxExceptionpublic class PatternSyntaxException extends IllegalArgumentException Unchecked exception thrown to indicate a syntax error in a
regular-expression pattern. |
Fields Summary |
---|
private final String | desc | private final String | pattern | private final int | index | private static String | nl |
Constructors Summary |
---|
public PatternSyntaxException(String desc, String regex, int index)Constructs a new instance of this class.
this.desc = desc;
this.pattern = regex;
this.index = index;
|
Methods Summary |
---|
public java.lang.String | getDescription()Retrieves the description of the error.
return desc;
| public int | getIndex()Retrieves the error index.
return index;
| public java.lang.String | getMessage()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.
nl = (String)java.security.AccessController
.doPrivileged(new GetPropertyAction("line.separator"));
String nl = System.getProperty("line.separator");
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();
| public java.lang.String | getPattern()Retrieves the erroneous regular-expression pattern.
return pattern;
|
|