001    package com.thaiopensource.datatype.xsd.regex;
002    
003    /**
004     * Thrown when an syntactically incorrect regular expression is detected.
005     */
006    public class RegexSyntaxException extends Exception {
007      private final int position;
008    
009      /**
010       * Represents an unknown position within a string containing a regular expression.
011       */
012      static public final int UNKNOWN_POSITION = -1;
013    
014      public RegexSyntaxException(String detail) {
015        this(detail, UNKNOWN_POSITION);
016      }
017    
018      public RegexSyntaxException(String detail, int position) {
019        super(detail);
020        this.position = position;
021      }
022    
023      /**
024       * Returns the index into the regular expression where the error was detected
025       * or <code>UNKNOWN_POSITION</code> if this is unknown.
026       *
027       * @return the index into the regular expression where the error was detected,
028       * or <code>UNKNOWNN_POSITION</code> if this is unknown
029       */
030      public int getPosition() {
031        return position;
032      }
033    }