Class PrettyTuplePrinter

  • All Implemented Interfaces:
    TupleProcessor

    public class PrettyTuplePrinter
    extends java.lang.Object
    implements TupleProcessor
    This implementation of the tuple-processor interface prints out the schema and the tuples produced by the SELECT statement in a cooler, prettier fashion.
    Author:
    Angela Gong
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.ArrayList<ColumnType> colTypes
      Stores the column type for each column
      private java.util.ArrayList<java.lang.Integer> colWidths
      Stores the maximum column widths for each column
      private int numColumns
      The number of columns to print
      private java.io.PrintStream out  
      (package private) PrettyPrintTools pTools
      Tools to aid in pretty printing
      private java.util.ArrayList<java.lang.String> schema
      Contains the schema to be printed
      private java.util.ArrayList<java.lang.String> tuples
      Contains all the tuples to be printed
    • Constructor Summary

      Constructors 
      Constructor Description
      PrettyTuplePrinter​(java.io.PrintStream out)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void finish()
      This function is called when all tuples have been produced and passed to the tuple processor.
      void process​(Tuple tuple)
      Processes a single tuple generated from evaluating a query plan.
      void setSchema​(Schema schema)
      This method is called once by the query evaluator before any tuples are passed to the TupleProcessor.process(edu.caltech.nanodb.relations.Tuple) method, so that the tuple-processor knows what the expected tuple-schema will be.
      • Methods inherited from class java.lang.Object

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

      • out

        private java.io.PrintStream out
      • schema

        private java.util.ArrayList<java.lang.String> schema
        Contains the schema to be printed
      • tuples

        private java.util.ArrayList<java.lang.String> tuples
        Contains all the tuples to be printed
      • colWidths

        private java.util.ArrayList<java.lang.Integer> colWidths
        Stores the maximum column widths for each column
      • colTypes

        private java.util.ArrayList<ColumnType> colTypes
        Stores the column type for each column
      • numColumns

        private int numColumns
        The number of columns to print
    • Constructor Detail

      • PrettyTuplePrinter

        public PrettyTuplePrinter​(java.io.PrintStream out)