Class SyntaxException

  • All Implemented Interfaces:
    java.io.Serializable

    public class SyntaxException
    extends DataException
    Generic checked exception thrown to indicate that input contains a syntax error.
    Author:
    Garret Wilson
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      SyntaxException​(java.lang.String message)
      Message constructor.
      SyntaxException​(java.lang.String input, int index)
      input and index constructor.
      SyntaxException​(java.lang.String message, java.lang.String input)
      Message and input constructor.
      SyntaxException​(java.lang.String message, java.lang.String input, int index)
      Message, input, and index constructor.
      SyntaxException​(java.lang.String message, java.lang.Throwable cause)
      Message, cause, input, and index constructor.
      SyntaxException​(java.lang.String message, java.lang.Throwable cause, java.lang.String input)
      Message, cause, and input constructor.
      SyntaxException​(java.lang.String message, java.lang.Throwable cause, java.lang.String input, int index)
      Message, cause, input, and index constructor.
      SyntaxException​(java.lang.Throwable cause)
      Cause constructor.
      SyntaxException​(java.lang.Throwable cause, java.lang.String input)
      Cause and input constructor.
      SyntaxException​(java.lang.Throwable cause, java.lang.String input, int index)
      Cause, input, and index constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String createMessage​(java.lang.String message, java.lang.Throwable cause, java.lang.CharSequence input, int index)
      Creates a message based upon a given input string, an optional index, and an optional message.
      int getIndex()  
      java.lang.String getInput()  
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SyntaxException

        public SyntaxException​(java.lang.String message)
        Message constructor.
        Parameters:
        message - An explanation of why the input could not be parsed, or null if a default message should be used.
      • SyntaxException

        public SyntaxException​(java.lang.String message,
                               java.lang.Throwable cause)
        Message, cause, input, and index constructor. A message will be constructed including the given message, if any, or the given message of the cause, if any.
        Parameters:
        message - An explanation of why the input could not be parsed, or null if a default message should be used.
        cause - The cause error or null if the cause is nonexistent or unknown.
      • SyntaxException

        public SyntaxException​(java.lang.String message,
                               java.lang.Throwable cause,
                               java.lang.String input)
        Message, cause, and input constructor. A message will be constructed including the given message, if any, or the given message of the cause, if any.
        Parameters:
        message - An explanation of why the input could not be parsed, or null if a default message should be used.
        cause - The cause error or null if the cause is nonexistent or unknown.
        input - The input, or null if the input is not known.
      • SyntaxException

        public SyntaxException​(java.lang.String input,
                               int index)
        input and index constructor.
        Parameters:
        input - The input, or null if the input is not known.
        index - The index into the input of the position at which the parse error occurred, or -1 if the position is not known.
        Throws:
        java.lang.IllegalArgumentException - if the given index is less than -1.
      • SyntaxException

        public SyntaxException​(java.lang.String message,
                               java.lang.String input)
        Message and input constructor.
        Parameters:
        message - An explanation of why the input could not be parsed, or null if a default message should be used.
        input - The input, or null if the input is not known.
      • SyntaxException

        public SyntaxException​(java.lang.String message,
                               java.lang.String input,
                               int index)
        Message, input, and index constructor.
        Parameters:
        message - An explanation of why the input could not be parsed, or null if a default message should be used.
        input - The input, or null if the input is not known.
        index - The index into the input of the position at which the parse error occurred, or -1 if the position is not known.
        Throws:
        java.lang.IllegalArgumentException - if the given index is less than -1.
      • SyntaxException

        public SyntaxException​(java.lang.Throwable cause)
        Cause constructor.
        Parameters:
        cause - The cause error or null if the cause is nonexistent or unknown.
      • SyntaxException

        public SyntaxException​(java.lang.Throwable cause,
                               java.lang.String input)
        Cause and input constructor.
        Parameters:
        cause - The cause error or null if the cause is nonexistent or unknown.
        input - The input, or null if the input is not known.
      • SyntaxException

        public SyntaxException​(java.lang.Throwable cause,
                               java.lang.String input,
                               int index)
        Cause, input, and index constructor.
        Parameters:
        cause - The cause error or null if the cause is nonexistent or unknown.
        input - The input, or null if the input is not known.
        index - The index into the input of the position at which the parse error occurred, or -1 if the position is not known.
        Throws:
        java.lang.IllegalArgumentException - if the given index is less than -1.
      • SyntaxException

        public SyntaxException​(java.lang.String message,
                               java.lang.Throwable cause,
                               java.lang.String input,
                               int index)
        Message, cause, input, and index constructor. A message will be constructed including the given message, if any, or the given message of the cause, if any.
        Parameters:
        message - An explanation of why the input could not be parsed, or null if a default message should be used.
        cause - The cause error or null if the cause is nonexistent or unknown.
        input - The input, or null if the input is not known.
        index - The index into the input of the position at which the parse error occurred, or -1 if the position is not known.
        Throws:
        java.lang.IllegalArgumentException - if the given index is less than -1.
    • Method Detail

      • getInput

        public java.lang.String getInput()
        Returns:
        The input, or null if the input is not known.
      • getIndex

        public int getIndex()
        Returns:
        The index into the input of the position at which the error occurred, or -1 if the position is not known.
      • createMessage

        public static java.lang.String createMessage​(java.lang.String message,
                                                     java.lang.Throwable cause,
                                                     java.lang.CharSequence input,
                                                     int index)
        Creates a message based upon a given input string, an optional index, and an optional message.
        Parameters:
        message - The message to include, or null if there is no custom message to include.
        cause - The cause error or null if the cause is nonexistent or unknown.
        input - The input character sequence, or null if the input string is not known.
        index - The index into the input string of the position at which the parse error occurred, or -1 if the position is not known.
        Returns:
        A string explaining the exception based upon the given input and optional index.
        Throws:
        java.lang.IllegalArgumentException - if the given index is less than -1.