Interface SimpleReader

All Superinterfaces:
AutoCloseable, SimpleReaderKernel, Standard<SimpleReader>
All Known Implementing Classes:
SimpleReader1L, SimpleReaderSecondary

public interface SimpleReader extends SimpleReaderKernel
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 Type
    Method
    Description
    boolean
    Reads a line from this.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 a boolean, and returns that boolean.
    double
    Reads a line from this.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 a double, and returns that double.
    int
    Reads a line from this.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 an int, and returns that int.
    Reads a line from this.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).
    long
    Reads a line from this.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 a long, and returns that long.

    Methods inherited from interface components.simplereader.SimpleReaderKernel

    atEOS, close, isOpen, name, peek, read

    Methods inherited from interface components.standard.Standard

    clear, newInstance, transferFrom
  • Method Details

    • nextLine

      Reads a line from this.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

      Reads a line from this.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 an int, and returns that int.
      Returns:
      the int read
      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 from this.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 a long, and returns that long.
      Returns:
      the long read
      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 from this.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 a boolean, and returns that boolean.
      Returns:
      the boolean read
      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 from this.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 a double, and returns that double.
      Returns:
      the double read
      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 = <>)