Class GoogleSheetWriter
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.core.DataEndpoint
com.northconcepts.datapipeline.core.DataWriter
com.northconcepts.datapipeline.core.AbstractWriter
com.northconcepts.datapipeline.google.sheets.GoogleSheetWriter
Writes records to one sheet of a Google Sheets spreadsheet opened as a
GoogleSheetDocument, creating the sheet
when its name is new and clearing the target block first. Values are sent in batches of setBatchSize(int) rows;
nulls become empty cells and dates, times and binary values are written as text.-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
FieldsFields inherited from class com.northconcepts.datapipeline.core.AbstractWriter
currentRecordFields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionGoogleSheetWriter(GoogleSheetDocument document) Creates a writer for the given document, which must be opened by the caller and is not closed by this writer unlesssetAutoCloseDocument(boolean)is enabled. -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.voidclose()Indicates that this endpoint has finished reading or writing.intintintgetRange()intbooleanIndicates if the GoogleSheetDocument should be closed when this endpoint is closed.voidopen()Makes this endpoint ready for reading or writing.setAutoCloseDocument(boolean autoCloseDocument) Indicates if the GoogleSheetDocument should be closed when this endpoint is closed.setBatchSize(int batchSize) setDescription(String description) Sets the optional text shown for this endpoint inEndpoint.toString()and exception properties.setFieldNamesInFirstRow(boolean fieldNamesInFirstRow) Indicates if a header row of field names is written before the first record (default is true); must be called beforeAbstractWriter.open().setFirstColumnIndex(int firstColumnIndex) Sets the 0-based column that each record's first field is written to when no range is set (defaults to 0).setFirstRowIndex(int firstRowIndex) Sets the 0-based row that the first record (or the header row) is written to when no range is set (defaults to 0).Sets the A1-notation range to write, such asA1:B3orSheet1!A1:B3; its first cell replaces the first row and column indexes and only that range is cleared (default is null).setSheetIndex(int sheetIndex) Sets the 0-based index of the sheet to write when no sheet name or range names one (defaults to 0).setSheetName(String sheetName) Sets the name of the sheet to write, reusing an existing sheet by that name or creating it; when set, it is used instead of the sheet index (default is null).protected voidwriteRecord(Record record) Writes one row; called first for the header row (seeAbstractWriter.isHeaderRow()) when field names are written, then for each record.Methods inherited from class com.northconcepts.datapipeline.core.AbstractWriter
createHeaderRecord, isFieldNamesInFirstRow, isHeaderRow, write, writeImplMethods inherited from class com.northconcepts.datapipeline.core.DataWriter
available, getNestedEndpoint, getNestedWriter, getRootEndpoint, getRootWriter, getWriterMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime
-
Field Details
-
DEFAULT_BATCH_SIZE
public static final int DEFAULT_BATCH_SIZE- See Also:
-
-
Constructor Details
-
GoogleSheetWriter
Creates a writer for the given document, which must be opened by the caller and is not closed by this writer unlesssetAutoCloseDocument(boolean)is enabled.
-
-
Method Details
-
addExceptionProperties
Description copied from class:EndpointAdds this endpoint's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Overrides:
addExceptionPropertiesin classAbstractWriter
-
open
public void open()Description copied from class:DataEndpointMakes this endpoint ready for reading or writing.- Overrides:
openin classAbstractWriter
-
close
public void close()Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein classDataEndpoint
-
writeRecord
Description copied from class:AbstractWriterWrites one row; called first for the header row (seeAbstractWriter.isHeaderRow()) when field names are written, then for each record.- Specified by:
writeRecordin classAbstractWriter- Throws:
Throwable
-
getDocument
-
setAutoCloseDocument
Indicates if the GoogleSheetDocument should be closed when this endpoint is closed. The default isfalse. -
isAutoCloseDocument
public boolean isAutoCloseDocument()Indicates if the GoogleSheetDocument should be closed when this endpoint is closed. The default isfalse. -
getSheetName
-
setSheetName
Sets the name of the sheet to write, reusing an existing sheet by that name or creating it; when set, it is used instead of the sheet index (default is null). -
getSheetIndex
public int getSheetIndex() -
setSheetIndex
Sets the 0-based index of the sheet to write when no sheet name or range names one (defaults to 0). -
getFirstColumnIndex
public int getFirstColumnIndex() -
setFirstColumnIndex
Sets the 0-based column that each record's first field is written to when no range is set (defaults to 0). -
getFirstRowIndex
public int getFirstRowIndex() -
setFirstRowIndex
Sets the 0-based row that the first record (or the header row) is written to when no range is set (defaults to 0). -
getRange
-
setRange
Sets the A1-notation range to write, such asA1:B3orSheet1!A1:B3; its first cell replaces the first row and column indexes and only that range is cleared (default is null). -
getBatchSize
public int getBatchSize() -
setBatchSize
-
setFieldNamesInFirstRow
Description copied from class:AbstractWriterIndicates if a header row of field names is written before the first record (default is true); must be called beforeAbstractWriter.open().- Overrides:
setFieldNamesInFirstRowin classAbstractWriter
-
setDescription
Description copied from class:EndpointSets the optional text shown for this endpoint inEndpoint.toString()and exception properties.- Overrides:
setDescriptionin classEndpoint
-