Package org.svetovid.io
Class AbstractSvetovidReader
java.lang.Object
org.svetovid.io.AbstractSvetovidReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,SvetovidReader
- Direct Known Subclasses:
DefaultSvetovidReader
This class provides default implementations for the
SvetovidReader
interface. Standard behaviors of all methods are defined here. The developer
need only subclass this abstract class and define the doReadLine()
method.- Author:
- Ivan Pribela
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected Throwable
protected String
protected boolean
protected String
protected AbstractSvetovidReader.TokenType
protected Pattern
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this reader and releases any resources associated with the underlying source.protected abstract String
Returns the exception raised in the last operation; if the operation was successful and no exception was raised, returnsnull
.Returns the currently used pattern for recognizing whitespace.protected void
handleAnyException
(Throwable exception) protected void
handleFormatException
(SvetovidFormatException exception) boolean
hasMore()
Checks whether this reader has data to be read.protected boolean
isCharInNumber
(char ch) protected boolean
isCharWhitespace
(char ch) protected boolean
isCharWhitespaceOrSymbol
(char ch) boolean
isEmpty()
Checks whether this reader has no more data to be read.boolean
Returns the indicator whether this reader will throw exceptions on I/O operation errors or just return default values.protected char
nextChar()
protected Boolean
protected Number
nextPair()
protected String
protected void
protected Object
protected boolean
protected char
readAll()
Reads all remaining content and returns it as a string.String[]
Read all remaining lines and returns them as an array of strings.boolean
readBool()
Reads one token and converts it to a boolean value.boolean[]
Reads one line, separates it into tokens and converts them to boolean values.Boolean[]
Reads one line, separates it into tokens and converts them to boolean values.Reads one token and converts it to a boolean value.boolean[][]
Reads multiple lines and converts the data to a boolean matrix.Boolean[][]
Reads multiple lines and converts the data to a boolean matrix.byte
readByte()
Reads one token and converts it to a byte value.byte[]
Reads one line, separates it into tokens and converts them to byte values.Byte[]
Reads one line, separates it into tokens and converts them to byte values.Reads one token and converts it to a byte value.byte[][]
Reads multiple lines and converts the data to a byte matrix.Byte[][]
Reads multiple lines and converts the data to a byte matrix.char
readChar()
Reads one token and converts it to a character value.char[]
Reads one line, separates it into tokens and converts them to character values.Reads one line, separates it into tokens and converts them to character values.Reads one token and converts it to a character value.char[][]
Reads multiple lines and converts the data to a character matrix.Character[][]
Reads multiple lines and converts the data to a character matrix.double
Reads one token and converts it to a double-precision floating-point value.double[]
Reads one line, separates it into tokens and converts them to double-precision floating-point values.Double[]
Reads one line, separates it into tokens and converts them to double-precision floating-point values.Reads one token and converts it to a double-precision floating-point value.double[][]
Reads multiple lines and converts the data to a double-precision floating-point matrix.Double[][]
Reads multiple lines and converts the data to a double-precision floating-point matrix.float
Reads one token and converts it to a floating-point value.float[]
Reads one line, separates it into tokens and converts them to floating-point values.Float[]
Reads one line, separates it into tokens and converts them to floating-point values.Reads one token and converts it to a floating-point value.float[][]
Reads multiple lines and converts the data to a floating-point matrix.Float[][]
Reads multiple lines and converts the data to a floating-point matrix.int
readInt()
Reads one token and converts it to an integer value.int[]
Reads one line, separates it into tokens and converts them to integer values.Integer[]
Reads one line, separates it into tokens and converts them to integer values.Reads one token and converts it to an integer value.int[][]
Reads multiple lines and converts the data to an integer matrix.Integer[][]
Reads multiple lines and converts the data to an integer matrix.readLine()
Reads a line of text and returns it as a string.long
readLong()
Reads one token and converts it to a long integer value.long[]
Reads one line, separates it into tokens and converts them to long integer values.Long[]
Reads one line, separates it into tokens and converts them to long integer values.Reads one token and converts it to a long integer value.long[][]
Reads multiple lines and converts the data to a long integer matrix.Long[][]
Reads multiple lines and converts the data to a long integer matrix.Reads a JSON (JavaScript Object Notation) formatted object.short
Reads one token and converts it to a short integer value.short[]
Reads one line, separates it into tokens and converts them to short integer values.Short[]
Reads one line, separates it into tokens and converts them to short integer values.Reads one token and converts it to a short integer value.short[][]
Reads multiple lines and converts the data to a shot integer matrix.Short[][]
Reads multiple lines and converts the data to a shot integer matrix.Reads one token and returns it as a string value.String[]
Reads one line, separates it into tokens and returns them as string values.String[][]
Reads multiple lines and converts the data to a string matrix.protected void
returnChar
(char ch) void
setThrowingExceptions
(boolean shouldThrow) Configures whether this reader should throw exceptions on I/O operation errors or just return default values.void
setWhitespace
(Pattern whitespace) Sets the pattern used to recognize whitespace.protected void
-
Field Details
-
whitespace
-
throwingExceptions
protected boolean throwingExceptions -
lastException
-
line
-
tokenType
-
tokenContent
-
-
Constructor Details
-
AbstractSvetovidReader
public AbstractSvetovidReader()
-
-
Method Details
-
getWhitespace
Description copied from interface:SvetovidReader
Returns the currently used pattern for recognizing whitespace. This pattern is used to separate tokens when reading form the underlying source. For more on patterns seePattern
.- Specified by:
getWhitespace
in interfaceSvetovidReader
- Returns:
- the pattern currently used to recognize whitespace.
- See Also:
-
setWhitespace
Description copied from interface:SvetovidReader
Sets the pattern used to recognize whitespace. This pattern is used to separate tokens when reading form the underlying source. For more on patterns seePattern
.- Specified by:
setWhitespace
in interfaceSvetovidReader
- Parameters:
whitespace
- the pattern to use recognize whitespace- See Also:
-
isThrowingExceptions
public boolean isThrowingExceptions()Description copied from interface:SvetovidReader
Returns the indicator whether this reader will throw exceptions on I/O operation errors or just return default values.- Specified by:
isThrowingExceptions
in interfaceSvetovidReader
- Returns:
true
if this reader throws exceptions on failed I/O operations;false
otherwise.
-
setThrowingExceptions
public void setThrowingExceptions(boolean shouldThrow) Description copied from interface:SvetovidReader
Configures whether this reader should throw exceptions on I/O operation errors or just return default values.- Specified by:
setThrowingExceptions
in interfaceSvetovidReader
- Parameters:
shouldThrow
-true
if this reader should throw exceptions on failed I/O operations in the future;false
if it should return default values.
-
getLastException
Description copied from interface:SvetovidReader
Returns the exception raised in the last operation; if the operation was successful and no exception was raised, returnsnull
.- Specified by:
getLastException
in interfaceSvetovidReader
- Returns:
- the exception raised in the last operation or
null
it the operation was successful.
-
wrapUpIOException
- Throws:
SvetovidException
-
handleFormatException
protected void handleFormatException(SvetovidFormatException exception) throws SvetovidFormatException - Throws:
SvetovidFormatException
-
handleAnyException
- Throws:
RuntimeException
-
isEmpty
public boolean isEmpty()Description copied from interface:SvetovidReader
Checks whether this reader has no more data to be read.- Specified by:
isEmpty
in interfaceSvetovidReader
- Returns:
true
if this reader has no more data to be read;false
otherwise.
-
hasMore
public boolean hasMore()Description copied from interface:SvetovidReader
Checks whether this reader has data to be read.- Specified by:
hasMore
in interfaceSvetovidReader
- Returns:
true
if this reader has data to be read;false
otherwise.
-
close
Description copied from interface:SvetovidReader
Closes this reader and releases any resources associated with the underlying source. The general contract ofclose
is that it closes the input source. A closed source cannot perform input operations and cannot be reopened.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceSvetovidReader
- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
readBool
Description copied from interface:SvetovidReader
Reads one token and converts it to a boolean value.- Specified by:
readBool
in interfaceSvetovidReader
- Returns:
- the
boolean
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable boolean.SvetovidIOException
- if an error occurred during the operation.
-
parseBool
- Throws:
NumberFormatException
-
readByte
Description copied from interface:SvetovidReader
Reads one token and converts it to a byte value.- Specified by:
readByte
in interfaceSvetovidReader
- Returns:
- the
byte
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable byte.SvetovidIOException
- if an error occurred during the operation.
-
readShort
Description copied from interface:SvetovidReader
Reads one token and converts it to a short integer value.- Specified by:
readShort
in interfaceSvetovidReader
- Returns:
- the
short
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable short.SvetovidIOException
- if an error occurred during the operation.
-
readInt
Description copied from interface:SvetovidReader
Reads one token and converts it to an integer value.- Specified by:
readInt
in interfaceSvetovidReader
- Returns:
- the
int
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable int.SvetovidIOException
- if an error occurred during the operation.
-
readLong
Description copied from interface:SvetovidReader
Reads one token and converts it to a long integer value.- Specified by:
readLong
in interfaceSvetovidReader
- Returns:
- the
long
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable long.SvetovidIOException
- if an error occurred during the operation.
-
readFloat
Description copied from interface:SvetovidReader
Reads one token and converts it to a floating-point value.- Specified by:
readFloat
in interfaceSvetovidReader
- Returns:
- the
float
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable float.SvetovidIOException
- if an error occurred during the operation.
-
readDouble
Description copied from interface:SvetovidReader
Reads one token and converts it to a double-precision floating-point value.- Specified by:
readDouble
in interfaceSvetovidReader
- Returns:
- the
double
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable double.SvetovidIOException
- if an error occurred during the operation.
-
readChar
Description copied from interface:SvetovidReader
Reads one token and converts it to a character value.- Specified by:
readChar
in interfaceSvetovidReader
- Returns:
- the
char
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable char.SvetovidIOException
- if an error occurred during the operation.
-
parseChar
- Throws:
NumberFormatException
-
readToken
Description copied from interface:SvetovidReader
Reads one token and returns it as a string value.- Specified by:
readToken
in interfaceSvetovidReader
- Returns:
- the
String
value read. - Throws:
SvetovidIOException
- if an error occurred during the operation.
-
readBoolBoxed
Description copied from interface:SvetovidReader
Reads one token and converts it to a boolean value.- Specified by:
readBoolBoxed
in interfaceSvetovidReader
- Returns:
- the
Boolean
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable boolean.SvetovidIOException
- if an error occurred during the operation.
-
readByteBoxed
Description copied from interface:SvetovidReader
Reads one token and converts it to a byte value.- Specified by:
readByteBoxed
in interfaceSvetovidReader
- Returns:
- the
Byte
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable byte.SvetovidIOException
- if an error occurred during the operation.
-
readShortBoxed
Description copied from interface:SvetovidReader
Reads one token and converts it to a short integer value.- Specified by:
readShortBoxed
in interfaceSvetovidReader
- Returns:
- the
Short
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable short.SvetovidIOException
- if an error occurred during the operation.
-
readIntBoxed
Description copied from interface:SvetovidReader
Reads one token and converts it to an integer value.- Specified by:
readIntBoxed
in interfaceSvetovidReader
- Returns:
- the
Integer
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable int.SvetovidIOException
- if an error occurred during the operation.
-
readLongBoxed
Description copied from interface:SvetovidReader
Reads one token and converts it to a long integer value.- Specified by:
readLongBoxed
in interfaceSvetovidReader
- Returns:
- the
Long
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable long.SvetovidIOException
- if an error occurred during the operation.
-
readFloatBoxed
Description copied from interface:SvetovidReader
Reads one token and converts it to a floating-point value.- Specified by:
readFloatBoxed
in interfaceSvetovidReader
- Returns:
- the
Float
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable float.SvetovidIOException
- if an error occurred during the operation.
-
readDoubleBoxed
Description copied from interface:SvetovidReader
Reads one token and converts it to a double-precision floating-point value.- Specified by:
readDoubleBoxed
in interfaceSvetovidReader
- Returns:
- the
Double
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable double.SvetovidIOException
- if an error occurred during the operation.
-
readCharBoxed
Description copied from interface:SvetovidReader
Reads one token and converts it to a character value.- Specified by:
readCharBoxed
in interfaceSvetovidReader
- Returns:
- the
Character
value read. - Throws:
SvetovidFormatException
- if the token is not a parsable character.SvetovidIOException
- if an error occurred during the operation.
-
readBoolArray
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to boolean values.- Specified by:
readBoolArray
in interfaceSvetovidReader
- Returns:
- an array of
boolean
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable boolean.SvetovidIOException
- if an error occurred during the operation.
-
readByteArray
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to byte values.- Specified by:
readByteArray
in interfaceSvetovidReader
- Returns:
- an array of
byte
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable byte.SvetovidIOException
- if an error occurred during the operation.
-
readShortArray
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to short integer values.- Specified by:
readShortArray
in interfaceSvetovidReader
- Returns:
- an array of
short
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable short.SvetovidIOException
- if an error occurred during the operation.
-
readIntArray
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to integer values.- Specified by:
readIntArray
in interfaceSvetovidReader
- Returns:
- an array of
int
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable integer.SvetovidIOException
- if an error occurred during the operation.
-
readLongArray
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to long integer values.- Specified by:
readLongArray
in interfaceSvetovidReader
- Returns:
- an array of
long
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable long.SvetovidIOException
- if an error occurred during the operation.
-
readFloatArray
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to floating-point values.- Specified by:
readFloatArray
in interfaceSvetovidReader
- Returns:
- an array of
float
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable float.SvetovidIOException
- if an error occurred during the operation.
-
readDoubleArray
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to double-precision floating-point values.- Specified by:
readDoubleArray
in interfaceSvetovidReader
- Returns:
- an array of
double
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable double.SvetovidIOException
- if an error occurred during the operation.
-
readCharArray
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to character values.- Specified by:
readCharArray
in interfaceSvetovidReader
- Returns:
- an array of
char
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable character.SvetovidIOException
- if an error occurred during the operation.
-
readTokenArray
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and returns them as string values.- Specified by:
readTokenArray
in interfaceSvetovidReader
- Returns:
- an array of
String
values read. - Throws:
SvetovidIOException
- if an error occurred during the operation.SvetovidFormatException
-
readBoolArrayBoxed
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to boolean values.- Specified by:
readBoolArrayBoxed
in interfaceSvetovidReader
- Returns:
- an array of
Boolean
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable boolean.SvetovidIOException
- if an error occurred during the operation.
-
readByteArrayBoxed
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to byte values.- Specified by:
readByteArrayBoxed
in interfaceSvetovidReader
- Returns:
- an array of
Byte
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable byte.SvetovidIOException
- if an error occurred during the operation.
-
readShortArrayBoxed
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to short integer values.- Specified by:
readShortArrayBoxed
in interfaceSvetovidReader
- Returns:
- an array of
Short
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable short.SvetovidIOException
- if an error occurred during the operation.
-
readIntArrayBoxed
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to integer values.- Specified by:
readIntArrayBoxed
in interfaceSvetovidReader
- Returns:
- an array of
Integer
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable integer.SvetovidIOException
- if an error occurred during the operation.
-
readLongArrayBoxed
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to long integer values.- Specified by:
readLongArrayBoxed
in interfaceSvetovidReader
- Returns:
- an array of
Long
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable long.SvetovidIOException
- if an error occurred during the operation.
-
readFloatArrayBoxed
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to floating-point values.- Specified by:
readFloatArrayBoxed
in interfaceSvetovidReader
- Returns:
- an array of
Float
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable float.SvetovidIOException
- if an error occurred during the operation.
-
readDoubleArrayBoxed
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to double-precision floating-point values.- Specified by:
readDoubleArrayBoxed
in interfaceSvetovidReader
- Returns:
- an array of
Double
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable double.SvetovidIOException
- if an error occurred during the operation.
-
readCharArrayBoxed
Description copied from interface:SvetovidReader
Reads one line, separates it into tokens and converts them to character values.- Specified by:
readCharArrayBoxed
in interfaceSvetovidReader
- Returns:
- an array of
Character
values read. - Throws:
SvetovidFormatException
- if one of the tokens is not a parsable character.SvetovidIOException
- if an error occurred during the operation.
-
readLine
Description copied from interface:SvetovidReader
Reads a line of text and returns it as a string. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a line feed.- Specified by:
readLine
in interfaceSvetovidReader
- Returns:
- A
String
containing the contents of the line, not including any line-termination characters, or null if the end of the source has been reached. - Throws:
SvetovidIOException
- if an error occurred during the operation.
-
doReadLine
- Throws:
IOException
-
readAllLines
Description copied from interface:SvetovidReader
Read all remaining lines and returns them as an array of strings. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a line feed.- Specified by:
readAllLines
in interfaceSvetovidReader
- Returns:
- A
String
array containing the contents of the remaining lines, not including any line-termination characters, or an empty array if the end of the source has been reached. - Throws:
SvetovidIOException
- if an error occurred during the operation.
-
readAll
Description copied from interface:SvetovidReader
Reads all remaining content and returns it as a string.- Specified by:
readAll
in interfaceSvetovidReader
- Returns:
- A
String
containing all the remaining contents of the source, or null if the end of the source has been reached. - Throws:
SvetovidIOException
- if an error occurred during the operation.
-
readBoolMatrix
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a boolean matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readBoolMatrix
in interfaceSvetovidReader
- Returns:
- a matrix of
boolean
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable boolean.SvetovidIOException
- if an error occurred during the operation.
-
readByteMatrix
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a byte matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readByteMatrix
in interfaceSvetovidReader
- Returns:
- a matrix of
byte
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable byte.SvetovidIOException
- if an error occurred during the operation.
-
readShortMatrix
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a shot integer matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readShortMatrix
in interfaceSvetovidReader
- Returns:
- a matrix of
short
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable short.SvetovidIOException
- if an error occurred during the operation.
-
readIntMatrix
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to an integer matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readIntMatrix
in interfaceSvetovidReader
- Returns:
- a matrix of
int
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable integer.SvetovidIOException
- if an error occurred during the operation.
-
readLongMatrix
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a long integer matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readLongMatrix
in interfaceSvetovidReader
- Returns:
- a matrix of
long
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable long.SvetovidIOException
- if an error occurred during the operation.
-
readFloatMatrix
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a floating-point matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readFloatMatrix
in interfaceSvetovidReader
- Returns:
- a matrix of
float
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable float.SvetovidIOException
- if an error occurred during the operation.
-
readDoubleMatrix
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a double-precision floating-point matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readDoubleMatrix
in interfaceSvetovidReader
- Returns:
- a matrix of
double
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable double.SvetovidIOException
- if an error occurred during the operation.
-
readCharMatrix
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a character matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readCharMatrix
in interfaceSvetovidReader
- Returns:
- a matrix of
char
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable character.SvetovidIOException
- if an error occurred during the operation.
-
readTokenMatrix
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a string matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readTokenMatrix
in interfaceSvetovidReader
- Returns:
- a matrix of
String
values read. - Throws:
SvetovidIOException
- if an error occurred during the operation.
-
readBoolMatrixBoxed
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a boolean matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readBoolMatrixBoxed
in interfaceSvetovidReader
- Returns:
- a matrix of
Boolean
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable boolean.SvetovidIOException
- if an error occurred during the operation.
-
readByteMatrixBoxed
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a byte matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readByteMatrixBoxed
in interfaceSvetovidReader
- Returns:
- a matrix of
Byte
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable byte.SvetovidIOException
- if an error occurred during the operation.
-
readShortMatrixBoxed
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a shot integer matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readShortMatrixBoxed
in interfaceSvetovidReader
- Returns:
- a matrix of
Short
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable short.SvetovidIOException
- if an error occurred during the operation.
-
readIntMatrixBoxed
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to an integer matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readIntMatrixBoxed
in interfaceSvetovidReader
- Returns:
- a matrix of
Integer
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable integer.SvetovidIOException
- if an error occurred during the operation.
-
readLongMatrixBoxed
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a long integer matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readLongMatrixBoxed
in interfaceSvetovidReader
- Returns:
- a matrix of
Long
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable long.SvetovidIOException
- if an error occurred during the operation.
-
readFloatMatrixBoxed
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a floating-point matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readFloatMatrixBoxed
in interfaceSvetovidReader
- Returns:
- a matrix of
Float
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable float.SvetovidIOException
- if an error occurred during the operation.
-
readDoubleMatrixBoxed
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a double-precision floating-point matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readDoubleMatrixBoxed
in interfaceSvetovidReader
- Returns:
- a matrix of
Double
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable double.SvetovidIOException
- if an error occurred during the operation.
-
readCharMatrixBoxed
Description copied from interface:SvetovidReader
Reads multiple lines and converts the data to a character matrix. The matrix is read row by row until an empty row is found or the end of input is reached.- Specified by:
readCharMatrixBoxed
in interfaceSvetovidReader
- Returns:
- a matrix of
Character
values read. - Throws:
SvetovidFormatException
- if one of the read values is not a parsable character.SvetovidIOException
- if an error occurred during the operation.
-
readObject
Description copied from interface:SvetovidReader
Reads a JSON (JavaScript Object Notation) formatted object.The object is converted to Java types using the following rules:
- literal
null
is converted to Javanull
, - literals
true
andfalse
are converted toBoolean.TRUE
andBoolean.FALSE
respectively, - numbers are converted to an instance of the first numeric type from
the following list that can hold the value read:
Byte
,Short
,Integer
,Long
,Float
,Double
,BigInteger
,BigDecimal
, - strings are converted to
String
values, - arrays are converted to
List
s containing the held values in the same order - and objects are converted to
Map
s that can be iterated in the order in which its members were defined. Each member's value is registered in the map under its name.
- Specified by:
readObject
in interfaceSvetovidReader
- Returns:
- a Java Object parsed form the JSON format according to the above rules.
- Throws:
SvetovidFormatException
- if the object to be read is not in the JSON format.SvetovidIOException
- if an error occurred during the operation.
- literal
-
nextChar
- Throws:
SvetovidIOException
EOFException
-
returnChar
protected void returnChar(char ch) -
isCharWhitespace
protected boolean isCharWhitespace(char ch) -
isCharWhitespaceOrSymbol
protected boolean isCharWhitespaceOrSymbol(char ch) -
isCharInNumber
protected boolean isCharInNumber(char ch) -
nextToken
- Throws:
SvetovidIOException
-
nextLiteral
- Throws:
SvetovidFormatException
-
nextNumber
- Throws:
SvetovidFormatException
-
nextString
- Throws:
SvetovidFormatException
-
nextArray
-
readNextObject
-
nextPair
-
nextValue
-