Package components.simplereader
Interface SimpleReader
- All Superinterfaces:
AutoCloseable,SimpleReaderKernel,Standard<SimpleReader>
- All Known Implementing Classes:
SimpleReader1L,SimpleReaderSecondary
SimpleReaderKernel enhanced with secondary methods.- Mathematical Definitions:
LINE_SEPARATOR: string of character is [character(s) used to denote line separator on the system where the input stream content was created]
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReads a line fromthis.content, up to and including the first line separator (or the end of the stream), where the string before the line separator is the string representation of aboolean, and returns thatboolean.doubleReads a line fromthis.content, up to and including the first line separator (or the end of the stream), where the string before the line separator is the string representation of adouble, and returns thatdouble.intReads a line fromthis.content, up to and including the first line separator (or the end of the stream), where the string before the line separator is the string representation of anint, and returns thatint.nextLine()Reads a line fromthis.content, up to and including the first line separator (or the end of the stream), and returns everything up to the line separator (if any).longnextLong()Reads a line fromthis.content, up to and including the first line separator (or the end of the stream), where the string before the line separator is the string representation of along, and returns thatlong.Methods inherited from interface components.simplereader.SimpleReaderKernel
atEOS, close, isOpen, name, peek, readMethods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Method Details
-
nextLine
Reads a line fromthis.content, up to and including the first line separator (or the end of the stream), and returns everything up to the line separator (if any).- Returns:
- the line read without the line separator
- Updates:
this.content- Requires:
this.is_open and this.content /= <>- Ensures:
if LINE_SEPARATOR is substring of #this.content then (#this.content = nextLine * LINE_SEPARATOR * this.content) else (nextLine = #this.content and this.content = <>)
-
nextInteger
int nextInteger()Reads a line fromthis.content, up to and including the first line separator (or the end of the stream), where the string before the line separator is the string representation of anint, and returns thatint.- Returns:
- the
intread - Updates:
this.content- Requires:
this.is_open and there exists i: integer (Integer.MIN_VALUE <= i and i <= Integer.MAX_VALUE and (TO_STRING(i) * LINE_SEPARATOR is prefix of this.content or TO_STRING(i) = this.content))- Ensures:
if LINE_SEPARATOR is substring of #this.content then (#this.content = TO_STRING(nextInteger) * LINE_SEPARATOR * this.content) else (TO_STRING(nextInteger) = #this.content and this.content = <>)
-
nextLong
long nextLong()Reads a line fromthis.content, up to and including the first line separator (or the end of the stream), where the string before the line separator is the string representation of along, and returns thatlong.- Returns:
- the
longread - Updates:
this.content- Requires:
this.is_open and there exists i: integer (Long.MIN_VALUE <= i and i <= Long.MAX_VALUE and (TO_STRING(i) * LINE_SEPARATOR is prefix of this.content or TO_STRING(i) = this.content))- Ensures:
if LINE_SEPARATOR is substring of #this.content then (#this.content = TO_STRING(nextLong) * LINE_SEPARATOR * this.content) else (TO_STRING(nextLong) = #this.content and this.content = <>)
-
nextBoolean
boolean nextBoolean()Reads a line fromthis.content, up to and including the first line separator (or the end of the stream), where the string before the line separator is the string representation of aboolean, and returns thatboolean.- Returns:
- the
booleanread - Updates:
this.content- Requires:
this.is_open and there exists b: boolean (TO_STRING(b) * LINE_SEPARATOR is prefix of this.content or TO_STRING(b) = this.content))- Ensures:
if LINE_SEPARATOR is substring of #this.content then (#this.content = TO_STRING(nextBoolean) * LINE_SEPARATOR * this.content) else (TO_STRING(nextBoolean) = #this.content and this.content = <>)
-
nextDouble
double nextDouble()Reads a line fromthis.content, up to and including the first line separator (or the end of the stream), where the string before the line separator is the string representation of adouble, and returns thatdouble.- Returns:
- the
doubleread - Updates:
this.content- Requires:
this.is_open and there exists d: real (Double.MIN_VALUE <= d and d <= Double.MAX_VALUE and (TO_STRING(d) * LINE_SEPARATOR is prefix of this.content or TO_STRING(d) = this.content))- Ensures:
if LINE_SEPARATOR is substring of #this.content then (#this.content = TO_STRING(nextDouble) * LINE_SEPARATOR * this.content) else (TO_STRING(nextDouble) = #this.content and this.content = <>)
-