Package com.redwood.agent.api.rtx
Class RTXWriter
- java.lang.Object
-
- com.redwood.agent.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 voidaddColumn(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.voidaddColumn(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.voidaddColumn(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.voidaddColumns(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.voidaddRow(RTXRow row)Adds arowvoidaddRow(Object[] data)Adds arowwith the supplied data, where the row will not have a key.voidaddRow(Object[] data, String key)Adds arowwith the supplied data and key.voidaddSource(RTXSource source)Add a source to theRTXMetadata, which is set previously withRTXConsumer.setMetadata(RTXMetadata)voidaddSources(Collection<RTXSource> sources, String prefix)Convenience method to add multiple sources, with a prefix, to theRTXMetadata, which is set previously withRTXConsumer.setMetadata(RTXMetadata)voidclose()voidflush()Write any cached data to the underlying output mechanism.RTXMetadatagetMetadata()intgetRowNumber()voidsetLogger(Logger newLog)Replace the default logger with anotherLogger.voidsetMetadata(RTXMetadata newMetadata)Sets theRTXMetadata.voidsetWriteComments(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.agent.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:RTXConsumerReplace the default logger with anotherLogger.- Specified by:
setLoggerin interfaceRTXConsumer
-
addColumn
public void addColumn(RTXColumn column) throws RTXMetadataRuntimeException, RTXInRowDataRuntimeException, RTXMetadataReadOnlyRuntimeException
Description copied from interface:RTXConsumerAdd 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:
addColumnin 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 newcolumnto theRTXMetadata, when alreadyRTXRowshave 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:RTXConsumerAdd a new column with the specified name and type, the column will be added to the end of this metadata.- Specified by:
addColumnin 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 newcolumnto theRTXMetadata, when alreadyRTXRowshave 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:RTXConsumerAdd a new column with the specified name and type, the column will be added to the end of this metadata.- Specified by:
addColumnin 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 newcolumnto theRTXMetadata, when alreadyRTXRowshave been added.RTXMetadataReadOnlyRuntimeException- if the metadata is read-only.
-
addColumns
public void addColumns(Collection<RTXColumn> newColumns) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Description copied from interface:RTXConsumerAdd 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:
addColumnsin 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:RTXConsumerAdds arowwith the supplied data, where the row will not have a key.- Specified by:
addRowin 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:
RTXWriterExceptionRTXColumnRuntimeException
-
addRow
public void addRow(Object[] data, String key) throws RTXWriterException, RTXColumnRuntimeException
Description copied from interface:RTXConsumerAdds arowwith the supplied data and key.- Specified by:
addRowin 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:
RTXWriterExceptionRTXColumnRuntimeException
-
addRow
public void addRow(RTXRow row) throws RTXWriterException, RTXColumnRuntimeException
Description copied from interface:RTXConsumerAdds arow- Specified by:
addRowin interfaceRTXConsumer- Throws:
RTXWriterExceptionRTXColumnRuntimeException
-
addSource
public void addSource(RTXSource source) throws RTXMetadataRuntimeException, RTXInRowDataRuntimeException, RTXMetadataReadOnlyRuntimeException
Description copied from interface:RTXConsumerAdd a source to theRTXMetadata, which is set previously withRTXConsumer.setMetadata(RTXMetadata)- Specified by:
addSourcein interfaceRTXConsumer- Throws:
RTXMetadataRuntimeException- if an error occurs.RTXInRowDataRuntimeException- when already data have been added. It is not allowed to add a newsourceto theRTXMetadata, when alreadyRTXRowshave 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:RTXConsumerConvenience method to add multiple sources, with a prefix, to theRTXMetadata, which is set previously withRTXConsumer.setMetadata(RTXMetadata)- Specified by:
addSourcesin interfaceRTXConsumer- Throws:
RTXMetadataRuntimeException- if an error occurs.RTXInRowDataRuntimeException- when already data have been added. It is not allowed to add a newsourceto theRTXMetadata, when alreadyRTXRowshave been added.RTXMetadataReadOnlyRuntimeException- if the metadata is read-only.- See Also:
RTXConsumer.addSource(RTXSource),RTXConsumer.setMetadata(RTXMetadata)
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceRTXConsumer
-
flush
public void flush() throws XMLStreamExceptionDescription copied from interface:RTXConsumerWrite any cached data to the underlying output mechanism.- Specified by:
flushin interfaceRTXConsumer- Throws:
XMLStreamException
-
getMetadata
public RTXMetadata getMetadata()
- Specified by:
getMetadatain interfaceRTXConsumer- Returns:
- the
RTXMetadata - See Also:
RTXConsumer.setMetadata(RTXMetadata)
-
setMetadata
public void setMetadata(RTXMetadata newMetadata) throws RTXColumnRuntimeException, RTXInRowDataRuntimeException
Description copied from interface:RTXConsumerSets theRTXMetadata. This is not allowed anymore, when data was already added, but needs to be set before any data is added.- Specified by:
setMetadatain interfaceRTXConsumer- Throws:
RTXColumnRuntimeExceptionRTXInRowDataRuntimeException- when already data have been added. It is not allowed to set newRTXMetadata, when alreadyRTXRowshave been added.- See Also:
RTXConsumer.getMetadata()
-
getRowNumber
public final int getRowNumber()
- Specified by:
getRowNumberin interfaceRTXConsumer- Returns:
- the current row number, i.e. the row number of added rows. Initially it returns 0, meaning no row has been added.
-
-