|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectadams.core.ConsoleObject
adams.core.option.AbstractOptionHandler
adams.data.io.output.AbstractSpreadSheetWriter
adams.data.io.output.SqlDumpSpreadSheetWriter
public class SqlDumpSpreadSheetWriter
Generates an SQL dump from the spreadsheet, which can be imported into a database.
Valid options are:-D <int> (property: debugLevel) The greater the number the more additional info the scheme may output to the console (0 = off). default: 0 minimum: 0
-appending (property: appending) If enabled, multiple spreadsheets with the same structure can be written to the same file.
-keep-existing (property: keepExisting) If enabled, any output file that exists when the writer is executed for the first time won't get replaced with the current header; useful when outputting data in multiple locations in the flow, but one needs to be cautious as to not stored mixed content (eg varying number of columns, etc).
-table <java.lang.String> (property: table) The name of the table. default: blah
-column-name-conversion <AS_IS|LOWER_CASE|UPPER_CASE> (property: columnNameConversion) How to convert the column headers into SQL table column names. default: UPPER_CASE
-max-string-length <int> (property: maxStringLength) The maximum length for strings to enforce; can be used as @MAX in the 'stringColumnsSQL' property. default: 50 minimum: 1
-string-column-sql <java.lang.String> (property: stringColumnSQL) The SQL type to use for STRING columns in the CREATE statement; you can use the @MAX placeholder to tie the type to the 'naxStringLength' property; see also: http://en.wikipedia.org/wiki/SQL default: VARCHAR(@MAX)
-add-create-table (property: addCreateTable) If enabled, a CREATE TABLE statement is output as well.
-use-backslashes (property: useBackslashes) If enabled, backslashes are used to escape single quotes, rather than doubling up the single quotes.
| Field Summary | |
|---|---|
protected boolean |
m_AddCreateTable
whether to add a CREATE TABLE statement. |
protected boolean |
m_Appending
whether to append spreadsheets. |
protected ColumnNameConversion |
m_ColumnNameConversion
the column name conversion. |
protected String[] |
m_ColumnNames
the column names (shortened, disambiguated). |
protected boolean |
m_FileExists
whether the file already exists. |
protected SpreadSheet |
m_Header
the header of the first spreadsheet written to file, if appending is active. |
protected boolean |
m_KeepExisting
whether to keep existing files the first time the writer is called. |
protected int |
m_MaxStringLength
the maximum length for strings. |
protected String |
m_StringColumnSQL
the SQL type for string columns. |
protected String |
m_Table
the name of the table. |
protected Cell.ContentType[] |
m_Types
the type used for the table. |
protected boolean |
m_UseBackslashes
whether to use backslashes for escaping. |
| Fields inherited from class adams.core.option.AbstractOptionHandler |
|---|
m_DebugLevel, m_OptionManager |
| Constructor Summary | |
|---|---|
SqlDumpSpreadSheetWriter()
|
|
| Method Summary | |
|---|---|
String |
addCreateTableTipText()
Returns the tip text for this property. |
String |
appendingTipText()
Returns the tip text for this property. |
boolean |
canAppend(SpreadSheet sheet)
Checks whether we can append the specified spreadsheet to the existing file. |
String |
columnNameConversionTipText()
Returns the tip text for this property. |
void |
defineOptions()
Adds options to the internal list of options. |
protected boolean |
doWrite(SpreadSheet content,
Writer writer)
Performs the actual writing. |
protected String |
format(double value)
Formats the number according to the format and returns the generated textual representation. |
boolean |
getAddCreateTable()
Returns whether a CREATE TABLE statement is output. |
ColumnNameConversion |
getColumnNameConversion()
Returns how to convert the column headers into SQL table column names. |
boolean |
getFileExists()
Returns whether the output file already exists. |
String |
getFormatDescription()
Returns a string describing the format (used in the file chooser). |
String[] |
getFormatExtensions()
Returns the extension(s) of the format. |
boolean |
getKeepExisting()
Returns whether any existing file is kept on first execution. |
int |
getMaxStringLength()
Returns the maximum length for strings. |
String |
getStringColumnSQL()
Returns the SQL type for string columns for the CREATE statement. |
String |
getTable()
Returns the name of the table. |
boolean |
getUseBackslashes()
Returns whether to use backslashes for escaping quotes rather than doubling them. |
protected boolean |
getUseOutputStream()
Returns whether to write to an OutputStream rather than a Writer when using a file name. |
String |
globalInfo()
Returns a string describing the object. |
protected void |
initialize()
Initializes the members. |
boolean |
isAppending()
Returns whether the next spreadsheet will get appended. |
String |
keepExistingTipText()
Returns the tip text for this property. |
String |
maxStringLengthTipText()
Returns the tip text for this property. |
protected String |
quoteString(String s)
Quotes the string if necessary. |
protected void |
reset()
Resets the writer. |
void |
setAddCreateTable(boolean value)
Sets whether to add a CREATE TABLE statement. |
void |
setAppending(boolean value)
Sets whether the next write call is to append the data to the existing file. |
void |
setColumnNameConversion(ColumnNameConversion value)
Sets how to convert the column headers into SQL table column names. |
void |
setFileExists(boolean value)
Sets whether the output file already exists. |
void |
setKeepExisting(boolean value)
Sets whether to keep any existing file on first execution. |
void |
setMaxStringLength(int value)
Sets the maximum length for strings. |
void |
setStringColumnSQL(String value)
Sets the SQL type for string columns for the CREATE statement. |
void |
setTable(String value)
Sets the name of the table. |
void |
setUseBackslashes(boolean value)
Sets whether to use backslashes for escaping quotes rather than doubling them. |
String |
stringColumnSQLTipText()
Returns the tip text for this property. |
String |
tableTipText()
Returns the tip text for this property. |
String |
useBackslashesTipText()
Returns the tip text for this property. |
| Methods inherited from class adams.data.io.output.AbstractSpreadSheetWriter |
|---|
doWrite, getWriters, write, write, write, write |
| Methods inherited from class adams.core.option.AbstractOptionHandler |
|---|
cleanUpOptions, debug, debug, debugLevelTipText, destroy, finishInit, getDebugLevel, getOptionManager, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString |
| Methods inherited from class adams.core.ConsoleObject |
|---|
getDebugging, getSystemErr, getSystemOut, sizeOf |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface adams.core.option.OptionHandler |
|---|
cleanUpOptions, getOptionManager |
| Methods inherited from interface adams.core.Destroyable |
|---|
destroy |
| Field Detail |
|---|
protected boolean m_Appending
protected SpreadSheet m_Header
protected boolean m_KeepExisting
protected boolean m_FileExists
protected String m_Table
protected Cell.ContentType[] m_Types
protected String[] m_ColumnNames
protected ColumnNameConversion m_ColumnNameConversion
protected String m_StringColumnSQL
protected int m_MaxStringLength
protected boolean m_AddCreateTable
protected boolean m_UseBackslashes
| Constructor Detail |
|---|
public SqlDumpSpreadSheetWriter()
| Method Detail |
|---|
public String globalInfo()
globalInfo in class AbstractOptionHandlerpublic void defineOptions()
defineOptions in interface OptionHandlerdefineOptions in class AbstractOptionHandlerprotected void initialize()
initialize in class AbstractOptionHandlerprotected void reset()
reset in class AbstractOptionHandlerpublic String getFormatDescription()
getFormatDescription in interface SpreadSheetWritergetFormatDescription in class AbstractSpreadSheetWriterpublic String[] getFormatExtensions()
getFormatExtensions in interface SpreadSheetWritergetFormatExtensions in class AbstractSpreadSheetWriterpublic boolean canAppend(SpreadSheet sheet)
canAppend in interface AppendableSpreadSheetWritersheet - the spreadsheet to append to the existing one
public void setAppending(boolean value)
setAppending in interface AppendableSpreadSheetWritervalue - true if to appendpublic boolean isAppending()
isAppending in interface AppendableSpreadSheetWriterpublic String appendingTipText()
appendingTipText in interface AppendableSpreadSheetWriterpublic void setKeepExisting(boolean value)
setKeepExisting in interface AppendableSpreadSheetWritervalue - if true then existing file is keptpublic boolean getKeepExisting()
getKeepExisting in interface AppendableSpreadSheetWriterpublic String keepExistingTipText()
keepExistingTipText in interface AppendableSpreadSheetWriterpublic void setTable(String value)
value - the namepublic String getTable()
public String tableTipText()
public void setColumnNameConversion(ColumnNameConversion value)
value - the conversionpublic ColumnNameConversion getColumnNameConversion()
public String columnNameConversionTipText()
public void setMaxStringLength(int value)
value - the maximumpublic int getMaxStringLength()
public String maxStringLengthTipText()
public void setStringColumnSQL(String value)
value - the SQL typepublic String getStringColumnSQL()
public String stringColumnSQLTipText()
public void setAddCreateTable(boolean value)
value - if true then a CREATE TABLE statement is output as wellpublic boolean getAddCreateTable()
public String addCreateTableTipText()
public void setUseBackslashes(boolean value)
value - if true then backslashes are usedpublic boolean getUseBackslashes()
public String useBackslashesTipText()
public void setFileExists(boolean value)
setFileExists in interface AppendableSpreadSheetWritervalue - true if the output file already existspublic boolean getFileExists()
getFileExists in interface AppendableSpreadSheetWriterprotected String format(double value)
value - the double value to turn into a string
protected String quoteString(String s)
s - the string to quote, if necessary
protected boolean getUseOutputStream()
getUseOutputStream in class AbstractSpreadSheetWriter
protected boolean doWrite(SpreadSheet content,
Writer writer)
doWrite in class AbstractSpreadSheetWritercontent - the spreadsheet to writewriter - the writer to write the spreadsheet to
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||