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
ConstructorsConstructorDescriptionNo-argument constructor (for output to stdout).SimpleWriter1L(String fileName) Constructor for output to given file. -
Method Summary
Modifier and TypeMethodDescriptionfinal 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 SimpleWriterReturns a new object with the same dynamic type asthis, having an initial value.final voidprint(boolean b) AppendsTO_STRING(b)to the end ofthis.content.final voidprint(char c) Appends<c>to the end ofthis.content.final voidprint(double d) AppendsTO_STRING(d)to the end ofthis.content.final voidprint(double d, int precision, boolean scientific) AppendsTO_STRING(d, precision, scientific)to the end ofthis.content.final voidprint(int i) AppendsTO_STRING(i)to the end ofthis.content.final voidprint(long x) AppendsTO_STRING(x)to the end ofthis.content.final voidAppends the string representation ofoto the end ofthis.content.final voidAppendssto the end ofthis.content.final voidprintln()Appends a line separator to the end ofthis.content.final voidprintln(boolean b) AppendsTO_STRING(b)and a line separator to the end ofthis.content.final voidprintln(char c) Appends<c>and a line separator to the end ofthis.content.final voidprintln(double d) AppendsTO_STRING(d)and a line separator to the end ofthis.content.final voidprintln(double d, int precision, boolean scientific) AppendsTO_STRING(d, precision, scientific)and a line separator to the end ofthis.content.final voidprintln(int i) AppendsTO_STRING(i)and a line separator to the end ofthis.content.final voidprintln(long x) AppendsTO_STRING(x)and a line separator to the end ofthis.content.final voidAppends the string representation ofoand a line separator to the end ofthis.content.final voidAppendssand a line separator to the end ofthis.content.final voidtransferFrom(SimpleWriter 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.final voidwrite(char c) Appends<c>to the end ofthis.contentwithout 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: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
-
print
Description copied from interface:SimpleWriterAppendssto the end ofthis.content.- Parameters:
s- the string to output
-
print
Description copied from interface:SimpleWriterAppendsTO_STRING(i)to the end ofthis.content.- Parameters:
i- the integer to output
-
print
Description copied from interface:SimpleWriterAppendsTO_STRING(x)to the end ofthis.content.- Parameters:
x- the long to output
-
print
Description copied from interface:SimpleWriterAppendsTO_STRING(d)to the end ofthis.content.- Parameters:
d- the double to output
-
print
Description copied from interface:SimpleWriterAppendsTO_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:SimpleWriterAppendsTO_STRING(b)to the end ofthis.content.- Parameters:
b- the boolean to output
-
print
Description copied from interface:SimpleWriterAppends<c>to the end ofthis.content.- Parameters:
c- the character to output
-
print
Description copied from interface:SimpleWriterAppends the string representation ofoto the end ofthis.content.- Parameters:
o- the Object to output
-
println
Description copied from interface:SimpleWriterAppendssand a line separator to the end ofthis.content.- Parameters:
s- the string to output
-
println
Description copied from interface:SimpleWriterAppendsTO_STRING(i)and a line separator to the end ofthis.content.- Parameters:
i- the integer to output
-
println
Description copied from interface:SimpleWriterAppendsTO_STRING(x)and a line separator to the end ofthis.content.- Parameters:
x- the long to output
-
println
Description copied from interface:SimpleWriterAppendsTO_STRING(d)and a line separator to the end ofthis.content.- Parameters:
d- the double to output
-
println
Description copied from interface:SimpleWriterAppendsTO_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:SimpleWriterAppendsTO_STRING(b)and a line separator to the end ofthis.content.- Parameters:
b- the boolean to output
-
println
Description copied from interface:SimpleWriterAppends<c>and a line separator to the end ofthis.content.- Parameters:
c- the character to output
-
println
Description copied from interface:SimpleWriterAppends a line separator to the end ofthis.content. -
println
Description copied from interface:SimpleWriterAppends the string representation ofoand a line separator to the end ofthis.content.- Parameters:
o- the Object to output
-
write
Description copied from interface:SimpleWriterKernelAppends<c>to the end ofthis.contentwithout flushing the output buffer.- Parameters:
c- the character to output
-
name
Description copied from interface:SimpleWriterKernelReports the name of the stream.- Returns:
this.ext_name
-
isOpen
Description copied from interface:SimpleWriterKernelReports whether the stream is open.- Returns:
- true iff
thisis open
-
close
Description copied from interface:SimpleWriterKernelCloses the stream.
-