com.sas.table
Class TableWriter

com.sas.table.TableWriter

public class TableWriter

TableWriter creates a comma separated values (CSV) stream from a table. The delimiter can be set to any String, but comma is the default.


Field Summary
protected  java.lang.String _delimiter
          The delimiter string to be used
protected static java.lang.String _excelArgs
           
protected static java.lang.String _fileExt
           
protected  java.io.Writer _out
          The Writer object to be used
protected static boolean _verbose
           
protected static java.lang.String DEFAULT_DELIMITER
           
protected static java.lang.String EXCEL
           
protected  boolean formattedDataUsed
           
static java.lang.String RB_KEY
           
 
Constructor Summary
TableWriter(java.io.Writer out)
          Creates a TableWriter with the default comma delimiter.
TableWriter(java.io.Writer out, java.lang.String delimiter)
           
 
Method Summary
static void export(com.sas.sasserver.mdtable.MultidimensionalTableInterface mdModel)
          Sends the table to Excel or to the browser, as appropriate.
static void export(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel, boolean formattedDataUsed)
          Sends the table to Excel or to the browser, as appropriate.
static void export(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel, boolean formattedDataUsed, boolean isRotated)
          Sends the table to Excel or to the browser, as appropriate.
static void export(StaticTableInterface table)
          Sends the table to Excel or to the browser, as appropriate.
static void export(StaticTableInterface table, boolean formattedDataUsed)
          Sends the table to Excel or to the browser, as appropriate.
static byte[] getCSVAsByteArray(com.sas.sasserver.mdtable.MultidimensionalTableInterface mdModel)
          Convenience method to represent a table as a CSV and return it as a byte array.
static byte[] getCSVAsByteArray(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel, boolean formattedDataUsed)
          Convenience method to represent a table as a CSV and return it as a byte array.
static byte[] getCSVAsByteArray(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel, boolean formattedDataUsed, boolean isRotated)
          Convenience method to represent a table as a CSV and return it as a byte array.
static byte[] getCSVAsByteArray(StaticTableInterface model)
          Convenience method to represent a table as a CSV and return it as a byte array.
static byte[] getCSVAsByteArray(StaticTableInterface model, boolean formattedDataUsed)
          Convenience method to represent a table as a CSV and return it as a byte array.
 java.lang.String getDelimiter()
          Get the delimiter (the separator for data items).
protected static java.lang.String getExcelEXE()
           
