org.geotoolkit.io
Class TableWriter

Object
  extended by Writer
      extended by FilterWriter
          extended by TableWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

Deprecated. Moved to Apache SIS as TableAppender.

@Deprecated
@ThreadSafe
@Decorator(value=java.io.Writer.class)
public class TableWriter
extends FilterWriter

A character stream that can be used to format tables. Columns are separated by tabulations ('\t') and rows are separated by line terminators ('\r', '\n' or "\r\n"). Every table cells are stored in memory until FilterWriter.flush() is invoked. When invoked, FilterWriter.flush() copy cell contents to the underlying stream while replacing tabulations by some amount of spaces. The exact number of spaces is computed from cell widths. TableWriter produces correct output when displayed with a monospaced font.

For example, the following code...

TableWriter out = new TableWriter(new OutputStreamWriter(System.out), 3);
out.write("Prénom\tNom\n");
out.nextLine('-');
out.write("Idéphonse\tLaporte\nSarah\tCoursi\nYvan\tDubois");
out.flush();
...produces the following output:
Prénom      Nom
---------   -------
Idéphonse   Laporte
Sarah       Coursi
Yvan        Dubois

Since:
1.0
Version:
3.00
Author:
Martin Desruisseaux (MPO, IRD)
Module:
utility/geotk-utility (download)    View source code for this class

Field Summary
static int ALIGN_CENTER
          Deprecated. A possible value for cell alignment.
static int ALIGN_LEFT
          Deprecated. A possible value for cell alignment.
static int ALIGN_RIGHT
          Deprecated. A possible value for cell alignment.
static char DOUBLE_HORIZONTAL_LINE
          Deprecated. A line separator for nextLine(char).
static String DOUBLE_VERTICAL_LINE
          Deprecated. A column separator for constructor.
static char SINGLE_HORIZONTAL_LINE
          Deprecated. A line separator for nextLine(char).
static String SINGLE_VERTICAL_LINE
          Deprecated. A column separator for constructor.
 
Fields inherited from class FilterWriter
out
 
Fields inherited from class Writer
lock
 
Constructor Summary
TableWriter(Writer out)
          Deprecated. Creates a new table writer with a default column separator.
TableWriter(Writer out, int spaces)
          Deprecated. Creates a new table writer with the specified amount of spaces as column separator.
TableWriter(Writer out, String separator)
          Deprecated. Creates a new table writer with the specified column separator.
 
Method Summary
 int getAlignment()
          Deprecated. Returns the alignment for current and next cells.
 int getColumnCount()
          Deprecated. Returns the number of columns in this table.
 int getRowCount()
          Deprecated. Returns the number of rows in this table.
 boolean isMultiLinesCells()
          Deprecated. Tells if EOL characters are used for line feeds inside current cells.
 void nextColumn()
          Deprecated. Moves one column to the right.
 void nextColumn(char fill)
          Deprecated. Moves one column to the right.
 void nextLine()
          Deprecated. Moves to the first column on the next row.
 void nextLine(char fill)
          Deprecated. Moves to the first column on the next row.
 void setAlignment(int alignment)
          Deprecated. Sets the alignment for current and next cells.
 void setColumnAlignment(int column, int alignment)
          Deprecated. Not effective anymore, because no equivalent method in SIS.
 void setMultiLinesCells(boolean multiLines)
          Deprecated. Sets the desired behavior for EOL and tabulations characters.
 String toString()
          Deprecated. Returns the table content as a string.
 void write(char[] cbuf)
          Deprecated. Writes an array of characters.
 void write(char[] cbuf, int offset, int length)
          Deprecated. Writes a portion of an array of characters.
 void write(int c)
          Deprecated. Write a single character.
 void write(String string)
          Deprecated. Writes a string.
 void write(String string, int offset, int length)
          Deprecated. Writes a portion of a string.
 void writeHorizontalSeparator()
          Deprecated. Writes an horizontal separator.
 
Methods inherited from class FilterWriter
close, flush
 
Methods inherited from class Writer
append, append, append
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALIGN_LEFT

public static final int ALIGN_LEFT
Deprecated. 
A possible value for cell alignment. This specifies that the text is aligned to the left indent and extra whitespace should be placed on the right.

See Also:
Constant Field Values

ALIGN_RIGHT

public static final int ALIGN_RIGHT
Deprecated. 
A possible value for cell alignment. This specifies that the text is aligned to the right indent and extra whitespace should be placed on the left.

See Also:
Constant Field Values

ALIGN_CENTER

public static final int ALIGN_CENTER
Deprecated. 
A possible value for cell alignment. This specifies that the text is aligned to the center and extra whitespace should be placed equally on the left and right.

See Also:
Constant Field Values

SINGLE_VERTICAL_LINE

public static final String SINGLE_VERTICAL_LINE
Deprecated. 
A column separator for constructor.

Since:
2.5
See Also:
Constant Field Values

DOUBLE_VERTICAL_LINE

public static final String DOUBLE_VERTICAL_LINE
Deprecated. 
A column separator for constructor.

Since:
2.5
See Also:
Constant Field Values

SINGLE_HORIZONTAL_LINE

public static final char SINGLE_HORIZONTAL_LINE
Deprecated. 
A line separator for nextLine(char).

Since:
2.5
See Also:
Constant Field Values

DOUBLE_HORIZONTAL_LINE

public static final char DOUBLE_HORIZONTAL_LINE
Deprecated. 
A line separator for nextLine(char).

Since:
2.5
See Also:
Constant Field Values
Constructor Detail

TableWriter

