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

    Constructors
    Constructor
    Description
    No-argument constructor (for output to stdout).
    Constructor for output to given file.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Resets this to an initial value.
    final void
    Closes the stream.
    final boolean
    Reports whether the stream is open.
    final String
    Reports the name of the stream.
    Returns a new object with the same dynamic type as this, having an initial value.
    final void
    print(boolean b)
    Appends TO_STRING(b) to the end of this.content.
    final void
    print(char c)
    Appends <c> to the end of this.content.
    final void
    print(double d)
    Appends TO_STRING(d) to the end of this.content.
    final void
    print(double d, int precision, boolean scientific)
    Appends TO_STRING(d, precision, scientific) to the end of this.content.
    final void
    print(int i)
    Appends TO_STRING(i) to the end of this.content.
    final void
    print(long x)
    Appends TO_STRING(x) to the end of this.content.
    final void
    Appends the string representation of o to the end of this.content.
    final void
    Appends s to the end of this.content.
    final void
    Appends a line separator to the end of this.content.
    final void
    println(boolean b)
    Appends TO_STRING(b) and a line separator to the end of this.content.
    final void
    println(char c)
    Appends <c> and a line separator to the end of this.content.
    final void
    println(double d)
    Appends TO_STRING(d) and a line separator to the end of this.content.
    final void
    println(double d, int precision, boolean scientific)
    Appends TO_STRING(d, precision, scientific) and a line separator to the end of this.content.
    final void
    println(int i)
    Appends TO_STRING(i) and a line separator to the end of this.content.
    final void
    println(long x)
    Appends TO_STRING(x) and a line separator to the end of this.content.
    final void
    Appends the string representation of o and a line separator to the end of this.content.
    final void
    Appends s and a line separator to the end of this.content .
    final void
    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.
    final void
    write(char c)
    Appends <c> to the end of this.content without flushing the output buffer.

    Methods inherited from class components.simplewriter.SimpleWriterSecondary

    toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SimpleWriter1L

      public SimpleWriter1L()
      No-argument constructor (for output to stdout).
    • SimpleWriter1L

      public SimpleWriter1L(String fileName)
      Constructor for output to given file.
      Parameters:
      fileName - the name of the file to output to
  • Method Details

    • newInstance

      public final SimpleWriter 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(SimpleWriter 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
    • print

      public final void print(String s)
      Description copied from interface: SimpleWriter
      Appends s to the end of this.content.
      Parameters:
      s - the string to output
    • print

      public final void print(int i)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(i) to the end of this.content.
      Parameters:
      i - the integer to output
    • print

      public final void print(long x)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(x) to the end of this.content.
      Parameters:
      x - the long to output
    • print

      public final void print(double d)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(d) to the end of this.content.
      Parameters:
      d - the double to output
    • print

      public final void print(double d, int precision, boolean scientific)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(d, precision, scientific) to the end of this.content.
      Parameters:
      d - the double to output
      precision - the number of decimal digits printed
      scientific - whether to use scientific notation or not
    • print

      public final void print(boolean b)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(b) to the end of this.content.
      Parameters:
      b - the boolean to output
    • print

      public final void print(char c)
      Description copied from interface: SimpleWriter
      Appends <c> to the end of this.content.
      Parameters:
      c - the character to output
    • print

      public final void print(Object o)
      Description copied from interface: SimpleWriter
      Appends the string representation of o to the end of this.content.
      Parameters:
      o - the Object to output
    • println

      public final void println(String s)
      Description copied from interface: SimpleWriter
      Appends s and a line separator to the end of this.content .
      Parameters:
      s - the string to output
    • println

      public final void println(int i)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(i) and a line separator to the end of this.content.
      Parameters:
      i - the integer to output
    • println

      public final void println(long x)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(x) and a line separator to the end of this.content.
      Parameters:
      x - the long to output
    • println

      public final void println(double d)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(d) and a line separator to the end of this.content.
      Parameters:
      d - the double to output
    • println

      public final void println(double d, int precision, boolean scientific)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(d, precision, scientific) and a line separator to the end of this.content.
      Parameters:
      d - the double to output
      precision - the number of decimal digits printed
      scientific - whether to use scientific notation or not
    • println

      public final void println(boolean b)
      Description copied from interface: SimpleWriter
      Appends TO_STRING(b) and a line separator to the end of this.content.
      Parameters:
      b - the boolean to output
    • println

      public final void println(char c)
      Description copied from interface: SimpleWriter
      Appends <c> and a line separator to the end of this.content.
      Parameters:
      c - the character to output
    • println

      public final void println()
      Description copied from interface: SimpleWriter
      Appends a line separator to the end of this.content.
    • println

      public final void println(Object o)
      Description copied from interface: SimpleWriter
      Appends the string representation of o and a line separator to the end of this.content.
      Parameters:
      o - the Object to output
    • write

      public final void write(char c)
      Description copied from interface: SimpleWriterKernel
      Appends <c> to the end of this.content without flushing the output buffer.
      Parameters:
      c - the character to output
    • name

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

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

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