public class XmlWriter extends AbstractStreamTableWriter
| Constructor and Description |
|---|
XmlWriter()
Constructor.
|
XmlWriter(File file)
Constructor.
|
XmlWriter(File file,
boolean writeHeaderRow)
Constructor.
|
XmlWriter(OutputStream out)
Constructor.
|
XmlWriter(OutputStream out,
boolean writeHeaderRow)
Constructor.
|
XmlWriter(String file)
Constructor.
|
XmlWriter(String file,
boolean writeHeaderRow)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Prints the closing of the XML file before closing the stream.
|
protected String |
encode(Object s)
Encodes the object for usage in XML file.
|
protected String |
getColumnEndTag(int column)
Returns column's closing tag
|
protected String |
getColumnName(int index)
Returns the column name at given index.
|
String |
getColumnNameAttribute()
Returns the name of the attribute within column tag that contains the column name.
|
protected String |
getColumnStartTag(int column,
Object value)
Returns the complete start tag for the column.
|
protected String |
getColumnTagAttributes(int column,
Object value)
Returns all attributes that need to be set for a column opening tag.
|
String |
getColumnTagName()
Returns the name of the column tag.
|
protected String |
getColumnTagName(int column)
Returns correct column name.
|
protected String |
getColumnType(Object value)
Returns the type of the value to be set as attribute in column opening tag.
|
String |
getColumnTypeAttribute()
Returns the name of the attribute in the column tag that contains the Java type of the value.
|
protected String |
getDefaultColumnName(int index)
Creates a default name for the column.
|
String |
getEncoding()
Returns the encoding string for XML header.
|
Object[] |
getHeaderColumns()
Returns the header column names.
|
String |
getRowTagName()
Returns the name of the row tag.
|
String |
getTopLevelTagName()
Returns the XML root tag name.
|
protected void |
init()
Initializes the writer.
|
boolean |
isUseColumnNameTags()
Returns whether column tag names will be equal to column names.
|
boolean |
isWriteHeaderRow()
Returns true when the first row being written contains the column names.
|
void |
printComment(String comment)
Prints the comment into the stream.
|
void |
printComment(String comment,
int row,
int column)
Prints the comment at the given location.
|
protected void |
printFooter()
Prints the footer.
|
protected void |
printHeader()
Prints the header.
|
void |
printRow(Object[] columns)
Prints the row into the stream.
|
void |
setColumnNameAttribute(String columnNameAttribute)
Sets the name of the attribute within column tag that contains the column name.
|
void |
setColumnTagName(String columnTagName)
Sets the name of teh column tag.
|
void |
setColumnTypeAttribute(String columnTypeAttribute)
Sets the name of the attribute in the column tag that contains the Java type of the value.
|
void |
setEncoding(String encoding)
Sets the encoding string for XML header.
|
void |
setHeaderColumns(Object[] headerColumns)
Sets the header column names explicitely.
|
void |
setRowTagName(String rowTagName)
Set the name of the row tag.
|
void |
setTopLevelTagName(String topLevelTagName)
Sets the XML root tag name.
|
void |
setUseColumnNameTags(boolean useColumnNameTags)
Sets whether column tag names will be equal to column names.
|
void |
setWriteHeaderRow(boolean writeHeaderRow)
Sets whether the first row being written contains the column names.
|
createOutputStreamWriter, createWriter, getCharsetEncoder, getOutputStream, getWriter, setCharset, setCharset, setCharsetEncoder, setOutputStreamconvert, convert, getRowCount, getTypeConversionHandler, incrementRowCount, printRow, printRow, printRow, registerTypeConversionHandler, unregisterTypeConversionHandlerpublic XmlWriter()
public XmlWriter(OutputStream out)
out - output streampublic XmlWriter(OutputStream out, boolean writeHeaderRow)
out - output streamwriteHeaderRow - whether a dedicated header row will be received as first rowpublic XmlWriter(File file) throws IOException
file - output fileIOException - if exception occurspublic XmlWriter(File file, boolean writeHeaderRow) throws IOException
file - output filewriteHeaderRow - whether a dedicated header row will be received as first rowIOException - if exception occurspublic XmlWriter(String file) throws IOException
file - file to writeIOException - if exception occurspublic XmlWriter(String file, boolean writeHeaderRow) throws IOException
file - file to writewriteHeaderRow - whether a dedicated header row will be received as first rowIOException - if exception occurspublic void close()
close in interface TableWriterclose in class AbstractStreamTableWriterAbstractStreamTableWriter.close()protected void init()
init in class AbstractTableWriterAbstractTableWriter.init()public void printRow(Object[] columns) throws IOException
setWriteHeaderRow(boolean) was set.columns - columns to be written in rowIOException - when an exception occursTableWriter.printRow(java.lang.Object[])protected String getColumnStartTag(int column, Object value)
column - index of columnvalue - value in columnprotected String getColumnEndTag(int column)
column - column indexprotected String getColumnTagName(int column)
column - index of columnisUseColumnNameTags()protected String getColumnTagAttributes(int column, Object value)
column - index of columnvalue - value of columnprotected String getColumnType(Object value)
value - value of columnpublic void printComment(String comment) throws IOException
printComment in interface TableWriterprintComment in class AbstractTableWritercomment - the comment to writeIOException - when an exception occursAbstractTableWriter.printComment(java.lang.String)public void printComment(String comment, int row, int column) throws IOException
printComment in interface TableWriterprintComment in class AbstractTableWritercomment - the comment to writerow - index of row for commentcolumn - index of column for commentIOException - when an exception occursAbstractTableWriter.printComment(java.lang.String, int, int)protected void printHeader()
protected void printFooter()
protected String encode(Object s)
s - object to encodeprotected String getColumnName(int index)
getDefaultColumnName(int) if no column header can be found.index - index of columnprotected String getDefaultColumnName(int index)
index - index of columnpublic String getTopLevelTagName()
public void setTopLevelTagName(String topLevelTagName)
topLevelTagName - the topLevelTagName to setpublic String getRowTagName()
public void setRowTagName(String rowTagName)
rowTagName - the rowTagName to setpublic String getColumnTagName()
setUseColumnNameTags(boolean) was not set.public void setColumnTagName(String columnTagName)
setUseColumnNameTags(boolean) was not set.columnTagName - the columnTagName to setpublic boolean isUseColumnNameTags()
public void setUseColumnNameTags(boolean useColumnNameTags)
useColumnNameTags - the useColumnNameTags to setpublic String getColumnNameAttribute()
setUseColumnNameTags(boolean) was not set.public void setColumnNameAttribute(String columnNameAttribute)
setUseColumnNameTags(boolean) was not set.columnNameAttribute - the columnNameAttribute to setpublic String getColumnTypeAttribute()
public void setColumnTypeAttribute(String columnTypeAttribute)
columnTypeAttribute - the columnTypeAttribute to setpublic String getEncoding()
public void setEncoding(String encoding)
encoding - the encoding to setpublic Object[] getHeaderColumns()
public void setHeaderColumns(Object[] headerColumns)
headerColumns - the headerColumns to setpublic boolean isWriteHeaderRow()
public void setWriteHeaderRow(boolean writeHeaderRow)
writeHeaderRow - the writeHeaderRow to setCopyright © 2014. All rights reserved.