public TableWriter(Writer out)
Deprecated. 
Creates a new table writer with a default column separator. The default is a double vertical line for the left and right table borders, and a single horizontal line between the columns.
Note: This writer may produce bad output on Windows console, unless the underlying stream use the correct codepage (e.g. OutputStreamWriter(System.out, "Cp437")). To display the appropriate codepage for a Windows console, type chcp on the command line.

Parameters:
out - Writer object to provide the underlying stream, or null if there is no underlying stream. If out is null, then the toString() method is the only way to get the table content.

TableWriter

public TableWriter(Writer out,
                   int spaces)
Deprecated. 
Creates a new table writer with the specified amount of spaces as column separator.

Parameters:
out - Writer object to provide the underlying stream, or null if there is no underlying stream. If out is null, then the toString() method is the only way to get the table content.
spaces - Amount of white spaces to use as column separator.

TableWriter

public TableWriter(Writer out,
                   String separator)
Deprecated. 
Creates a new table writer with the specified column separator.

Parameters:
out - Writer object to provide the underlying stream, or null if there is no underlying stream. If out is null, then the toString() method is the only way to get the table content.
separator - String to write between columns. Drawing box characters are treated specially. For example " \\u2502 " can be used for a single-line box.
See Also:
SINGLE_VERTICAL_LINE, DOUBLE_VERTICAL_LINE
Method Detail

setMultiLinesCells

public void setMultiLinesCells(boolean multiLines)
Deprecated. 
Sets the desired behavior for EOL and tabulations characters. The default value is false.

Parameters:
multiLines - true true if EOL are used for line feeds inside current cells, or false if EOL move to the next row.

isMultiLinesCells

public boolean isMultiLinesCells()
Deprecated. 
Tells if EOL characters are used for line feeds inside current cells.

Returns:
true if EOL characters are to be write inside the cell.

setColumnAlignment

@Deprecated
public void setColumnAlignment(int column,
                                          int alignment)
Deprecated. Not effective anymore, because no equivalent method in SIS.

Sets the alignment for all cells in the specified column. This method overwrite the alignment for all previous cells in the specified column.

Parameters:
column - The 0-based column number.
alignment - Cell alignment. Must be ALIGN_LEFT ALIGN_RIGHT or ALIGN_CENTER.

setAlignment

public void setAlignment(int alignment)
Deprecated. 
Sets the alignment for current and next cells. Change to the alignment doesn't affect the alignment of previous cells and previous rows. The default alignment is ALIGN_LEFT.

Parameters:
alignment - Cell alignment. Must be ALIGN_LEFT ALIGN_RIGHT or ALIGN_CENTER.

getAlignment

public int getAlignment()
Deprecated. 
Returns the alignment for current and next cells.

Returns:
Cell alignment: ALIGN_LEFT (the default), ALIGN_RIGHT or ALIGN_CENTER.

getRowCount

public int getRowCount()
Deprecated. 
Returns the number of rows in this table. This count is reset to 0 by FilterWriter.flush().

Returns:
The number of rows in this table.
Since:
2.5

getColumnCount

public int getColumnCount()
Deprecated. 
Returns the number of columns in this table.

Returns:
The number of columns in this table.
Since:
2.5

write

public void write(int c)
Deprecated. 
Write a single character. If isMultiLinesCells() is false (which is the default), then:

Overrides:
write in class FilterWriter
Parameters:
c - Character to write.

write

public void write(String string)
Deprecated. 
Writes a string. Tabulations and line separators are interpreted as by write(int).

Overrides:
write in class Writer
Parameters:
string - String to write.

write

public void write(String string,
                  int offset,
                  int length)
Deprecated. 
Writes a portion of a string. Tabulations and line separators are interpreted as by write(int).

Overrides:
write in class FilterWriter
Parameters:
string - String to write.
offset - Offset from which to start writing characters.
length - Number of characters to write.

write

public void write(char[] cbuf)
Deprecated. 
Writes an array of characters. Tabulations and line separators are interpreted as by write(int).

Overrides:
write in class Writer
Parameters:
cbuf - Array of characters to be written.

write

public void write(char[] cbuf,
                  int offset,
                  int length)
Deprecated. 
Writes a portion of an array of characters. Tabulations and line separators are interpreted as by write(int).

Overrides:
write in class FilterWriter
Parameters:
cbuf - Array of characters.
offset - Offset from which to start writing characters.
length - Number of characters to write.

writeHorizontalSeparator

public void writeHorizontalSeparator()
Deprecated. 
Writes an horizontal separator.


nextColumn

public void nextColumn()
Deprecated. 
Moves one column to the right. Next write operations will occur in a new cell on the same row.


nextColumn

public void nextColumn(char fill)
Deprecated. 
Moves one column to the right. Next write operations will occur in a new cell on the same row. This method fill every remaining space in the current cell with the specified character. For example calling nextColumn('*') from the first character of a cell is a convenient way to put a pad value in this cell.

Parameters:
fill - Character filling the cell (default to whitespace).

nextLine

public void nextLine()
Deprecated. 
Moves to the first column on the next row. Next write operations will occur on a new row.


nextLine

public void nextLine(char fill)
Deprecated. 
Moves to the first column on the next row. Next write operations will occur on a new row. This method fill every remaining cell in the current row with the specified character. Calling nextLine('-') from the first column of a row is a convenient way to fill this row with a line separator.

Parameters:
fill - Character filling the rest of the line (default to whitespace). This character may be use as a row separator.
See Also:
SINGLE_HORIZONTAL_LINE, DOUBLE_HORIZONTAL_LINE

toString

public String toString()
Deprecated. 
Returns the table content as a string.



Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.