Class AbstractWriter

  • Direct Known Subclasses:
    ExpressionWriter, StreamTracer

    public abstract class AbstractWriter
    extends java.lang.Object
    An abstract class for writing an object model as a textual output.
    Author:
    Holger Eichelberger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.StringBuilder actualIndentation  
      private java.lang.String indentation  
      private java.io.PrintWriter out  
      private char whitespace  
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractWriter​(java.io.Writer out)
      Creates a build language writer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void decreaseIndentation()
      Decreases the current indentation step.
      void flush()
      Flushes the writer.
      protected java.io.Writer getOut()
      Returns the underlying writer.
      protected void increaseIndentation()
      Increases the current indentation step.
      protected void print​(char ch)
      Prints a character.
      protected void print​(int value)
      Prints an integer.
      protected void print​(java.lang.Object object)
      Prints an object.
      protected void print​(java.lang.String string)
      Prints a string.
      protected void printIndentation()
      Prints the indentation.
      protected void printJavaEscaped​(java.lang.String string)
      Prints a Java-escaped string.
      protected void println()
      Prints a newline.
      protected void println​(char ch)
      Prints a character with trailing newline.
      protected void println​(int value)
      Prints an integer with trailing newline.
      protected void println​(java.lang.Object object)
      Prints an object with trailing newline.
      protected void println​(java.lang.String string)
      Prints a string with trailing newline.
      protected void printWhitespace()
      Prints a whitespace character.
      void setIndentation​(java.lang.String indentation)
      Defines an indentation step.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • actualIndentation

        private java.lang.StringBuilder actualIndentation
      • whitespace

        private char whitespace
      • indentation

        private java.lang.String indentation
      • out

        private java.io.PrintWriter out
    • Constructor Detail

      • AbstractWriter

        public AbstractWriter​(java.io.Writer out)
        Creates a build language writer.
        Parameters:
        out - the writer to write the elements to
    • Method Detail

      • getOut

        protected java.io.Writer getOut()
        Returns the underlying writer.
        Returns:
        the underlying writer
      • print

        protected void print​(java.lang.String string)
        Prints a string.
        Parameters:
        string - the string to be printed
      • printJavaEscaped

        protected void printJavaEscaped​(java.lang.String string)
        Prints a Java-escaped string.
        Parameters:
        string - the string to be printed
      • println

        protected void println​(java.lang.String string)
        Prints a string with trailing newline.
        Parameters:
        string - the string to be printed
      • print

        protected void print​(char ch)
        Prints a character.
        Parameters:
        ch - the character to be printed
      • println

        protected void println​(char ch)
        Prints a character with trailing newline.
        Parameters:
        ch - the character to be printed
      • print

        protected void print​(int value)
        Prints an integer.
        Parameters:
        value - the integer
      • println

        protected void println​(int value)
        Prints an integer with trailing newline.
        Parameters:
        value - the integer
      • print

        protected void print​(java.lang.Object object)
        Prints an object.
        Parameters:
        object - the object to be printed
      • println

        protected void println​(java.lang.Object object)
        Prints an object with trailing newline.
        Parameters:
        object - the object to be printed
      • println

        protected void println()
        Prints a newline.
      • printIndentation

        protected final void printIndentation()
        Prints the indentation.
      • printWhitespace

        protected final void printWhitespace()
        Prints a whitespace character.
      • flush

        public final void flush()
                         throws java.io.IOException
        Flushes the writer. Should be used if there aren't any more elements to read.
        Throws:
        java.io.IOException - If an I/O error occurs
      • setIndentation

        public void setIndentation​(java.lang.String indentation)
        Defines an indentation step.
        Parameters:
        indentation - the indentation step
      • increaseIndentation

        protected void increaseIndentation()
        Increases the current indentation step.
      • decreaseIndentation

        protected void decreaseIndentation()
        Decreases the current indentation step.