< prev index next >

src/java.base/share/classes/java/util/regex/PatternSyntaxException.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs


  77 
  78     /**
  79      * Retrieves the description of the error.
  80      *
  81      * @return  The description of the error
  82      */
  83     public String getDescription() {
  84         return desc;
  85     }
  86 
  87     /**
  88      * Retrieves the erroneous regular-expression pattern.
  89      *
  90      * @return  The erroneous pattern
  91      */
  92     public String getPattern() {
  93         return pattern;
  94     }
  95 
  96     private static final String nl =
  97         java.security.AccessController
  98             .doPrivileged(new GetPropertyAction("line.separator"));
  99 
 100     /**
 101      * Returns a multi-line string containing the description of the syntax
 102      * error and its index, the erroneous regular-expression pattern, and a
 103      * visual indication of the error index within the pattern.
 104      *
 105      * @return  The full detail message
 106      */
 107     public String getMessage() {
 108         StringBuilder sb = new StringBuilder();
 109         sb.append(desc);
 110         if (index >= 0) {
 111             sb.append(" near index ");
 112             sb.append(index);
 113         }
 114         sb.append(nl);
 115         sb.append(pattern);
 116         if (index >= 0) {
 117             sb.append(nl);
 118             for (int i = 0; i < index; i++) sb.append(' ');


  77 
  78     /**
  79      * Retrieves the description of the error.
  80      *
  81      * @return  The description of the error
  82      */
  83     public String getDescription() {
  84         return desc;
  85     }
  86 
  87     /**
  88      * Retrieves the erroneous regular-expression pattern.
  89      *
  90      * @return  The erroneous pattern
  91      */
  92     public String getPattern() {
  93         return pattern;
  94     }
  95 
  96     private static final String nl =
  97             GetPropertyAction.getProperty("line.separator");

  98 
  99     /**
 100      * Returns a multi-line string containing the description of the syntax
 101      * error and its index, the erroneous regular-expression pattern, and a
 102      * visual indication of the error index within the pattern.
 103      *
 104      * @return  The full detail message
 105      */
 106     public String getMessage() {
 107         StringBuilder sb = new StringBuilder();
 108         sb.append(desc);
 109         if (index >= 0) {
 110             sb.append(" near index ");
 111             sb.append(index);
 112         }
 113         sb.append(nl);
 114         sb.append(pattern);
 115         if (index >= 0) {
 116             sb.append(nl);
 117             for (int i = 0; i < index; i++) sb.append(' ');
< prev index next >