Class UnexpectedCharacterException

  • All Implemented Interfaces:
    java.io.Serializable

    public class UnexpectedCharacterException
    extends ParseException
    Thrown when attempting to consume a character of unexpected types. This exception is a wrapper exception extending ParseException.
    Since:
    0.8.0
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private VersionParser.CharType[] expected
      The array of expected character types.
      private int position
      The position of the unexpected character.
      private java.lang.Character unexpected
      The unexpected character.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) VersionParser.CharType[] getExpectedCharTypes()
      Gets the expected character types.
      (package private) int getPosition()
      Gets the position of the unexpected character.
      (package private) java.lang.Character getUnexpectedCharacter()
      Gets the unexpected character.
      java.lang.String toString()
      Returns the string representation of this exception containing the information about the unexpected element and, if available, about the expected types.
      • Methods inherited from class java.lang.Throwable

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

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

      • unexpected

        private final java.lang.Character unexpected
        The unexpected character.
      • position

        private final int position
        The position of the unexpected character.
    • Constructor Detail

      • UnexpectedCharacterException

        UnexpectedCharacterException​(UnexpectedElementException cause)
        Constructs a UnexpectedCharacterException instance with the wrapped UnexpectedElementException exception.
        Parameters:
        cause - the wrapped exception
      • UnexpectedCharacterException

        UnexpectedCharacterException​(java.lang.Character unexpected,
                                     int position,
                                     VersionParser.CharType... expected)
        Constructs a UnexpectedCharacterException instance with the unexpected character, its position and the expected types.
        Parameters:
        unexpected - the unexpected character
        position - the position of the unexpected character
        expected - an array of the expected character types
    • Method Detail

      • getUnexpectedCharacter

        java.lang.Character getUnexpectedCharacter()
        Gets the unexpected character.
        Returns:
        the unexpected character
      • getPosition

        int getPosition()
        Gets the position of the unexpected character.
        Returns:
        the position of the unexpected character
      • getExpectedCharTypes

        VersionParser.CharType[] getExpectedCharTypes()
        Gets the expected character types.
        Returns:
        an array of expected character types
      • toString

        public java.lang.String toString()
        Returns the string representation of this exception containing the information about the unexpected element and, if available, about the expected types.
        Overrides:
        toString in class ParseException
        Returns:
        the string representation of this exception