Package edu.caltech.nanodb.queryeval
Class PrettyPrintTools
- java.lang.Object
-
- edu.caltech.nanodb.queryeval.PrettyPrintTools
-
public class PrettyPrintTools extends java.lang.Object
Various methods to use for pretty-printing, such as delimiters, padding, and such.- Author:
- Angela Gong
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<ColumnType>
colTypes
Stores the column type for each columnprivate java.util.ArrayList<java.lang.Integer>
colWidths
Stores the maximum column widths for each columnprivate int
numColumns
The number of columns to printprivate java.io.PrintStream
out
-
Constructor Summary
Constructors Constructor Description PrettyPrintTools(java.io.PrintStream out, java.util.ArrayList<java.lang.Integer> colWidths, java.util.ArrayList<ColumnType> colTypes, int numColumns)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkColumnWidths(java.lang.String str, int col)
Changes the maximum column width stored if necessaryint
getColumnWidth(int index)
Gets the width of a specified column.java.lang.String
padString(java.lang.Integer colWidth, java.lang.String str)
Pads a string with the spaces on either end necessary when printing.java.lang.String
padString(java.lang.Integer colWidth, java.lang.String str, int index)
Pads a string with the spaces on either end necessary when printing.void
printDelimiter()
Prints the delimiter, i.e.
-
-
-
Field Detail
-
out
private java.io.PrintStream out
-
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
-
PrettyPrintTools
public PrettyPrintTools(java.io.PrintStream out, java.util.ArrayList<java.lang.Integer> colWidths, java.util.ArrayList<ColumnType> colTypes, int numColumns)
-
-
Method Detail
-
printDelimiter
public void printDelimiter()
Prints the delimiter, i.e. the "+-------+--------+" portion.
-
getColumnWidth
public int getColumnWidth(int index)
Gets the width of a specified column.- Parameters:
index
- the index of the colujmn- Returns:
- the column width
-
padString
public java.lang.String padString(java.lang.Integer colWidth, java.lang.String str)
Pads a string with the spaces on either end necessary when printing.- Parameters:
colWidth
- the width of the column the string will be printed instr
- the string to be printed- Returns:
- the newly-padded string
-
padString
public java.lang.String padString(java.lang.Integer colWidth, java.lang.String str, int index)
Pads a string with the spaces on either end necessary when printing. Also handles if tuples are numbers, in that case, the column is aligned right instead of left- Parameters:
colWidth
- the width of the column the string will be printed instr
- the string to be printedindex
- the index of the column being printed- Returns:
- the newly-padded string
-
checkColumnWidths
public void checkColumnWidths(java.lang.String str, int col)
Changes the maximum column width stored if necessary- Parameters:
str
- the string added to the list of things to printcol
- the column it was added at
-
-