Package components.simplereader
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 Summary
ConstructorDescriptionNo-argument constructor (for input from stdin).SimpleReader1L
(String name) Constructor for input from given file. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
atEOS()
Reports whether the end of the stream has been reached.final void
clear()
Resetsthis
to an initial value.final void
close()
Closes the stream.final boolean
isOpen()
Reports whether the stream is open.final String
name()
Reports the name of the stream.final SimpleReader
Returns a new object with the same dynamic type asthis
, having an initial value.final char
peek()
Peeks a singlechar
fromthis.content
.final char
read()
Reads a singlechar
fromthis.content
.final void
transferFrom
(SimpleReader source) Setsthis
to the incoming value ofsource
, and resetssource
to an initial value; the declaration notwithstanding, the dynamic type ofsource
must be the same as the dynamic type ofthis
.Methods inherited from class components.simplereader.SimpleReaderSecondary
nextBoolean, nextDouble, nextInteger, nextLine, nextLong, toString
-
Constructor Details
-
SimpleReader1L
public SimpleReader1L()No-argument constructor (for input from stdin). -
SimpleReader1L
Constructor for input from given file.- Parameters:
name
- the name of the file or of a URL to input from
-
-
Method Details
-
newInstance
Description copied from interface:Standard
Returns a new object with the same dynamic type asthis
, having an initial value. If the typeT
has a no-argument constructor, then the value of the new returned object satisfies the contract of the no-argument constructor forT
. IfT
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 initializethis
.- Returns:
- new object "like"
this
with an initial value
-
clear
Description copied from interface:Standard
Resetsthis
to an initial value. If the typeT
has a no-argument constructor, thenthis
satisfies the contract of the no-argument constructor forT
. IfT
does not have a no-argument constructor, thenthis
satisfies the contract of the constructor call that was used to initialize#this
. -
transferFrom
Description copied from interface:Standard
Setsthis
to the incoming value ofsource
, and resetssource
to an initial value; the declaration notwithstanding, the dynamic type ofsource
must be the same as the dynamic type ofthis
. If the typeT
has a no-argument constructor, thensource
satisfies the contract of the no-argument constructor forT
. IfT
does not have a no-argument constructor, thensource
satisfies the contract of the constructor call that was used to initialize#source
.- Parameters:
source
- object whose value is to be transferred
-
read
Description copied from interface:SimpleReaderKernel
Reads a singlechar
fromthis.content
.- Returns:
- the
char
read
-
peek
Description copied from interface:SimpleReaderKernel
Peeks a singlechar
fromthis.content
.- Returns:
- the
char
peeked
-
name
Description copied from interface:SimpleReaderKernel
Reports the name of the stream.- Returns:
this.ext_name
-
isOpen
Description copied from interface:SimpleReaderKernel
Reports whether the stream is open.- Returns:
- true iff
this
is open
-
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
Description copied from interface:SimpleReaderKernel
Closes the stream.
-