TableWriterpublic class HtmlWriter extends AbstractStreamTableWriter
Please note! This class is mainly for convinience when aou need to create static HTML files. You'd rather use JSP pages when you are in a JSP environment (unless you have good reasons to use this class).
| Modifier and Type | Field | Description |
|---|---|---|
static String |
DEFAULT_TABLE_TEMPLATE |
|
static String |
DEFAULT_TBODY_TD_TEMPLATE |
|
static String |
DEFAULT_TBODY_TD_TEMPLATE2 |
|
static String |
DEFAULT_TBODY_TEMPLATE |
|
static String |
DEFAULT_TBODY_TR_TEMPLATE |
|
static String |
DEFAULT_TBODY_TR_TEMPLATE2 |
|
static String |
DEFAULT_THEAD_TEMPLATE |
|
static String |
DEFAULT_THEAD_TH_TEMPLATE |
|
static String |
DEFAULT_THEAD_TH_TEMPLATE2 |
|
static String |
DEFAULT_THEAD_TR_TEMPLATE |
| Constructor | Description |
|---|---|
HtmlWriter() |
Default Constructor.
|
HtmlWriter(File file) |
|
HtmlWriter(OutputStream out) |
|
HtmlWriter(String file) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
Closes the writer by printing the footer of the table.
|
static String |
encodeHtml(String s) |
Makes HTML encoding for the string.
|
int |
getCurrentRowIndex() |
Returns the current data row index.
|
protected static String |
getFooter(String template) |
Returns the footer part of the given template
|
protected static String |
getHeader(String template) |
Returns the header part of the given template
|
String |
getTableTemplate() |
Returns the main table template.
|
String |
getTbodyTdTemplate() |
Returns the data cell template for even columns.
|
String |
getTbodyTdTemplate2() |
Returns the data cell template for odd columns.
|
String |
getTbodyTemplate() |
Returns the table body template.
|
String |
getTbodyTrTemplate() |
Returns the row template for even data rows.
|
String |
getTbodyTrTemplate2() |
Returns the row template for odd data rows.
|
String |
getTheadTemplate() |
Returns the header template.
|
String |
getTheadThTemplate() |
Returns the header cell template for even columns.
|
String |
getTheadThTemplate2() |
Returns the header cell template for odd columns.
|
String |
getTheadTrTemplate() |
Returns the header row template.
|
protected void |
init() |
General initialization.
|
boolean |
isHasHeaderRow() |
Returns true if this writer will create a header row.
|
boolean |
isTableHeaderWritten() |
Returns whether the table header (table tag) was written.
|
void |
printColumnContent(Object o,
int rowIndex,
int columnIndex) |
Prints the value of this object only without any enclosing tags.
|
void |
printDataRow(Object[] columns,
int rowIndex) |
Prints a data row to the underlying stream
|
void |
printHeaderRow(Object[] columns) |
Prints the header row into the stream.
|
void |
printRow(Object[] columns) |
Prints the row.
|
void |
printTableBodyFooter() |
Prints the table body (tbody) footer into the underlying stream.
|
void |
printTableBodyHeader() |
Prints the table body (tbody) header into the underlying stream.
|
void |
printTableBodyRowFooter(int rowIndex) |
Prints the table body row (tr) footer into the underlying stream.
|
void |
printTableBodyRowHeader(int rowIndex) |
Prints the table body row (tr) header into the underlying stream.
|
void |
printTableDataColumnFooter(int rowIndex,
int columnIndex) |
Prints the table body data cell (td) footer into the underlying stream.
|
void |
printTableDataColumnHeader(int rowIndex,
int columnIndex) |
Prints the table body data cell (td) header into the underlying stream.
|
void |
printTableFooter() |
Prints the table footer into the underlying stream.
|
void |
printTableHeadColumnFooter(int columnIndex) |
Prints the table header column (th) footer into the underlying stream.
|
void |
printTableHeadColumnHeader(int columnIndex) |
Prints the table header column (th) header into the underlying stream.
|
void |
printTableHeader() |
Prints the table header into the underlying stream.
|
void |
printTableHeadFooter() |
Prints the table head (thead) footer into the underlying stream.
|
void |
printTableHeadHeader() |
Prints the table head (thead) header into the underlying stream.
|
void |
printTableHeadRowFooter() |
Prints the table header row (tr) footer into the underlying stream.
|
void |
printTableHeadRowHeader() |
Prints the table header row (tr) header into the underlying stream.
|
void |
setHasHeaderRow(boolean hasHeaderRow) |
Sets whether writer will create a header row.
|
void |
setTableTemplate(String tableTemplate) |
Sets the main table template.
|
void |
setTbodyTdTemplate(String dataColumnTemplate) |
Sets the data cell template for even columns.
|
void |
setTbodyTdTemplate2(String dataColumnTemplate2) |
Sets the data cell template for odd columns.
|
void |
setTbodyTemplate(String bodyTemplate) |
Sets the body template.
|
void |
setTbodyTrTemplate(String bodyRowTemplate) |
Sets the row template for even data rows.
|
void |
setTbodyTrTemplate2(String bodyRowTemplate2) |
Sets the row template for odd data rows.
|
void |
setTheadTemplate(String headerTemplate) |
Sets the header template.
|
void |
setTheadThTemplate(String headerColumnTemplate) |
Sets the header cell template for even columns.
|
void |
setTheadThTemplate2(String headerColumnTemplate2) |
Sets the header cell template for odd columns.
|
void |
setTheadTrTemplate(String headerRowTemplate) |
Sets the header row template.
|
createOutputStreamWriter, createWriter, getCharsetEncoder, getOutputStream, getWriter, setCharset, setCharset, setCharsetEncoder, setOutputStreamconvert, convert, getRowCount, getTypeConversionHandler, incrementRowCount, printComment, printComment, printRow, printRow, printRow, registerTypeConversionHandler, unregisterTypeConversionHandlerpublic static final String DEFAULT_TABLE_TEMPLATE
public static final String DEFAULT_THEAD_TEMPLATE
public static final String DEFAULT_THEAD_TR_TEMPLATE
public static final String DEFAULT_THEAD_TH_TEMPLATE
public static final String DEFAULT_THEAD_TH_TEMPLATE2
public static final String DEFAULT_TBODY_TEMPLATE
public static final String DEFAULT_TBODY_TR_TEMPLATE
public static final String DEFAULT_TBODY_TD_TEMPLATE
public static final String DEFAULT_TBODY_TR_TEMPLATE2
public static final String DEFAULT_TBODY_TD_TEMPLATE2
public HtmlWriter()
public HtmlWriter(OutputStream out)
out - output streampublic HtmlWriter(File file) throws IOException
file - output fileIOException - when the file cannot be writtenpublic HtmlWriter(String file) throws IOException
file - output filenameIOException - when the file cannot be writtenpublic void close()
close in interface TableWriterclose in class AbstractStreamTableWriterAbstractStreamTableWriter.close()protected void init()
AbstractTableWriterinit in class AbstractTableWriterAbstractTableWriter.init()public void printRow(Object[] columns) throws IOException
columns - columns to be writtenIOException - when an exception occursTableWriter.printRow(java.lang.Object[])public void printHeaderRow(Object[] columns)
columns - columns to be writtenpublic void printDataRow(Object[] columns, int rowIndex)
columns - the column values to be writtenrowIndex - index of data row (not including header row)public void printColumnContent(Object o, int rowIndex, int columnIndex)
o - object to be writtenrowIndex - index of data row (not including header row)columnIndex - index of columnpublic void printTableHeader()
public void printTableFooter()
public void printTableHeadHeader()
public void printTableHeadFooter()
public void printTableBodyHeader()
public void printTableBodyFooter()
public void printTableHeadRowHeader()
public void printTableHeadRowFooter()
public void printTableHeadColumnHeader(int columnIndex)
columnIndex - index of columnpublic void printTableHeadColumnFooter(int columnIndex)
columnIndex - index of columnpublic void printTableBodyRowHeader(int rowIndex)
rowIndex - index of data row (not including header row)public void printTableBodyRowFooter(int rowIndex)
rowIndex - index of data row (not including header row)public void printTableDataColumnHeader(int rowIndex,
int columnIndex)
rowIndex - index of data row (not including header row)columnIndex - index of columnpublic void printTableDataColumnFooter(int rowIndex,
int columnIndex)
rowIndex - index of data row (not including header row)columnIndex - index of columnpublic String getTableTemplate()
public void setTableTemplate(String tableTemplate)
tableTemplate - the tableTemplate to setpublic String getTheadTemplate()
public void setTheadTemplate(String headerTemplate)
headerTemplate - the headerTemplate to setpublic String getTheadTrTemplate()
public void setTheadTrTemplate(String headerRowTemplate)
headerRowTemplate - the headerRowTemplate to setpublic String getTheadThTemplate()
public void setTheadThTemplate(String headerColumnTemplate)
headerColumnTemplate - the headerColumnTemplate to setpublic String getTheadThTemplate2()
public void setTheadThTemplate2(String headerColumnTemplate2)
headerColumnTemplate2 - the headerColumnTemplate2 to setpublic String getTbodyTemplate()
public void setTbodyTemplate(String bodyTemplate)
bodyTemplate - the bodyTemplate to setpublic String getTbodyTrTemplate()
public void setTbodyTrTemplate(String bodyRowTemplate)
bodyRowTemplate - the bodyRowTemplate to setpublic String getTbodyTrTemplate2()
public void setTbodyTrTemplate2(String bodyRowTemplate2)
bodyRowTemplate2 - the bodyRowTemplate2 to setpublic String getTbodyTdTemplate()
public void setTbodyTdTemplate(String dataColumnTemplate)
dataColumnTemplate - the dataColumnTemplate to setpublic String getTbodyTdTemplate2()
public void setTbodyTdTemplate2(String dataColumnTemplate2)
dataColumnTemplate2 - the dataColumnTemplate2 to setpublic boolean isTableHeaderWritten()
public int getCurrentRowIndex()
public boolean isHasHeaderRow()
public void setHasHeaderRow(boolean hasHeaderRow)
hasHeaderRow - the hasHeaderRow to setpublic static String encodeHtml(String s)
s - the string ready to be used in HTMLprotected static String getHeader(String template)
template - template divided into two parts separated by a pipe character (|)Copyright © 2018. All rights reserved.