Package components.simplewriter
Class SimpleWriter1L
java.lang.Object
components.simplewriter.SimpleWriterSecondary
components.simplewriter.SimpleWriter1L
- All Implemented Interfaces:
SimpleWriter
,SimpleWriterKernel
,Standard<SimpleWriter>
,AutoCloseable
SimpleWriter
represented as java.io.PrintWriter
with implementations of primary methods.- Representation Invariant (concrete invariant of $this):
[$this.rep is not null when the stream is open]
- Abstraction Relation (interpretation mapping between $this and this):
this.is_open = [$this.rep is open] and this.ext_name = $this.name and this.contents = [the contents of $this.rep]
-
Constructor Summary
ConstructorDescriptionNo-argument constructor (for output to stdout).SimpleWriter1L
(String fileName) Constructor for output to given file. -
Method Summary
Modifier and TypeMethodDescriptionfinal 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 SimpleWriter
Returns a new object with the same dynamic type asthis
, having an initial value.final void
print
(boolean b) AppendsTO_STRING(b)
to the end ofthis.content
.final void
print
(char c) Appends<c>
to the end ofthis.content
.final void
print
(double d) AppendsTO_STRING(d)
to the end ofthis.content
.final void
print
(double d, int precision, boolean scientific) AppendsTO_STRING(d, precision, scientific)
to the end ofthis.content
.final void
print
(int i) AppendsTO_STRING(i)
to the end ofthis.content
.final void
print
(long x) AppendsTO_STRING(x)
to the end ofthis.content
.final void
Appends the string representation ofo
to the end ofthis.content
.final void
Appendss
to the end ofthis.content
.final void
println()
Appends a line separator to the end ofthis.content
.final void
println
(boolean b) AppendsTO_STRING(b)
and a line separator to the end ofthis.content
.final void
println
(char c) Appends<c>
and a line separator to the end ofthis.content
.final void
println
(double d) AppendsTO_STRING(d)
and a line separator to the end ofthis.content
.final void
println
(double d, int precision, boolean scientific) AppendsTO_STRING(d, precision, scientific)
and a line separator to the end ofthis.content
.final void
println
(int i) AppendsTO_STRING(i)
and a line separator to the end ofthis.content
.final void
println
(long x) AppendsTO_STRING(x)
and a line separator to the end ofthis.content
.final void
Appends the string representation ofo
and a line separator to the end ofthis.content
.final void
Appendss
and a line separator to the end ofthis.content
.final void
transferFrom
(SimpleWriter 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
.final void
write
(char c) Appends<c>
to the end ofthis.content
without flushing the output buffer.Methods inherited from class components.simplewriter.SimpleWriterSecondary
toString
-
Constructor Details
-
SimpleWriter1L
public SimpleWriter1L()No-argument constructor (for output to stdout). -
SimpleWriter1L
Constructor for output to given file.- Parameters:
fileName
- the name of the file to output to
-
-
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
-
print
Description copied from interface:SimpleWriter
Appendss
to the end ofthis.content
.- Parameters:
s
- the string to output
-
print
Description copied from interface:SimpleWriter
AppendsTO_STRING(i)
to the end ofthis.content
.- Parameters:
i
- the integer to output
-
print
Description copied from interface:SimpleWriter
AppendsTO_STRING(x)
to the end ofthis.content
.- Parameters:
x
- the long to output
-
print
Description copied from interface:SimpleWriter
AppendsTO_STRING(d)
to the end ofthis.content
.- Parameters:
d
- the double to output
-
print
Description copied from interface:SimpleWriter
AppendsTO_STRING(d, precision, scientific)
to the end ofthis.content
.- Parameters:
d
- the double to outputprecision
- the number of decimal digits printedscientific
- whether to use scientific notation or not
-
print
Description copied from interface:SimpleWriter
AppendsTO_STRING(b)
to the end ofthis.content
.- Parameters:
b
- the boolean to output
-
print
Description copied from interface:SimpleWriter
Appends<c>
to the end ofthis.content
.- Parameters:
c
- the character to output
-
print
Description copied from interface:SimpleWriter
Appends the string representation ofo
to the end ofthis.content
.- Parameters:
o
- the Object to output
-
println
Description copied from interface:SimpleWriter
Appendss
and a line separator to the end ofthis.content
.- Parameters:
s
- the string to output
-
println
Description copied from interface:SimpleWriter
AppendsTO_STRING(i)
and a line separator to the end ofthis.content
.- Parameters:
i
- the integer to output
-
println
Description copied from interface:SimpleWriter
AppendsTO_STRING(x)
and a line separator to the end ofthis.content
.- Parameters:
x
- the long to output
-
println
Description copied from interface:SimpleWriter
AppendsTO_STRING(d)
and a line separator to the end ofthis.content
.- Parameters:
d
- the double to output
-
println
Description copied from interface:SimpleWriter
AppendsTO_STRING(d, precision, scientific)
and a line separator to the end ofthis.content
.- Parameters:
d
- the double to outputprecision
- the number of decimal digits printedscientific
- whether to use scientific notation or not
-
println
Description copied from interface:SimpleWriter
AppendsTO_STRING(b)
and a line separator to the end ofthis.content
.- Parameters:
b
- the boolean to output
-
println
Description copied from interface:SimpleWriter
Appends<c>
and a line separator to the end ofthis.content
.- Parameters:
c
- the character to output
-
println
Description copied from interface:SimpleWriter
Appends a line separator to the end ofthis.content
. -
println
Description copied from interface:SimpleWriter
Appends the string representation ofo
and a line separator to the end ofthis.content
.- Parameters:
o
- the Object to output
-
write
Description copied from interface:SimpleWriterKernel
Appends<c>
to the end ofthis.content
without flushing the output buffer.- Parameters:
c
- the character to output
-
name
Description copied from interface:SimpleWriterKernel
Reports the name of the stream.- Returns:
this.ext_name
-
isOpen
Description copied from interface:SimpleWriterKernel
Reports whether the stream is open.- Returns:
- true iff
this
is open
-
close
Description copied from interface:SimpleWriterKernel
Closes the stream.
-