Package com.github.zafarkhaja.semver
Class UnexpectedCharacterException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.github.zafarkhaja.semver.ParseException
-
- com.github.zafarkhaja.semver.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 extendingParseException.- Since:
- 0.8.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private VersionParser.CharType[]expectedThe array of expected character types.private intpositionThe position of the unexpected character.private java.lang.CharacterunexpectedThe unexpected character.
-
Constructor Summary
Constructors Constructor Description UnexpectedCharacterException(UnexpectedElementException cause)Constructs aUnexpectedCharacterExceptioninstance with the wrappedUnexpectedElementExceptionexception.UnexpectedCharacterException(java.lang.Character unexpected, int position, VersionParser.CharType... expected)Constructs aUnexpectedCharacterExceptioninstance with the unexpected character, its position and the expected types.
-
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) intgetPosition()Gets the position of the unexpected character.(package private) java.lang.CharactergetUnexpectedCharacter()Gets the unexpected character.java.lang.StringtoString()Returns the string representation of this exception containing the information about the unexpected element and, if available, about the expected types.
-
-
-
Field Detail
-
unexpected
private final java.lang.Character unexpected
The unexpected character.
-
position
private final int position
The position of the unexpected character.
-
expected
private final VersionParser.CharType[] expected
The array of expected character types.
-
-
Constructor Detail
-
UnexpectedCharacterException
UnexpectedCharacterException(UnexpectedElementException cause)
Constructs aUnexpectedCharacterExceptioninstance with the wrappedUnexpectedElementExceptionexception.- Parameters:
cause- the wrapped exception
-
UnexpectedCharacterException
UnexpectedCharacterException(java.lang.Character unexpected, int position, VersionParser.CharType... expected)Constructs aUnexpectedCharacterExceptioninstance with the unexpected character, its position and the expected types.- Parameters:
unexpected- the unexpected characterposition- the position of the unexpected characterexpected- 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:
toStringin classParseException- Returns:
- the string representation of this exception
-
-