com.sibvisions.rad.model
Class DataBookCSVExporter

java.lang.Object
  extended by com.sibvisions.rad.model.DataBookCSVExporter

public final class DataBookCSVExporter
extends java.lang.Object

The DataBookUtil handles simple access to databooks. It allows export/import of data.


Method Summary
static java.lang.String formatCSVFileName(java.lang.String pName)
          Formats a name as filename for a csv export.
static java.lang.String getDefaultEncoding()
          Get the default encoding for CSV exports.
static void setDefaultEncoding(java.lang.String pEncoding)
          Sets the default encoding for CSV exports.
static void writeCSV(IDataBook pBook, java.io.OutputStream pStream)
          Writes all rows and values of a databook, as comma separated values to a stream.
static void writeCSV(IDataBook pBook, java.io.OutputStream pStream, java.lang.String pEncoding)
          Writes all rows and values of a databook, as comma separated values to a stream.
static void writeCSV(IDataBook pBook, java.io.OutputStream pStream, java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort)
          Writes all rows and values of a databook, as comma separated values to a stream.
static void writeCSV(IDataBook pBook, java.io.OutputStream pStream, java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort, java.lang.String pSeparator)
          Writes all rows and values of a databook, as comma separated values to a stream.
static void writeCSV(IDataBook pBook, java.io.OutputStream pStream, java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort, java.lang.String pSeparator, java.lang.String pEncoding)
          Writes all rows and values of a databook, as comma separated values to a stream.
static void writeQuoted(java.io.OutputStreamWriter pStream, IDataType pDataType, java.lang.Object pValue, java.lang.String pSeparator)
          Writes an object as quoted string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

writeCSV

public static void writeCSV(IDataBook pBook,
                            java.io.OutputStream pStream)
                     throws ModelException,
                            java.io.IOException
Writes all rows and values of a databook, as comma separated values to a stream.

Parameters:
pBook - the databook
pStream - the output stream
Throws:
ModelException - if the access to rows or values of the databook fails
java.io.IOException - if an error occurs during writing

writeCSV

public static void writeCSV(IDataBook pBook,
                            java.io.OutputStream pStream,
                            java.lang.String pEncoding)
                     throws ModelException,
                            java.io.IOException
Writes all rows and values of a databook, as comma separated values to a stream.

Parameters:
pBook - the databook
pStream - the output stream
pEncoding - the character encoding
Throws:
ModelException - if the access to rows or values of the databook fails
java.io.IOException - if an error occurs during writing

writeCSV

public static void writeCSV(IDataBook pBook,
                            java.io.OutputStream pStream,
                            java.lang.String[] pColumnNames,
                            java.lang.String[] pLabels,
                            ICondition pFilter,
                            SortDefinition pSort)
                     throws ModelException,
                            java.io.IOException
Writes all rows and values of a databook, as comma separated values to a stream.

Parameters:
pBook - the databook
pStream - the output stream
pColumnNames - specific column names or null to use the column names from the current ColumnView
pLabels - the preferred column labels
pFilter - the export filter
pSort - the export sort definition
Throws:
ModelException - if the access to rows or values of the databook fails
java.io.IOException - if an error occurs during writing

writeCSV

public static void writeCSV(IDataBook pBook,
                            java.io.OutputStream pStream,
                            java.lang.String[] pColumnNames,
                            java.lang.String[] pLabels,
                            ICondition pFilter,
                            SortDefinition pSort,
                            java.lang.String pSeparator)
                     throws ModelException,
                            java.io.IOException
Writes all rows and values of a databook, as comma separated values to a stream.

Parameters:
pBook - the databook
pStream - the output stream
pColumnNames - specific column names or null to use the column names from the current ColumnView
pLabels - the preferred column labels
pFilter - the export filter
pSort - the export sort definition
pSeparator - the list separator
Throws:
ModelException - if the access to rows or values of the databook fails
java.io.IOException - if an error occurs during writing

writeCSV

public static void writeCSV(IDataBook pBook,
                            java.io.OutputStream pStream,
                            java.lang.String[] pColumnNames,
                            java.lang.String[] pLabels,
                            ICondition pFilter,
                            SortDefinition pSort,
                            java.lang.String pSeparator,
                            java.lang.String pEncoding)
                     throws ModelException,
                            java.io.IOException
Writes all rows and values of a databook, as comma separated values to a stream.

Parameters:
pBook - the databook
pStream - the output stream
pColumnNames - specific column names or null to use the column names from the current ColumnView
pLabels - the preferred column labels
pFilter - the export filter
pSort - the export sort definition
pSeparator - the list separator
pEncoding - the character encoding
Throws:
ModelException - if the access to rows or values of the databook fails
java.io.IOException - if an error occurs during writing

formatCSVFileName

public static java.lang.String formatCSVFileName(java.lang.String pName)
Formats a name as filename for a csv export.

Parameters:
pName - a databook name or filename. Predefined extensions will be re-used.
Returns:
the filename for the export. If the pName is null then Export.csv is used.

writeQuoted

public static void writeQuoted(java.io.OutputStreamWriter pStream,
                               IDataType pDataType,
                               java.lang.Object pValue,
                               java.lang.String pSeparator)
                        throws java.io.IOException
Writes an object as quoted string. Quotes are only added, if needed.

Parameters:
pStream - the output stream
pDataType - the datatype for the given value
pValue - the value
pSeparator - the column separator
Throws:
java.io.IOException - if a write error occurs

setDefaultEncoding

public static void setDefaultEncoding(java.lang.String pEncoding)
Sets the default encoding for CSV exports.

Parameters:
pEncoding - the encoding

getDefaultEncoding

public static java.lang.String getDefaultEncoding()
Get the default encoding for CSV exports. If no user-defined default encoding was set, the system property "file.encoding" will be used, if possible. The method Charset.defaultCharset() acts as fallback.

Returns:
the user-defined default encoding or system detected default encoding for CSV exports


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.