Package org.obolibrary.robot.export
Class Table
- java.lang.Object
-
- org.obolibrary.robot.export.Table
-
public class Table extends Object
- Author:
- Becky Jackson
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumn(Column column)
Add a Column to the Table.void
addRow(Row row)
Add a Row to the Table.org.apache.poi.ss.usermodel.Workbook
asWorkbook(String split)
Render the Table as a Workbook.List<Column>
getColumns()
Get the Columns in a Table.RendererType
getDisplayRendererType()
Get the type of display rendererString
getFormat()
Get the format of this tableRendererType
getSortRendererType()
Get thee type of sort renderervoid
setSortColumns()
Once all Columns have been added to a Table, set the columns to sort on.void
sortRows()
Once all Rows have been added to a Table, sort Rows based on the sort Columns.String
toHTML(String split)
Render the Table as an HTML string.String
toHTML(String split, boolean standalone)
Render the Table as an HTML string.String
toHTML(String split, boolean standalone, boolean includeJS)
Render the Table as an HTML string.String
toHTMLList()
String
toJSON()
Render the Table as a JSON string.List<String[]>
toList(String split)
Render the Table as List of Arrays for writing to CSV/TSV.String
toYAML()
Render the Table as a YAML string.boolean
write(String path, String split)
Given a path and a split character, write the table to a path.boolean
write(String path, String split, boolean standalone)
Given a path, a split character, and boolean if standalone, write the table to a path.
-
-
-
Constructor Detail
-
Table
public Table()
Init a new Table.
-
Table
public Table(String format)
Init a new Table with a format.- Parameters:
format
- format of the table (tsv, csv, html)
-
-
Method Detail
-
addColumn
public void addColumn(Column column)
Add a Column to the Table. This will be appended to the end of the current list of Columns.- Parameters:
column
- Column to add.
-
addRow
public void addRow(Row row)
Add a Row to the Table. This will be appended to the end of the current list of Rows.- Parameters:
row
- Row to add
-
asWorkbook
public org.apache.poi.ss.usermodel.Workbook asWorkbook(String split)
Render the Table as a Workbook.- Parameters:
split
- character to split multiple cell values on- Returns:
- Workbook
-
getDisplayRendererType
public RendererType getDisplayRendererType()
Get the type of display renderer- Returns:
- RendererType
-
getSortRendererType
public RendererType getSortRendererType()
Get thee type of sort renderer- Returns:
- RendererType
-
getFormat
public String getFormat()
Get the format of this table- Returns:
- table format (csv, tsv, or html)
-
setSortColumns
public void setSortColumns()
Once all Columns have been added to a Table, set the columns to sort on. The columns should have consecutive sort order integers which will determine the order in which they are used to sort the Rows.
-
sortRows
public void sortRows()
Once all Rows have been added to a Table, sort Rows based on the sort Columns.
-
toList
public List<String[]> toList(String split)
Render the Table as List of Arrays for writing to CSV/TSV.- Parameters:
split
- String to split mulitple cell values on (default |)- Returns:
- List of String[]
-
toHTML
public String toHTML(String split)
Render the Table as an HTML string.- Parameters:
split
- character to split multiple cell values on- Returns:
- HTML string
-
toHTML
public String toHTML(String split, boolean standalone)
Render the Table as an HTML string.- Parameters:
split
- character to split multiple cell values onstandalone
- if true, include header- Returns:
- HTML string
-
toHTML
public String toHTML(String split, boolean standalone, boolean includeJS)
Render the Table as an HTML string.- Parameters:
split
- character to split multiple cell values onstandalone
- if true, include headerincludeJS
- if true and standalone, include JS script for tooltips- Returns:
- HTML string
-
toHTMLList
public String toHTMLList()
-
toJSON
public String toJSON()
Render the Table as a JSON string.- Returns:
- JSON string
-
toYAML
public String toYAML() throws IOException
Render the Table as a YAML string.- Returns:
- YAML string
- Throws:
IOException
- on issue writing to JSON tree
-
write
public boolean write(String path, String split) throws IOException
Given a path and a split character, write the table to a path.- Parameters:
path
- path to write tosplit
- split character for multiple cell values- Returns:
- true on success
- Throws:
IOException
- on any problem opening or writing file
-
write
public boolean write(String path, String split, boolean standalone) throws IOException
Given a path, a split character, and boolean if standalone, write the table to a path.- Parameters:
path
- path to write tosplit
- split character for multiple cell valuesstandalone
- if true, include HTML headers for HTML output- Returns:
- true on success
- Throws:
IOException
- on any problem opening or writing file
-
-