Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.table.io
Class XMLExportManager

java.lang.Object
  extended by com.citra.table.io.XMLExportManager
All Implemented Interfaces:
ExportManager

public class XMLExportManager
extends Object
implements ExportManager

XMLExportManager writes a table model in an XML format. You should define a 'path' element in the constructor, which follows the XPath specification. The specified path defines parent-child relationships from left to right, with each 'node' being separated with a '/'. e.g.

/bookstore/book
person etc.

An XML document will be created with the specified paths and the table columns as element nodes, and the cell values as the atomic values of the column nodes.


Field Summary
static String DEFAULT_IDENT
          the default identation string as "\t"
static String DEFAULT_NEWLINE
          the default new line as "\r\n"
protected  String ident
          the indentation string
protected  String newline
          the newline string
protected  String path
          the path
 
Constructor Summary
XMLExportManager(String path)
          Constructs an XMLExportManager.
 
Method Summary
protected  String format(TableModel model, int row, int column)
          Returns the value of a specified cell as a string.
protected  String formatHeader(String value)
          Returns a formatted string of a table's column name.
 String getPath()
          Returns the current path.
 void setPath(String path)
          Sets the current path.
 void write(TableModel model, OutputStream out)
          Writes model to the outputstream out.
 void write(TableModel model, Writer writer)
          Writes model to the writer writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_IDENT

public static final String DEFAULT_IDENT
the default identation string as "\t"

See Also:
Constant Field Values

DEFAULT_NEWLINE

public static final String DEFAULT_NEWLINE
the default new line as "\r\n"

See Also:
Constant Field Values

path

protected String path
the path


ident

protected String ident
the indentation string


newline

protected String newline
the newline string

Constructor Detail

XMLExportManager

public XMLExportManager(String path)
Constructs an XMLExportManager.

Method Detail

format

protected String format(TableModel model,
                        int row,
                        int column)
Returns the value of a specified cell as a string.

Parameters:
model - the table model
row - the row index
column - the column index
Returns:
the formatted cell value

getPath

public String getPath()
Returns the current path.

Returns:
the current path

setPath

public void setPath(String path)
Sets the current path.

Parameters:
path - the path to assign

write

public void write(TableModel model,
                  OutputStream out)
Writes model to the outputstream out.

Specified by:
write in interface ExportManager
Parameters:
model - the table model to write
out - the output stream to write to

write

public void write(TableModel model,
                  Writer writer)
Writes model to the writer writer.

Specified by:
write in interface ExportManager
Parameters:
model - the table model to write
writer - the writer to write to

formatHeader

protected String formatHeader(String value)
Returns a formatted string of a table's column name.

Parameters:
value - the value of the colunmn
Returns:
the formatted column value
Since:
3.4

Copyright © 2011 Citra Technologies. All Rights Reserved.