ThinkUI Data Generator 1.0.2 API

thinkui.datagen.io
Class DefaultDataObjectWriter

java.lang.Object
  extended bythinkui.db.io.AbstractDataObjectWriter
      extended bythinkui.datagen.io.DefaultDataObjectWriter
All Implemented Interfaces:
DataObjectWriter

public class DefaultDataObjectWriter
extends AbstractDataObjectWriter

Extends AbstractDataObjectWriter to implement a DataObjectWriter for writing the generated data to the configured database table.


Constructor Summary
DefaultDataObjectWriter()
          DefaultDataObjectWriter constructor.
 
Method Summary
 void close()
          Closes the database connection (if any) and shutdown any embedded database.
 void commit()
          Commit the current database transaction (if any).
 int getCommitInterval()
           
 int getCount()
           
 thinkui.db.jdbc.JDBCDataObjectManager getDataObjectManager()
           
 int getMaxNumErrors()
           
 int getNumErrors()
           
 java.lang.String getOutputMode()
           
 java.lang.String getTableName()
           
 void init()
          Initializes the writer by processing the "outputMode" setting and resetting the various counters.
 boolean isOutputSQL()
           
 boolean isRequireSyncOnInsert()
           
 void rollback()
          Rollback the current database transaction (if any).
 void setCommitInterval(int commitInterval)
          Sets the interval between automatically committing the current transaction.
 void setDataObjectManager(thinkui.db.jdbc.JDBCDataObjectManager dataObjectManager)
          Sets the data object manager to use to write the data objects.
 void setMaxNumErrors(int maxNumErrors)
          Sets the maximum number of errors that can occur before aborting.
 void setOutputMode(java.lang.String outputMode)
          Sets the output mode.
 void setOutputSQL(boolean outputSQL)
          Sets whether or not to output the SQL.
 void setRequireSyncOnInsert(boolean requireSyncOnInsert)
          Sets whether or not synchronization is required on insert.
 void setTableName(java.lang.String tableName)
          Sets the table name.
 void write(DataClass dataClass)
          Write the given data class.
 DataObject write(DataObject dataObject)
          Write the given data object.
 
Methods inherited from class thinkui.db.io.AbstractDataObjectWriter
getFormatFactory, getOutputStream, getWriter, isWriteHeader, isWriteUppercase, setFormatFactory, setOutputStream, setWriteHeader, setWriter, setWriteUppercase
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDataObjectWriter

public DefaultDataObjectWriter()
DefaultDataObjectWriter constructor.

Method Detail

close

public void close()
           throws java.lang.Exception
Closes the database connection (if any) and shutdown any embedded database. After calling this method, no more calls to write() method can be performed.

Specified by:
close in interface DataObjectWriter
Overrides:
close in class AbstractDataObjectWriter
Throws:
java.lang.Exception

commit

public void commit()
            throws java.lang.Exception
Commit the current database transaction (if any).

Specified by:
commit in interface DataObjectWriter
Overrides:
commit in class AbstractDataObjectWriter
Throws:
java.lang.Exception

getCommitInterval

public final int getCommitInterval()
Returns:
the interval between automatically committing or -1.

getCount

public final int getCount()
Returns:
the number of objects that has been inserted.

getDataObjectManager

public final thinkui.db.jdbc.JDBCDataObjectManager getDataObjectManager()
Returns:
the data object manager to use to write the data objects.

getMaxNumErrors

public final int getMaxNumErrors()
Returns:
the maximum number of errors that can occur before aborting.

getNumErrors

public final int getNumErrors()
Returns:
the number of errors that has been encountered.

getOutputMode

public final java.lang.String getOutputMode()
Returns:
the output mode.

getTableName

public final java.lang.String getTableName()
Returns:
the table name or null.

init

public void init()
          throws java.lang.Exception
Initializes the writer by processing the "outputMode" setting and resetting the various counters. This method should only be called once before invoking the write() method.

Specified by:
init in interface DataObjectWriter
Overrides:
init in class AbstractDataObjectWriter
Throws:
java.lang.Exception

isOutputSQL

public final boolean isOutputSQL()
Returns:
the whether or not to output the SQL.

isRequireSyncOnInsert

public final boolean isRequireSyncOnInsert()
Returns:
the whether or not synchronization is required on insert.

rollback

public void rollback()
              throws java.lang.Exception
Rollback the current database transaction (if any).

Specified by:
rollback in interface DataObjectWriter
Overrides:
rollback in class AbstractDataObjectWriter
Throws:
java.lang.Exception

setCommitInterval

public final void setCommitInterval(int commitInterval)
Sets the interval between automatically committing the current transaction. If a negative interval is set, no commit will occur. Instead, the transaction must be committed at a higher level.


setDataObjectManager

public final void setDataObjectManager(thinkui.db.jdbc.JDBCDataObjectManager dataObjectManager)
Sets the data object manager to use to write the data objects.


setMaxNumErrors

public final void setMaxNumErrors(int maxNumErrors)
Sets the maximum number of errors that can occur before aborting. A negative value indicates that all errors will be ignored and there will be no maximum number of errors.


setOutputMode

public final void setOutputMode(java.lang.String outputMode)
Sets the output mode.


setOutputSQL

public final void setOutputSQL(boolean outputSQL)
Sets whether or not to output the SQL.


setRequireSyncOnInsert

public final void setRequireSyncOnInsert(boolean requireSyncOnInsert)
Sets whether or not synchronization is required on insert.


setTableName

public final void setTableName(java.lang.String tableName)
Sets the table name.


write

public final void write(DataClass dataClass)
                 throws java.lang.Exception
Write the given data class.

Throws:
java.lang.Exception

write

public DataObject write(DataObject dataObject)
                 throws java.lang.Exception
Write the given data object.

The actually data object that was written (may be different from the data object that was passed in) is returned.

This is useful for example, if the primary key column of the database object is needed in a subsequent step.

Returns:
the actual data object that was written.
Throws:
java.lang.Exception

ThinkUI Data Generator 1.0.2 API

Copyright © 2007-2009. ThinkUI Software Inc. All rights reserved.