Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.utilities.output
Class PrettyPrinter

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.output.PrettyPrinter

public class PrettyPrinter
extends Object

Class for formatting output into table.

Author:
Arthur Zimek

Field Summary
private  int[] columnWidth
          provides the column width for each column
static String NEWLINE
          The newline-String dependent on the system.
private  String separator
          provides a separator to separate different columns (could be empty String)
 
Constructor Summary
PrettyPrinter(int[] columnWidth, String separator)
          Provides a PrettyPrinter with specified columnWidth and specified separator.
 
Method Summary
 Vector<String> breakLine(String line, int column)
          Breaks a line at near line-end spaces fitting to width of columnWidth[column].
 String formattedLine(String[] lineEntries, char fillCharacter)
          Formats given lineEntries into formatted tableLine, filled with specified fillCharacter.
 String formattedLine(String[] lineEntries, char fillCharacter, boolean[] leftBounded)
          Formats given lineEntries into formatted tableLine, filled with specified fillCharacter.
private  String splitAtLastBlank(String s, int column)
          Splits the specified string at the last blank before columnWidth[column].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEWLINE

public static final String NEWLINE
The newline-String dependent on the system.


columnWidth

private int[] columnWidth
provides the column width for each column


separator

private String separator
provides a separator to separate different columns (could be empty String)

Constructor Detail

PrettyPrinter

public PrettyPrinter(int[] columnWidth,
                     String separator)
Provides a PrettyPrinter with specified columnWidth and specified separator.

Parameters:
columnWidth - the column width for each column
separator - a separator to separate different columns (could be empty String)
Method Detail

formattedLine

public String formattedLine(String[] lineEntries,
                            char fillCharacter)
Formats given lineEntries into formatted tableLine, filled with specified fillCharacter.

Parameters:
lineEntries - the entries to be written into table
fillCharacter - char to fill the table line with
Returns:
formatted lineEntries

formattedLine

public String formattedLine(String[] lineEntries,
                            char fillCharacter,
                            boolean[] leftBounded)
Formats given lineEntries into formatted tableLine, filled with specified fillCharacter.

Parameters:
lineEntries - the entries to be written into table
fillCharacter - char to fill the table line with
leftBounded - specifies, if column is leftBounded
Returns:
formatted lineEntries

breakLine

public Vector<String> breakLine(String line,
                                int column)
Breaks a line at near line-end spaces fitting to width of columnWidth[column].

Parameters:
line - the line to break
column - the index of column in columnWidth
Returns:
Vector contains the lines made of the given line

splitAtLastBlank

private String splitAtLastBlank(String s,
                                int column)
Splits the specified string at the last blank before columnWidth[column].

Parameters:
s - the string to be splitted
column - the index of column in columnWidth
Returns:
the splitted string

Release 0.2.1 (2009-07-13_1605)