com.partnersoft.io
Class DataRecordSink

java.lang.Object
  extended by com.partnersoft.io.DataRecordSink
Direct Known Subclasses:
SqlDataRecordInsertOrUpdateSink, SqlDataRecordInsertSink, SqlDataRecordUpdateSink

public abstract class DataRecordSink
extends java.lang.Object

A sink for data records, which are written sequentially.

"Data record" is used here in the classic, tabular sense, of a structure with predefined field names, and record-specified field values. "Record" is often used synonymously with "row"; "field" is often used synonymously with "column".

Copyright 2009 Partner Software, Inc.

Version:
$Id$
Author:
Rich Stepanski

Constructor Summary
DataRecordSink(java.util.List<java.lang.String> fieldNames)
          Creates a new DataRecordSink with the specified field names.
DataRecordSink(java.lang.String... fieldNames)
          Creates a new DataRecordSink with the specified field names.
 
Method Summary
 void close()
          Closes sink when writing is finished.
protected abstract  void closeImp()
           
 java.lang.Exception getException()
          Returns any exception that may have happened during open, close, or write.
 java.lang.String[] getFieldNames()
          Gets the field names array.
 void open()
          Opens sink for writing.
protected abstract  void openImp()
           
 void write(java.util.List<java.lang.Object> payload)
          Writes List to sink.
 void write(Naming<java.lang.Object> payload)
          Writes Naming to sink.
 void write(java.lang.Object... payload)
          Writes Object array to sink.
protected abstract  void writeImp(java.util.List<java.lang.Object> payload)
           
protected abstract  void writeImp(Naming<java.lang.Object> payload)
           
protected abstract  void writeImp(java.lang.Object... payload)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataRecordSink

public DataRecordSink(java.util.List<java.lang.String> fieldNames)
Creates a new DataRecordSink with the specified field names.


DataRecordSink

public DataRecordSink(java.lang.String... fieldNames)
Creates a new DataRecordSink with the specified field names.

Method Detail

open

public void open()
Opens sink for writing.


close

public void close()
Closes sink when writing is finished.


write

public void write(java.lang.Object... payload)
Writes Object array to sink.

Parameters:
payload - to write in same order as field names.

write

public void write(Naming<java.lang.Object> payload)
Writes Naming to sink.

Parameters:
payload - to write in same order as field names.

write

public void write(java.util.List<java.lang.Object> payload)
Writes List to sink.

Parameters:
payload - to write in same order as field names.

getException

public java.lang.Exception getException()
Returns any exception that may have happened during open, close, or write. Returns null otherwise.

Returns:
last Exception that happened, or null if none have.

getFieldNames

public java.lang.String[] getFieldNames()
Gets the field names array. The names are in the same order as they are expected in the various write() methods.

Returns:
array of String field names

openImp

protected abstract void openImp()
                         throws java.lang.Exception
Throws:
java.lang.Exception

closeImp

protected abstract void closeImp()
                          throws java.lang.Exception
Throws:
java.lang.Exception

writeImp

protected abstract void writeImp(Naming<java.lang.Object> payload)
                          throws java.lang.Exception
Throws:
java.lang.Exception

writeImp

protected abstract void writeImp(java.lang.Object... payload)
                          throws java.lang.Exception
Throws:
java.lang.Exception

writeImp

protected abstract void writeImp(java.util.List<java.lang.Object> payload)
                          throws java.lang.Exception
Throws:
java.lang.Exception