Package com.globalmentor.io
Class ParseUnexpectedDataException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.io.IOException
-
- com.globalmentor.io.ParseIOException
-
- com.globalmentor.io.ParseUnexpectedDataException
-
- All Implemented Interfaces:
java.io.Serializable
public class ParseUnexpectedDataException extends ParseIOException
Class for unexpected characters encountered when parsing an input stream. Used byParseReader
.This implementation assumes that if a list of strings were expected, a string will have been found. That is, if
getExpectedCharacters()
returns a valuegetFoundCharacter()
will hold a valid value; otherwise,getFoundString()
will hold the appropriate value.- See Also:
ParseIOException
,ParseReader
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ParseUnexpectedDataException(char expectedChar, char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error, when one character was expected.ParseUnexpectedDataException(char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error.ParseUnexpectedDataException(Characters expectedChars, char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error, when multiple characters were expected.ParseUnexpectedDataException(java.io.Reader reader, char foundChar)
Constructor for an unexpected character error from a parse reader.ParseUnexpectedDataException(java.io.Reader reader, char expectedChar, char foundChar)
Constructor for an unexpected character error from a parse reader, when one character was expected.ParseUnexpectedDataException(java.io.Reader reader, Characters expectedChars, char foundChar)
Constructor for an unexpected character error from a parse reader, when multiple characters were expected.ParseUnexpectedDataException(java.io.Reader reader, java.lang.String message, char foundChar)
Constructor for an unexpected character error from a parse reader.ParseUnexpectedDataException(java.io.Reader reader, java.lang.String message, char expectedChar, char foundChar)
Constructor for an unexpected character error from a parse reader, when one character was expected.ParseUnexpectedDataException(java.lang.String[] expectedStrings, java.lang.String foundString, long lineIndex, long charIndex, java.lang.String sourceName)
Constructor for an unexpected character error, when multiple strings were expected.ParseUnexpectedDataException(java.lang.String message, char expectedChar, char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error, when one character was expected.ParseUnexpectedDataException(java.lang.String message, char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<Characters>
getExpectedCharacters()
java.lang.String
getExpectedMessage()
Returns a message with the expected data, either a list of characters or a list of strings.java.util.Optional<java.util.List<java.lang.String>>
getExpectedStrings()
char
getFoundCharacter()
java.lang.String
getFoundMessage()
Returns a message with the data found, either a single character or a string.java.util.Optional<java.lang.String>
getFoundString()
protected void
setExpectedCharacters(Characters expectedCharacters)
Sets the expected characters.protected void
setExpectedStrings(java.util.List<java.lang.String> expectedStrings)
Sets the expected strings.protected void
setFoundCharacter(char foundCharacter)
Sets the character found.protected void
setFoundString(java.lang.String foundString)
Sets the string found.-
Methods inherited from class com.globalmentor.io.ParseIOException
convertStringsToMessage, createMessage, createMessage, createMessage, getCharacterIndex, getCharIndex, getLineIndex, getLineIndex, getSourceName
-
-
-
-
Constructor Detail
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(java.io.Reader reader, char foundChar)
Constructor for an unexpected character error from a parse reader.- Parameters:
reader
- The reader the data of which is the source of the error.foundChar
- The character found at this location.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(java.io.Reader reader, java.lang.String message, char foundChar)
Constructor for an unexpected character error from a parse reader.- Parameters:
reader
- The reader the data of which is the source of the error.message
- The error message, ornull
if there is no error message.foundChar
- The character found at this location.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error.- Parameters:
foundChar
- The character found at this location.lineIndex
- The index of the line in which the error occurred.charIndex
- The index of the character at which the error occurred on the current line.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(java.lang.String message, char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error.- Parameters:
message
- The error message, ornull
if there is no error message.foundChar
- The character found at this location.lineIndex
- The index of the line in which the error occurred.charIndex
- The index of the character at which the error occurred on the current line.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(java.io.Reader reader, char expectedChar, char foundChar)
Constructor for an unexpected character error from a parse reader, when one character was expected.- Parameters:
reader
- The reader the data of which is the source of the error.expectedChar
- The character expected at this location.foundChar
- The character found at this location.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(java.io.Reader reader, java.lang.String message, char expectedChar, char foundChar)
Constructor for an unexpected character error from a parse reader, when one character was expected.- Parameters:
reader
- The reader the data of which is the source of the error.message
- The error message, ornull
if there is no error message.expectedChar
- The character expected at this location.foundChar
- The character found at this location.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(char expectedChar, char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error, when one character was expected.- Parameters:
expectedChar
- The character expected at this location.foundChar
- The character found at this location.lineIndex
- The index of the line in which the error occurred.charIndex
- The index of the character at which the error occurred on the current line.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(java.lang.String message, char expectedChar, char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error, when one character was expected.- Parameters:
message
- The error message, ornull
if there is no error message.expectedChar
- The character expected at this location.foundChar
- The character found at this location.lineIndex
- The index of the line in which the error occurred.charIndex
- The index of the character at which the error occurred on the current line.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(java.io.Reader reader, Characters expectedChars, char foundChar)
Constructor for an unexpected character error from a parse reader, when multiple characters were expected.- Parameters:
reader
- The reader the data of which is the source of the error.expectedChars
- The characters expected at this location.foundChar
- The character found at this location.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(Characters expectedChars, char foundChar, long lineIndex, long charIndex)
Constructor for an unexpected character error, when multiple characters were expected.- Parameters:
expectedChars
- The characters expected at this location.foundChar
- The character found at this location.lineIndex
- The index of the line in which the error occurred.charIndex
- The index of the character at which the error occurred on the current line.
-
ParseUnexpectedDataException
public ParseUnexpectedDataException(java.lang.String[] expectedStrings, java.lang.String foundString, long lineIndex, long charIndex, java.lang.String sourceName)
Constructor for an unexpected character error, when multiple strings were expected.- Parameters:
expectedStrings
- An array containing the strings expected at this location.foundString
- The string found at this location.lineIndex
- The index of the line in which the error occurred.charIndex
- The index of the character at which the error occurred on the current line.sourceName
- The name of the source of the data (perhaps a filename).
-
-
Method Detail
-
getExpectedCharacters
public java.util.Optional<Characters> getExpectedCharacters()
- Returns:
- The expected characters, if characters were expected.
-
setExpectedCharacters
protected void setExpectedCharacters(@Nonnull Characters expectedCharacters)
Sets the expected characters.- Parameters:
expectedCharacters
- The expected characters.
-
getFoundCharacter
public char getFoundCharacter()
- Returns:
- The character found, if characters were expected, else
0
.
-
setFoundCharacter
protected void setFoundCharacter(char foundCharacter)
Sets the character found.- Parameters:
foundCharacter
- The character found.
-
getExpectedStrings
public java.util.Optional<java.util.List<java.lang.String>> getExpectedStrings()
- Returns:
- The expected strings, if strings were expected.
-
setExpectedStrings
protected void setExpectedStrings(@Nonnull java.util.List<java.lang.String> expectedStrings)
Sets the expected strings.- Parameters:
expectedStrings
- The expected strings.
-
getFoundString
public java.util.Optional<java.lang.String> getFoundString()
- Returns:
- The string found, if strings were expected.
-
setFoundString
protected void setFoundString(@Nonnull java.lang.String foundString)
Sets the string found.- Parameters:
foundString
- The string found.
-
getExpectedMessage
public java.lang.String getExpectedMessage()
Returns a message with the expected data, either a list of characters or a list of strings.- Returns:
- A message with the expected data.
-
getFoundMessage
public java.lang.String getFoundMessage()
Returns a message with the data found, either a single character or a string.- Returns:
- A message with the data found.
-
-