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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Throwableprotected Stringprotected booleanprotected Stringprotected AbstractSvetovidReader.TokenTypeprotected Pattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this reader and releases any resources associated with the underlying source.protected abstract StringReturns 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 voidhandleAnyException(Throwable exception) protected voidhandleFormatException(SvetovidFormatException exception) booleanhasMore()Checks whether this reader has data to be read.protected booleanisCharInNumber(char ch) protected booleanisCharWhitespace(char ch) protected booleanisCharWhitespaceOrSymbol(char ch) booleanisEmpty()Checks whether this reader has no more data to be read.booleanReturns the indicator whether this reader will throw exceptions on I/O operation errors or just return default values.protected charnextChar()protected Booleanprotected NumbernextPair()protected Stringprotected voidprotected Objectprotected booleanprotected charreadAll()Reads all remaining content and returns it as a string.String[]Read all remaining lines and returns them as an array of strings.booleanreadBool()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.bytereadByte()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.charreadChar()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.doubleReads 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.floatReads 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.intreadInt()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.longreadLong()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.shortReads 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 voidreturnChar(char ch) voidsetThrowingExceptions(boolean shouldThrow) Configures whether this reader should throw exceptions on I/O operation errors or just return default values.voidsetWhitespace(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:SvetovidReaderReturns 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:
getWhitespacein interfaceSvetovidReader- Returns:
- the pattern currently used to recognize whitespace.
- See Also:
-
setWhitespace
Description copied from interface:SvetovidReaderSets 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:
setWhitespacein interfaceSvetovidReader- Parameters:
whitespace- the pattern to use recognize whitespace- See Also:
-
isThrowingExceptions
public boolean isThrowingExceptions()Description copied from interface:SvetovidReaderReturns the indicator whether this reader will throw exceptions on I/O operation errors or just return default values.- Specified by:
isThrowingExceptionsin interfaceSvetovidReader- Returns:
trueif this reader throws exceptions on failed I/O operations;falseotherwise.
-
setThrowingExceptions
public void setThrowingExceptions(boolean shouldThrow) Description copied from interface:SvetovidReaderConfigures whether this reader should throw exceptions on I/O operation errors or just return default values.- Specified by:
setThrowingExceptionsin interfaceSvetovidReader- Parameters:
shouldThrow-trueif this reader should throw exceptions on failed I/O operations in the future;falseif it should return default values.
-
getLastException
Description copied from interface:SvetovidReaderReturns the exception raised in the last operation; if the operation was successful and no exception was raised, returnsnull.- Specified by:
getLastExceptionin interfaceSvetovidReader- Returns:
- the exception raised in the last operation or
nullit 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:SvetovidReaderChecks whether this reader has no more data to be read.- Specified by:
isEmptyin interfaceSvetovidReader- Returns:
trueif this reader has no more data to be read;falseotherwise.
-
hasMore
public boolean hasMore()Description copied from interface:SvetovidReaderChecks whether this reader has data to be read.- Specified by:
hasMorein interfaceSvetovidReader- Returns:
trueif this reader has data to be read;falseotherwise.
-
close
Description copied from interface:SvetovidReaderCloses this reader and releases any resources associated with the underlying source. The general contract ofcloseis that it closes the input source. A closed source cannot perform input operations and cannot be reopened.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSvetovidReader- Throws:
SvetovidIOException- if an error occurred during the operation.
-
readBool
Description copied from interface:SvetovidReaderReads one token and converts it to a boolean value.- Specified by:
readBoolin interfaceSvetovidReader- Returns:
- the
booleanvalue 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:SvetovidReaderReads one token and converts it to a byte value.- Specified by:
readBytein interfaceSvetovidReader- Returns:
- the
bytevalue read. - Throws:
SvetovidFormatException- if the token is not a parsable byte.SvetovidIOException- if an error occurred during the operation.
-
readShort
Description copied from interface:SvetovidReaderReads one token and converts it to a short integer value.- Specified by:
readShortin interfaceSvetovidReader- Returns:
- the
shortvalue read. - Throws:
SvetovidFormatException- if the token is not a parsable short.SvetovidIOException- if an error occurred during the operation.
-
readInt
Description copied from interface:SvetovidReaderReads one token and converts it to an integer value.- Specified by:
readIntin interfaceSvetovidReader- Returns:
- the
intvalue read. - Throws:
SvetovidFormatException- if the token is not a parsable int.SvetovidIOException- if an error occurred during the operation.
-
readLong
Description copied from interface:SvetovidReaderReads one token and converts it to a long integer value.- Specified by:
readLongin interfaceSvetovidReader- Returns:
- the
longvalue read. - Throws:
SvetovidFormatException- if the token is not a parsable long.SvetovidIOException- if an error occurred during the operation.
-
readFloat
Description copied from interface:SvetovidReaderReads one token and converts it to a floating-point value.- Specified by:
readFloatin interfaceSvetovidReader- Returns:
- the
floatvalue read. - Throws:
SvetovidFormatException- if the token is not a parsable float.SvetovidIOException- if an error occurred during the operation.
-
readDouble
Description copied from interface:SvetovidReaderReads one token and converts it to a double-precision floating-point value.- Specified by:
readDoublein interfaceSvetovidReader- Returns:
- the
doublevalue read. - Throws:
SvetovidFormatException- if the token is not a parsable double.SvetovidIOException- if an error occurred during the operation.
-
readChar
Description copied from interface:SvetovidReaderReads one token and converts it to a character value.- Specified by:
readCharin interfaceSvetovidReader- Returns:
- the
charvalue 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:SvetovidReaderReads one token and returns it as a string value.- Specified by:
readTokenin interfaceSvetovidReader- Returns:
- the
Stringvalue read. - Throws:
SvetovidIOException- if an error occurred during the operation.
-
readBoolBoxed
Description copied from interface:SvetovidReaderReads one token and converts it to a boolean value.- Specified by:
readBoolBoxedin interfaceSvetovidReader- Returns:
- the
Booleanvalue read. - Throws:
SvetovidFormatException- if the token is not a parsable boolean.SvetovidIOException- if an error occurred during the operation.
-
readByteBoxed
Description copied from interface:SvetovidReaderReads one token and converts it to a byte value.- Specified by:
readByteBoxedin interfaceSvetovidReader- Returns:
- the
Bytevalue read. - Throws:
SvetovidFormatException- if the token is not a parsable byte.SvetovidIOException- if an error occurred during the operation.
-
readShortBoxed
Description copied from interface:SvetovidReaderReads one token and converts it to a short integer value.- Specified by:
readShortBoxedin interfaceSvetovidReader- Returns:
- the
Shortvalue read. - Throws:
SvetovidFormatException- if the token is not a parsable short.SvetovidIOException- if an error occurred during the operation.
-
readIntBoxed
Description copied from interface:SvetovidReaderReads one token and converts it to an integer value.- Specified by:
readIntBoxedin interfaceSvetovidReader- Returns:
- the
Integervalue read. - Throws:
SvetovidFormatException- if the token is not a parsable int.SvetovidIOException- if an error occurred during the operation.
-
readLongBoxed
Description copied from interface:SvetovidReaderReads one token and converts it to a long integer value.- Specified by:
readLongBoxedin interfaceSvetovidReader- Returns:
- the
Longvalue read. - Throws:
SvetovidFormatException- if the token is not a parsable long.SvetovidIOException- if an error occurred during the operation.
-
readFloatBoxed
Description copied from interface:SvetovidReaderReads one token and converts it to a floating-point value.- Specified by:
readFloatBoxedin interfaceSvetovidReader- Returns:
- the
Floatvalue read. - Throws:
SvetovidFormatException- if the token is not a parsable float.SvetovidIOException- if an error occurred during the operation.
-
readDoubleBoxed
Description copied from interface:SvetovidReaderReads one token and converts it to a double-precision floating-point value.- Specified by:
readDoubleBoxedin interfaceSvetovidReader- Returns:
- the
Doublevalue read. - Throws:
SvetovidFormatException- if the token is not a parsable double.SvetovidIOException- if an error occurred during the operation.
-
readCharBoxed
Description copied from interface:SvetovidReaderReads one token and converts it to a character value.- Specified by:
readCharBoxedin interfaceSvetovidReader- Returns:
- the
Charactervalue read. - Throws:
SvetovidFormatException- if the token is not a parsable character.SvetovidIOException- if an error occurred during the operation.
-
readBoolArray
Description copied from interface:SvetovidReaderReads one line, separates it into tokens and converts them to boolean values.- Specified by:
readBoolArrayin interfaceSvetovidReader- Returns:
- an array of
booleanvalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to byte values.- Specified by:
readByteArrayin interfaceSvetovidReader- Returns:
- an array of
bytevalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to short integer values.- Specified by:
readShortArrayin interfaceSvetovidReader- Returns:
- an array of
shortvalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to integer values.- Specified by:
readIntArrayin interfaceSvetovidReader- Returns:
- an array of
intvalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to long integer values.- Specified by:
readLongArrayin interfaceSvetovidReader- Returns:
- an array of
longvalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to floating-point values.- Specified by:
readFloatArrayin interfaceSvetovidReader- Returns:
- an array of
floatvalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to double-precision floating-point values.- Specified by:
readDoubleArrayin interfaceSvetovidReader- Returns:
- an array of
doublevalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to character values.- Specified by:
readCharArrayin interfaceSvetovidReader- Returns:
- an array of
charvalues 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:SvetovidReaderReads one line, separates it into tokens and returns them as string values.- Specified by:
readTokenArrayin interfaceSvetovidReader- Returns:
- an array of
Stringvalues read. - Throws:
SvetovidIOException- if an error occurred during the operation.SvetovidFormatException
-
readBoolArrayBoxed
Description copied from interface:SvetovidReaderReads one line, separates it into tokens and converts them to boolean values.- Specified by:
readBoolArrayBoxedin interfaceSvetovidReader- Returns:
- an array of
Booleanvalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to byte values.- Specified by:
readByteArrayBoxedin interfaceSvetovidReader- Returns:
- an array of
Bytevalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to short integer values.- Specified by:
readShortArrayBoxedin interfaceSvetovidReader- Returns:
- an array of
Shortvalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to integer values.- Specified by:
readIntArrayBoxedin interfaceSvetovidReader- Returns:
- an array of
Integervalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to long integer values.- Specified by:
readLongArrayBoxedin interfaceSvetovidReader- Returns:
- an array of
Longvalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to floating-point values.- Specified by:
readFloatArrayBoxedin interfaceSvetovidReader- Returns:
- an array of
Floatvalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to double-precision floating-point values.- Specified by:
readDoubleArrayBoxedin interfaceSvetovidReader- Returns:
- an array of
Doublevalues 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:SvetovidReaderReads one line, separates it into tokens and converts them to character values.- Specified by:
readCharArrayBoxedin interfaceSvetovidReader- Returns:
- an array of
Charactervalues 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:SvetovidReaderReads 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:
readLinein interfaceSvetovidReader- Returns:
- A
Stringcontaining 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:SvetovidReaderRead 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:
readAllLinesin interfaceSvetovidReader- Returns:
- A
Stringarray 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:SvetovidReaderReads all remaining content and returns it as a string.- Specified by:
readAllin interfaceSvetovidReader- Returns:
- A
Stringcontaining 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:SvetovidReaderReads 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:
readBoolMatrixin interfaceSvetovidReader- Returns:
- a matrix of
booleanvalues 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:SvetovidReaderReads 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:
readByteMatrixin interfaceSvetovidReader- Returns:
- a matrix of
bytevalues 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:SvetovidReaderReads 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:
readShortMatrixin interfaceSvetovidReader- Returns:
- a matrix of
shortvalues 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:SvetovidReaderReads 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:
readIntMatrixin interfaceSvetovidReader- Returns:
- a matrix of
intvalues 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:SvetovidReaderReads 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:
readLongMatrixin interfaceSvetovidReader- Returns:
- a matrix of
longvalues 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:SvetovidReaderReads 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:
readFloatMatrixin interfaceSvetovidReader- Returns:
- a matrix of
floatvalues 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:SvetovidReaderReads 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:
readDoubleMatrixin interfaceSvetovidReader- Returns:
- a matrix of
doublevalues 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:SvetovidReaderReads 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:
readCharMatrixin interfaceSvetovidReader- Returns:
- a matrix of
charvalues 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:SvetovidReaderReads 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:
readTokenMatrixin interfaceSvetovidReader- Returns:
- a matrix of
Stringvalues read. - Throws:
SvetovidIOException- if an error occurred during the operation.
-
readBoolMatrixBoxed
Description copied from interface:SvetovidReaderReads 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:
readBoolMatrixBoxedin interfaceSvetovidReader- Returns:
- a matrix of
Booleanvalues 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:SvetovidReaderReads 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:
readByteMatrixBoxedin interfaceSvetovidReader- Returns:
- a matrix of
Bytevalues 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:SvetovidReaderReads 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:
readShortMatrixBoxedin interfaceSvetovidReader- Returns:
- a matrix of
Shortvalues 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:SvetovidReaderReads 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:
readIntMatrixBoxedin interfaceSvetovidReader- Returns:
- a matrix of
Integervalues 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:SvetovidReaderReads 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:
readLongMatrixBoxedin interfaceSvetovidReader- Returns:
- a matrix of
Longvalues 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:SvetovidReaderReads 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:
readFloatMatrixBoxedin interfaceSvetovidReader- Returns:
- a matrix of
Floatvalues 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:SvetovidReaderReads 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:
readDoubleMatrixBoxedin interfaceSvetovidReader- Returns:
- a matrix of
Doublevalues 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:SvetovidReaderReads 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:
readCharMatrixBoxedin interfaceSvetovidReader- Returns:
- a matrix of
Charactervalues 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:SvetovidReaderReads a JSON (JavaScript Object Notation) formatted object.The object is converted to Java types using the following rules:
- literal
nullis converted to Javanull, - literals
trueandfalseare converted toBoolean.TRUEandBoolean.FALSErespectively, - 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
Stringvalues, - arrays are converted to
Lists containing the held values in the same order - and objects are converted to
Maps 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:
readObjectin 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:
SvetovidIOExceptionEOFException
-
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
-