Package com.redwood.agent.api.rtx
Class RTXMetadata
- java.lang.Object
-
- com.redwood.agent.api.rtx.RTXMetadata
-
- All Implemented Interfaces:
Serializable
public class RTXMetadata extends Object implements Serializable
RTX Metadata: column definitions and sources.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RTXMetadata()
Create a new empty RTX metadata.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated 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 (ie.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
addColumn(String columnName, String columnDescription, RTXType columnType)
Add a new column with the specified name, description and type, the column will be added to the end of this metadata.void
addColumns(Collection<RTXColumn> newColumns)
Add a 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 (ie.void
addSource(RTXSource source)
Add a source.void
addSource(RTXSource source, String prefix)
Add a source.void
addSources(Collection<RTXSource> newSources)
Add multiple sourcesvoid
addSources(Collection<RTXSource> newSources, String prefix)
Add multiple sources with a prefix.void
assertAssignableFrom(RTXMetadata another)
Deprecated.protected void
assertColumnIndex(int index)
void
assertColumnsCompatible(RTXMetadata another)
Deprecated.<T> RTXColumn<T>
createColumn(String columnName, Class<T> columnClass)
Create, add and return a new column with the specified name and type, the column will be added to the end of this metadata.RTXColumn
getColumnByIndex(int columnIndex)
Get a column by index (0 based).RTXColumn
getColumnByName(String columnName)
Get a column by name (case-insensitive).int
getColumnIndex(String columnName)
Get the index of a column.Map<String,RTXColumn>
getColumnMap()
Get a map of columns.String
getColumnName(int columnIndex)
Get the name of a column.List<RTXColumn>
getColumns()
Get a list of columns.RTXType
getColumnType(int columnIndex)
Get the type of a column.RTXType
getColumnType(String columnName)
Get the type of a column.Map<String,RTXSource>
getSources()
Get a map of all sources.boolean
hasColumn(String columnName)
Does the metadata contain a column?boolean
isReadOnly()
Is this metadata read-only?void
setReadOnly()
Make the metadata read only, changing anything after this point will cause an exception to be thrown.String
toString()
-
-
-
Method Detail
-
setReadOnly
public void setReadOnly()
Make the metadata read only, changing anything after this point will cause an exception to be thrown.
-
addColumn
public void addColumn(RTXColumn column) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Add a new column with the name and type of an existing column, the column will be added to the end of this metadata (ie. the index of the input column is ignored).- Parameters:
column
- the column to get the name and type from.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
addColumn
public void addColumn(String columnName, String columnType) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Add a new column with the specified name and type, the column will be added to the end of this metadata.- Parameters:
columnName
- the column name.columnType
- the column type.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
addColumn
public void addColumn(String columnName, String columnDescription, RTXType columnType) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Add a new column with the specified name, description and type, the column will be added to the end of this metadata.- Parameters:
columnName
- the column name.columnDescription
- the column description.columnType
- the column type.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
addColumn
public void addColumn(String columnName, RTXType columnType) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Add a new column with the specified name and type, the column will be added to the end of this metadata.- Parameters:
columnName
- the column name.columnType
- the column type.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
createColumn
public <T> RTXColumn<T> createColumn(String columnName, Class<T> columnClass)
Create, add and return a new column with the specified name and type, the column will be added to the end of this metadata.- Parameters:
columnName
- the column name.columnClass
- the column type.- Returns:
- the new column.
- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
addColumns
public void addColumns(Collection<RTXColumn> newColumns) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Add a 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 (ie. the index of on each input column is ignored).- Parameters:
newColumns
- the columns to get the name and type from.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read-only.
-
getColumnByIndex
public RTXColumn getColumnByIndex(int columnIndex) throws RTXColumnRuntimeException
Get a column by index (0 based).- Parameters:
columnIndex
- the index (0 based).- Returns:
- the column if it exists.
- Throws:
RTXColumnRuntimeException
- if the column does not exist.
-
getColumnByName
public RTXColumn getColumnByName(String columnName) throws RTXColumnRuntimeException
Get a column by name (case-insensitive).- Parameters:
columnName
- the index (case-insensitive).- Returns:
- the column if it exists.
- Throws:
RTXColumnRuntimeException
- if the column does not exist.
-
getColumns
public List<RTXColumn> getColumns()
Get a list of columns.- Returns:
- an unmodifiable list of columns, the columns themselves are modifiable if the metadata is.
-
getColumnMap
public Map<String,RTXColumn> getColumnMap()
Get a map of columns.- Returns:
- an unmodifiable map of columns, the key is the column name (in lower case), the value is the column, the columns themselves are modifiable if the metadata is.
-
assertColumnIndex
protected void assertColumnIndex(int index) throws RTXColumnRuntimeException
- Throws:
RTXColumnRuntimeException
-
getColumnIndex
public int getColumnIndex(String columnName) throws RTXColumnRuntimeException
Get the index of a column.- Parameters:
columnName
- the name of the column (case insensitive)- Returns:
- the column index.
- Throws:
RTXColumnRuntimeException
- if the column does not exist.
-
hasColumn
public boolean hasColumn(String columnName)
Does the metadata contain a column?- Parameters:
columnName
- the name of the column (case insensitive)- Returns:
- true if the column is in the metadata, false otherwise.
-
getColumnName
public String getColumnName(int columnIndex) throws RTXColumnRuntimeException
Get the name of a column.- Parameters:
columnIndex
- the index of the column (0 based)- Returns:
- the column index.
- Throws:
RTXColumnRuntimeException
- if the column does not exist.
-
getColumnType
public RTXType getColumnType(int columnIndex) throws RTXColumnRuntimeException
Get the type of a column.- Parameters:
columnIndex
- the index of the column (0 based)- Returns:
- the column index.
- Throws:
RTXColumnRuntimeException
- if the column does not exist.
-
getColumnType
public RTXType getColumnType(String columnName) throws RTXColumnRuntimeException
Get the type of a column.- Parameters:
columnName
- the name of the column (case insensitive)- Returns:
- the column index.
- Throws:
RTXColumnRuntimeException
- if the column does not exist.
-
getSources
public Map<String,RTXSource> getSources()
Get a map of all sources.- Returns:
- a map of all sources.
-
addSource
public void addSource(RTXSource source) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Add a source.- Parameters:
source
- the source to add- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read only.
-
addSource
public void addSource(RTXSource source, String prefix) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Add a source.- Parameters:
source
- the source to addprefix
- the prefix to use for identifiers.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read only.
-
addSources
public void addSources(Collection<RTXSource> newSources) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Add multiple sources- Parameters:
newSources
- multiple sources.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read only.
-
addSources
public void addSources(Collection<RTXSource> newSources, String prefix) throws RTXMetadataRuntimeException, RTXMetadataReadOnlyRuntimeException
Add multiple sources with a prefix.- Parameters:
newSources
- multiple sources.prefix
- the prefix to use.- Throws:
RTXMetadataRuntimeException
- if an error occurs.RTXMetadataReadOnlyRuntimeException
- if the metadata is read only.
-
assertColumnsCompatible
@Deprecated public void assertColumnsCompatible(RTXMetadata another) throws RTXIncompatibleColumnException
Deprecated.- Throws:
RTXIncompatibleColumnException
-
assertAssignableFrom
@Deprecated public void assertAssignableFrom(RTXMetadata another) throws RTXIncompatibleColumnException
Deprecated.- Throws:
RTXIncompatibleColumnException
-
isReadOnly
public boolean isReadOnly()
Is this metadata read-only?- Returns:
- true if it is read-only, false otherwise.
-
-