static boolean isExportAllowed()
          Indicates whether exporting can happen (checks security, application paths, etc. as appropriate.
 boolean isFormattedDataUsed()
          Gets whether the writer is going to use the formatted data (if available), or the raw data.
 boolean isTransposed()
          Sets whether the md tableview is rotated.
static void resetCheck()
          clears the checked flag so that isExportAllowed will check again
 void setDelimiter(java.lang.String delimiter)
          Set the delimiter (the separator for data items).
 void setFormattedDataUsed(boolean useFormat)
          Sets whether the writer is going to use the formatted data (if available), or the raw data.
 void setTransposed(boolean isRotated)
          Sets whether the md tableview is rotated.
static void setVerbose(boolean verbose)
          Useful for debugging
 void writeCSV(com.sas.sasserver.mdtable.MultidimensionalTableInterface mdModel)
          Writes a table as a CSV to the writer specified in the constructor.
 void writeCSV(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel)
          Writes a table as a CSV to the writer specified in the constructor.
 void writeCSV(StaticTableInterface model)
          Writes a table as a CSV to the writer specified in the constructor.
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values

DEFAULT_DELIMITER

protected static java.lang.String DEFAULT_DELIMITER

formattedDataUsed

protected boolean formattedDataUsed

_out

protected java.io.Writer _out
The Writer object to be used


_delimiter

protected java.lang.String _delimiter
The delimiter string to be used


_verbose

protected static boolean _verbose

_excelArgs

protected static final java.lang.String _excelArgs
See Also:
Constant Field Values

_fileExt

protected static final java.lang.String _fileExt
See Also:
Constant Field Values

EXCEL

protected static final java.lang.String EXCEL
See Also:
Constant Field Values
Constructor Detail

TableWriter

public TableWriter(java.io.Writer out)
Creates a TableWriter with the default comma delimiter.

Parameters:
out - the writer to which the table should be written as a CSV

TableWriter

public TableWriter(java.io.Writer out,
                   java.lang.String delimiter)
Parameters:
out - the writer to which the table should be written as a CSV
delimiter - the delimiter string
Method Detail

setDelimiter

public void setDelimiter(java.lang.String delimiter)
Set the delimiter (the separator for data items).

Parameters:
delimiter - the delimiter string

getDelimiter

public java.lang.String getDelimiter()
Get the delimiter (the separator for data items).

Returns:
the current delimiter string

setFormattedDataUsed

public void setFormattedDataUsed(boolean useFormat)
Sets whether the writer is going to use the formatted data (if available), or the raw data. To use the formatted data (true)is the default value.

Parameters:
useFormat - boolean indicating whether to use the formatted data or not

isFormattedDataUsed

public boolean isFormattedDataUsed()
Gets whether the writer is going to use the formatted data (if available), or the raw data. To use the formatted data (true) is the default value.

Returns:
whether to use the formatted data, or use the raw data

setTransposed

public void setTransposed(boolean isRotated)
Sets whether the md tableview is rotated.

Parameters:
isRotated - boolean indicating whether to the mdtableview is rotated

isTransposed

public boolean isTransposed()
Sets whether the md tableview is rotated.

Returns:
whether the md tableview is rotated

getCSVAsByteArray

public static byte[] getCSVAsByteArray(StaticTableInterface model)
Convenience method to represent a table as a CSV and return it as a byte array.

Parameters:
model - the two dimensional table to use

getCSVAsByteArray

public static byte[] getCSVAsByteArray(com.sas.sasserver.mdtable.MultidimensionalTableInterface mdModel)
Convenience method to represent a table as a CSV and return it as a byte array.

Parameters:
model - the multidimensional table to use

getCSVAsByteArray

public static byte[] getCSVAsByteArray(StaticTableInterface model,
                                       boolean formattedDataUsed)
Convenience method to represent a table as a CSV and return it as a byte array.

Parameters:
model - the two dimensional table to use

getCSVAsByteArray

public static byte[] getCSVAsByteArray(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel,
                                       boolean formattedDataUsed)
Convenience method to represent a table as a CSV and return it as a byte array.

Parameters:
model - the multidimensional table to use

getCSVAsByteArray

public static byte[] getCSVAsByteArray(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel,
                                       boolean formattedDataUsed,
                                       boolean isRotated)
Convenience method to represent a table as a CSV and return it as a byte array.

Parameters:
model - the multidimensional table to use

writeCSV

public void writeCSV(StaticTableInterface model)
              throws java.io.IOException
Writes a table as a CSV to the writer specified in the constructor.

Parameters:
model - the two dimensional table to use
Throws:
java.io.IOException

writeCSV

public void writeCSV(com.sas.sasserver.mdtable.MultidimensionalTableInterface mdModel)
              throws java.io.IOException
Writes a table as a CSV to the writer specified in the constructor.

Parameters:
model - the multidimensional table to use
Throws:
java.io.IOException

writeCSV

public void writeCSV(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel)
              throws java.io.IOException
Writes a table as a CSV to the writer specified in the constructor.

Parameters:
model - the multidimensional table to use
Throws:
java.io.IOException

setVerbose

public static void setVerbose(boolean verbose)
Useful for debugging


resetCheck

public static void resetCheck()
clears the checked flag so that isExportAllowed will check again


isExportAllowed

public static boolean isExportAllowed()
Indicates whether exporting can happen (checks security, application paths, etc. as appropriate.


getExcelEXE

protected static java.lang.String getExcelEXE()

export

public static void export(StaticTableInterface table)
Sends the table to Excel or to the browser, as appropriate.


export

public static void export(com.sas.sasserver.mdtable.MultidimensionalTableInterface mdModel)
Sends the table to Excel or to the browser, as appropriate.


export

public static void export(StaticTableInterface table,
                          boolean formattedDataUsed)
Sends the table to Excel or to the browser, as appropriate.


export

public static void export(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel,
                          boolean formattedDataUsed)
Sends the table to Excel or to the browser, as appropriate.


export

public static void export(com.sas.mdtable.StaticMultidimensionalTableInterface mdModel,
                          boolean formattedDataUsed,
                          boolean isRotated)
Sends the table to Excel or to the browser, as appropriate.




Copyright © 2009 SAS Institute Inc. All Rights Reserved.