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
ConstructorsConstructorDescriptionNo-argument constructor (for input from stdin).SimpleReader1L(String name) Constructor for input from given file. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanatEOS()Reports whether the end of the stream has been reached.final voidclear()Resetsthisto an initial value.final voidclose()Closes the stream.final booleanisOpen()Reports whether the stream is open.final Stringname()Reports the name of the stream.final SimpleReaderReturns a new object with the same dynamic type asthis, having an initial value.final charpeek()Peeks a singlecharfromthis.content.final charread()Reads a singlecharfromthis.content.final voidtransferFrom(SimpleReader source) Setsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust 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:StandardReturns a new object with the same dynamic type asthis, having an initial value. If the typeThas a no-argument constructor, then the value of the new returned object satisfies the contract of the no-argument constructor forT. IfTdoes 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"
thiswith an initial value
-
clear
Description copied from interface:StandardResetsthisto an initial value. If the typeThas a no-argument constructor, thenthissatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thenthissatisfies the contract of the constructor call that was used to initialize#this. -
transferFrom
Description copied from interface:StandardSetsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust be the same as the dynamic type ofthis. If the typeThas a no-argument constructor, thensourcesatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thensourcesatisfies 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:SimpleReaderKernelReads a singlecharfromthis.content.- Returns:
- the
charread
-
peek
Description copied from interface:SimpleReaderKernelPeeks a singlecharfromthis.content.- Returns:
- the
charpeeked
-
name
Description copied from interface:SimpleReaderKernelReports the name of the stream.- Returns:
this.ext_name
-
isOpen
Description copied from interface:SimpleReaderKernelReports whether the stream is open.- Returns:
- true iff
thisis open
-
atEOS
Description copied from interface:SimpleReaderKernelReports whether the end of the stream has been reached.- Returns:
- true iff
thisis at end-of-stream
-
close
Description copied from interface:SimpleReaderKernelCloses the stream.
-