com.sibvisions.rad.model
Class DataBookUtil

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

public final class DataBookUtil
extends Object

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


Method Summary
static String formatCSVFileName(String pName)
          Formats a name as filename for a csv export.
static void writeCSV(IDataBook pBook, OutputStream pStream, String[] pColumnNames, 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, OutputStream pStream, String[] pColumnNames, String[] pLabels, ICondition pFilter, SortDefinition pSort, String pSeparator)
          Writes all rows and values of a databook, as comma separated values to a stream.
static void writeQuoted(OutputStreamWriter pStream, IDataType pDataType, Object pValue, 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,
                            OutputStream pStream,
                            String[] pColumnNames,
                            String[] pLabels,
                            ICondition pFilter,
                            SortDefinition pSort)
                     throws ModelException,
                            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 failes
IOException - if an error occurs during writing

writeCSV

public static void writeCSV(IDataBook pBook,
                            OutputStream pStream,
                            String[] pColumnNames,
                            String[] pLabels,
                            ICondition pFilter,
                            SortDefinition pSort,
                            String pSeparator)
                     throws ModelException,
                            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 failes
IOException - if an error occurs during writing

formatCSVFileName

public static String formatCSVFileName(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(OutputStreamWriter pStream,
                               IDataType pDataType,
                               Object pValue,
                               String pSeparator)
                        throws 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:
IOException - if a write error occurs


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.