Class SimpleReader1L

java.lang.Object
components.simplereader.SimpleReaderSecondary
components.simplereader.SimpleReader1L
All Implemented Interfaces:
SimpleReader, SimpleReaderKernel, Standard<SimpleReader>, AutoCloseable

SimpleReader represented as java.io.BufferedReader with implementations of primary methods.
Representation Invariant (concrete invariant of $this):
[$this.rep is not null when the stream is open and
 lookAheadIsValid is true iff the contents of $this.rep is not <>]
Abstraction Relation (interpretation mapping between $this and this):
this.is_open = [$this.rep is open] and
 this.ext_name = $this.name and
 if $this.lookAheadIsValid then
   this.contents = [$this.lookAhead * the contents of $this.rep]
 else
   this.contents = [the contents of $this.rep]
  • Constructor Details

    • SimpleReader1L

      public SimpleReader1L()
      No-argument constructor (for input from stdin).
    • SimpleReader1L

      public SimpleReader1L(String name)
      Constructor for input from given file.
      Parameters:
      name - the name of the file or of a URL to input from
  • Method Details

    • newInstance

      public final SimpleReader newInstance()
      Description copied from interface: Standard
      Returns a new object with the same dynamic type as this, having an initial value. If the type T has a no-argument constructor, then the value of the new returned object satisfies the contract of the no-argument constructor for T. If T does not have a no-argument constructor, then the value of the new returned object satisfies the contract of the constructor call that was used to initialize this .
      Returns:
      new object "like" this with an initial value
    • clear

      public final void clear()
      Description copied from interface: Standard
      Resets this to an initial value. If the type T has a no-argument constructor, then this satisfies the contract of the no-argument constructor for T. If T does not have a no-argument constructor, then this satisfies the contract of the constructor call that was used to initialize #this.
    • transferFrom

      public final void transferFrom(SimpleReader source)
      Description copied from interface: Standard
      Sets this to the incoming value of source, and resets source to an initial value; the declaration notwithstanding, the dynamic type of source must be the same as the dynamic type of this. If the type T has a no-argument constructor, then source satisfies the contract of the no-argument constructor for T. If T does not have a no-argument constructor, then source satisfies the contract of the constructor call that was used to initialize #source.
      Parameters:
      source - object whose value is to be transferred
    • read

      public final char read()
      Description copied from interface: SimpleReaderKernel
      Reads a single char from this.content.
      Returns:
      the char read
    • peek

      public final char peek()
      Description copied from interface: SimpleReaderKernel
      Peeks a single char from this.content.
      Returns:
      the char peeked
    • name

      public final String name()
      Description copied from interface: SimpleReaderKernel
      Reports the name of the stream.
      Returns:
      this.ext_name
    • isOpen

      public final boolean isOpen()
      Description copied from interface: SimpleReaderKernel
      Reports whether the stream is open.
      Returns:
      true iff this is open
    • atEOS

      public final boolean atEOS()
      Description copied from interface: SimpleReaderKernel
      Reports whether the end of the stream has been reached.
      Returns:
      true iff this is at end-of-stream
    • close

      public final void close()
      Description copied from interface: SimpleReaderKernel
      Closes the stream.