Package com.redwood.scheduler.api.rtx
Class RTXWriter
- java.lang.Object
-
- com.redwood.scheduler.api.rtx.RTXWriter
-
- All Implemented Interfaces:
RTXConsumer
,Closeable
,AutoCloseable
public class RTXWriter extends Object implements RTXConsumer
Writer for RTX format.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumn(RTXColumn column)
Add a new column with the name and type of an existing column, the column will be added to the end of this metadata (i.e.void
addColumn(String columnName, RTXType columnType)
Add a new column with the specified name and type, the column will be added to the end of this metadata.void
addColumn(String columnName, String columnType)
Add a new column with the specified name and type, the column will be added to the end of this metadata.void
addColumns(Collection<RTXColumn> newColumns)
Add new columns based on the input columns, the columns will be added in the order that they occur in the list, to the end of this metadata (i.e.void
addRow(RTXRow row)
Adds arow
void
addRow(Object[] data)
Adds arow
with the supplied data, where the row will not have a key.void
addRow(Object[] data, String key)
Adds arow
with the supplied data and key.void
addSource(RTXSource source)
Add a source to theRTXMetadata
, which is set previously withRTXConsumer.setMetadata(RTXMetadata)
void
addSources(Collection<RTXSource> sources, String prefix)
Convenience method to add multiple sources, with a prefix, to theRTXMetadata
, which is set previously withRTXConsumer.setMetadata(RTXMetadata)
void
close()
void
flush()
Write any cached data to the underlying output mechanism.RTXMetadata
getMetadata()
int
getRowNumber()
void
setLogger(Logger newLog)
Replace the default logger with anotherLogger
.void
setMetadata(RTXMetadata newMetadata)
Sets theRTXMetadata
.void
setWriteComments(boolean newValue)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.redwood.scheduler.api.rtx.RTXConsumer
addSources, addSources, addSources, copyColumns, newRow
-
-
-
-
Constructor Detail
-
RTXWriter
public RTXWriter(OutputStream newOutputStream) throws RTXWriterException
- Throws:
RTXWriterException
-
RTXWriter
public RTXWriter(Writer newWriter) throws RTXWriterException
- Throws:
RTXWriterException
-
RTXWriter
public RTXWriter(String filename) throws RTXWriterException, FileNotFoundException
-
-
Method Detail
-
setWriteComments
public void setWriteComments(boolean newValue)
-
setLogger
public void setLogger(Logger newLog)
Description copied from interface:RTXConsumer
Replace the default logger with anotherLogger
.- Specified by:
setLogger
in interfaceRTXConsumer
-
addColumn
public void addColumn(RTXColumn column) throws RTXMetadataRuntimeException, RTXInRowDataRuntimeException, RTXMetadataReadOnlyRuntimeException
Description copied from interface:RTXConsumer
Add a new column with the name and type of an existing column, the column will be added to the end of this metadata (i.e. the index of the input column is ignored).- Specified by:
addColumn
in interfaceRTXConsumer
- Parameters:
column
- the column to get the name and type from.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXInRowDataRuntimeException
- when already data have been added. It is not allowed to add a newcolumn
to theRTXMetadata
, when alreadyRTXRows
have been added.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
addColumn
public void addColumn(String columnName, String columnType) throws RTXMetadataRuntimeException, RTXInRowDataRuntimeException, RTXMetadataReadOnlyRuntimeException
Description copied from interface:RTXConsumer
Add a new column with the specified name and type, the column will be added to the end of this metadata.- Specified by:
addColumn
in interfaceRTXConsumer
- Parameters:
columnName
- the column name.columnType
- the column type.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXInRowDataRuntimeException
- when already data have been added. It is not allowed to add a newcolumn
to theRTXMetadata
, when alreadyRTXRows
have been added.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
addColumn
public void addColumn(String columnName, RTXType columnType) throws RTXMetadataRuntimeException, RTXInRowDataRuntimeException, RTXMetadataReadOnlyRuntimeException
Description copied from interface:RTXConsumer
Add a new column with the specified name and type, the column will be added to the end of this metadata.- Specified by:
addColumn
in interfaceRTXConsumer
- Parameters:
columnName
- the column name.columnType
- the column type.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXInRowDataRuntimeException
- when already data have been added. It is not allowed to add a newcolumn
to theRTXMetadata
, when alreadyRTXRows
have been added.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
addColumns
public void addColumns(Collection<RTXColumn> newColumns) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Description copied from interface:RTXConsumer
Add new columns based on the input columns, the columns will be added in the order that they occur in the list, to the end of this metadata (i.e. the index of on each input column is ignored).- Specified by:
addColumns
in interfaceRTXConsumer
- Parameters:
newColumns
- the columns to get the name and type from.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
addRow
public void addRow(Object[] data) throws RTXWriterException, RTXColumnRuntimeException
Description copied from interface:RTXConsumer
Adds arow
with the supplied data, where the row will not have a key.- Specified by:
addRow
in interfaceRTXConsumer
- Parameters:
data
- the values for the different cells in the new row. When the row has more columns than supplied indata
, then the rest of the cells will be empty.- Throws:
RTXWriterException
RTXColumnRuntimeException
-
addRow
public void addRow(Object[] data, String key) throws RTXWriterException, RTXColumnRuntimeException
Description copied from interface:RTXConsumer
Adds arow
with the supplied data and key.- Specified by:
addRow
in interfaceRTXConsumer
- Parameters:
data
-key
- the optional key of this row, which is only a label and can be used as reference to other data structures. No uniqueness is provided and keys cannot be used to access rows directly.- Throws:
RTXWriterException
RTXColumnRuntimeException
-
addRow
public void addRow(RTXRow row) throws RTXWriterException, RTXColumnRuntimeException
Description copied from interface:RTXConsumer
Adds arow
- Specified by:
addRow
in interfaceRTXConsumer
- Throws:
RTXWriterException
RTXColumnRuntimeException
-
addSource
public void addSource(RTXSource source) throws RTXMetadataRuntimeException, RTXInRowDataRuntimeException, RTXMetadataReadOnlyRuntimeException
Description copied from interface:RTXConsumer
Add a source to theRTXMetadata
, which is set previously withRTXConsumer.setMetadata(RTXMetadata)
- Specified by:
addSource
in interfaceRTXConsumer
- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXInRowDataRuntimeException
- when already data have been added. It is not allowed to add a newsource
to theRTXMetadata
, when alreadyRTXRows
have been added.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.- See Also:
RTXConsumer.setMetadata(RTXMetadata)
-
addSources
public void addSources(Collection<RTXSource> sources, String prefix) throws RTXMetadataRuntimeException, RTXInRowDataRuntimeException, RTXMetadataReadOnlyRuntimeException
Description copied from interface:RTXConsumer
Convenience method to add multiple sources, with a prefix, to theRTXMetadata
, which is set previously withRTXConsumer.setMetadata(RTXMetadata)
- Specified by:
addSources
in interfaceRTXConsumer
- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXInRowDataRuntimeException
- when already data have been added. It is not allowed to add a newsource
to theRTXMetadata
, when alreadyRTXRows
have been added.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.- See Also:
RTXConsumer.addSource(RTXSource)
,RTXConsumer.setMetadata(RTXMetadata)
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceRTXConsumer
-
flush
public void flush() throws XMLStreamException
Description copied from interface:RTXConsumer
Write any cached data to the underlying output mechanism.- Specified by:
flush
in interfaceRTXConsumer
- Throws:
XMLStreamException
-
getMetadata
public RTXMetadata getMetadata()
- Specified by:
getMetadata
in interfaceRTXConsumer
- Returns:
- the
RTXMetadata
- See Also:
RTXConsumer.setMetadata(RTXMetadata)
-
setMetadata
public void setMetadata(RTXMetadata newMetadata) throws RTXColumnRuntimeException, RTXInRowDataRuntimeException
Description copied from interface:RTXConsumer
Sets theRTXMetadata
. This is not allowed anymore, when data was already added, but needs to be set before any data is added.- Specified by:
setMetadata
in interfaceRTXConsumer
- Throws:
RTXColumnRuntimeException
RTXInRowDataRuntimeException
- when already data have been added. It is not allowed to set newRTXMetadata
, when alreadyRTXRows
have been added.- See Also:
RTXConsumer.getMetadata()
-
getRowNumber
public final int getRowNumber()
- Specified by:
getRowNumber
in interfaceRTXConsumer
- Returns:
- the current row number, i.e. the row number of added rows. Initially it returns 0, meaning no row has been added.
-
-