public interface CyTable extends CyIdentifiable
org.cytoscape.model
document.
A column name can be broken down into two parts, a "namespace" and a "name". The namespace and name can be combined into a String by separating them with a "::", for example: "MyNamespace::MyName". The namespace part is optional, for example the column name "MyName" does not have a namespace. All methods that take a namespace argument will accept null to indicate no namespace. All of the default network columns created by Cytoscape do not have a namespace.
Apps are encouraged to put any columns they create into a namespace. The advantages of doing this are:
Case is ignored when column names are compared, or example "MyColumnName" and "mycolumnname" are equivalent. This also applies to namespaces, for example "MyNamespace::MyName" and "mynamespace::myname" are equivalent.
Whitespace is significant in both the namespace and the name (for historical reasons), for example " mynamespace ::myname" is in the namespace " mynamespace ". The empty string is a valid name for a namespace, for example "::myname" is in the "" namespace. It is highly recommended not to use whitespace in namespace identifiers, stick with alphanumeric characters and underscores.
Pick a namespace identifier that is between 6-15 characters in length that does not contain whitespace or special characters. Good examples are "EnrichmentMap", "clusterMaker" or "WordCloud".
Module: model-api
To use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>model-api</artifactId> </dependency>
Modifier and Type | Interface and Description |
---|---|
static class |
CyTable.Mutability
Mutability of the table specifies whether or not it is able to be deleted..
|
SUID
Modifier and Type | Method and Description |
---|---|
String |
addVirtualColumn(String virtualColumn,
String sourceColumn,
CyTable sourceTable,
String targetJoinKey,
boolean isImmutable)
Adds a "virtual" column to the the current table.
|
void |
addVirtualColumns(CyTable sourceTable,
String targetJoinKey,
boolean isImmutable)
Adds all columns in another table as "virtual" columns to the the current table.
|
int |
countMatchingRows(String fullyQualifiedName,
Object value)
Returns the number of rows with the in the specified column with the specified value in the user namespace.
|
default int |
countMatchingRows(String namespace,
String columnName,
Object value)
Returns the number of rows with the in the specified column with the specified value.
|
<T> void |
createColumn(String fullyQualifiedName,
Class<? extends T> type,
boolean isImmutable)
Create a column of the specified name and the specified type.
|
<T> void |
createColumn(String fullyQualifiedName,
Class<? extends T> type,
boolean isImmutable,
T defaultValue)
Create a column of the specified name and the specified type.
|
default <T> void |
createColumn(String namespace,
String columnName,
Class<? extends T> type,
boolean isImmutable)
Create a column of the specified name and the specified type in the specified namespace.
|
default <T> void |
createColumn(String namespace,
String columnName,
Class<? extends T> type,
boolean isImmutable,
T defaultValue)
Create a column of the specified name and the specified type in the specified namespace.
|
<T> void |
createListColumn(String fullyQualifiedName,
Class<T> listElementType,
boolean isImmutable)
Create a column of Lists with the specified name and the specified element type.
|
<T> void |
createListColumn(String fullyQualifiedName,
Class<T> listElementType,
boolean isImmutable,
List<T> defaultValue)
Create a column of Lists with the specified name and the specified element type.
|
default <T> void |
createListColumn(String namespace,
String columnName,
Class<T> listElementType,
boolean isImmutable)
Create a column of Lists with the specified name and the specified element type in the specified namespace.
|
default <T> void |
createListColumn(String namespace,
String columnName,
Class<T> listElementType,
boolean isImmutable,
List<T> defaultValue)
Create a column of Lists with the specified name and the specified element type in the specified namespace.
|
void |
deleteColumn(String fullyQualifiedName)
Will delete the column with the specified fully-qualified name.
|
default void |
deleteColumn(String namespace,
String columnName)
Will delete the column of the specified name in the specified namespace.
|
boolean |
deleteRows(Collection<?> primaryKeys)
Deletes the rows corresponding to the given primary keys and returns true if
at least one row was deleted.
|
List<CyRow> |
getAllRows()
Return a list of all the rows stored in this data table.
|
CyColumn |
getColumn(String fullyQualifiedName)
Returns the column with the specified fully-qualified name.
|
default CyColumn |
getColumn(String namespace,
String name)
Returns the column for the specified name in the specified namespace.
|
Collection<CyColumn> |
getColumns()
Returns the column types for all columns in this table.
|
default Collection<CyColumn> |
getColumns(String namespace)
Returns the column types for all columns in this table in the given namespace.
|
String |
getLastInternalError()
Returns a descriptive message for certain internal errors.
|
<T> Collection<T> |
getMatchingKeys(String fullyQualifiedName,
Object value,
Class<T> type)
Returns all the keys of a specified column that match the given value.
|
default <T> Collection<T> |
getMatchingKeys(String namespace,
String columnName,
Object value,
Class<T> type)
Returns all the keys of a specified column that match the given value.
|
Collection<CyRow> |
getMatchingRows(String fullyQualifiedName,
Object value)
Returns all the rows of a specified column that contain a certain value for that column.
|
default Collection<CyRow> |
getMatchingRows(String namespace,
String columnName,
Object value)
Returns all the rows of a specified column that contain a certain value for that column.
|
CyTable.Mutability |
getMutability()
The table can be deleted if this returns Mutability.MUTABLE, otherwise it cannot be
deleted!
|
default Collection<String> |
getNamespaces()
Returns all the namespaces used in the table.
|
CyColumn |
getPrimaryKey()
Returns the column type of the primary key for this table.
|
CyRow |
getRow(Object primaryKey)
Returns the row specified by the primary key object and if a row
for the specified key does not yet exist in the table, a new row
will be created and the new row will be returned.
|
int |
getRowCount()
Returns the number of rows in this table.
|
SavePolicy |
getSavePolicy()
Returns how (or if) this CyTable should be saved.
|
String |
getTitle()
Returns a human readable name for the CyTable.
|
boolean |
isPublic()
A public CyTable is a table that is accessible to the user through the user
interface.
|
boolean |
rowExists(Object primaryKey)
Returns true if a row exists for the specified primary key and false otherwise.
|
void |
setPublic(boolean isPublic)
Sets the privacy flag for the CyTable.
|
void |
setSavePolicy(SavePolicy policy)
Sets how (or if) this CyTable should be saved.
|
void |
setTitle(String title)
Allows the title of the table to be set.
|
void |
swap(CyTable otherTable)
Swaps the contents and properties (such as mutability) of "otherTable" with this table.
|
getSUID
boolean isPublic()
void setPublic(boolean isPublic)
isPublic
- if true, the table will be public and if false, the table will be private.CyTable.Mutability getMutability()
String getTitle()
void setTitle(String title)
title
- The human readable title for the CyTable suitable for use in a user
interface.CyColumn getPrimaryKey()
CyColumn getColumn(String fullyQualifiedName)
fullyQualifiedName
- The fully-qualified name of the column, not null.getColumn(String, String)
default CyColumn getColumn(String namespace, String name)
name
- The name of the column, not null.namespace
- The namespace of the column, or null to indicate no namespace.Collection<CyColumn> getColumns()
CyColumn
objects that describe all columns in this table.default Collection<CyColumn> getColumns(String namespace)
namespace
- The namespace, or null to indicate no namespace.CyColumn
objects that describe all columns in the given namespace.default Collection<String> getNamespaces()
void deleteColumn(String fullyQualifiedName)
ColumnDeletedEvent
will be fired.
Default columns created by Cytoscape do not have a namespace.fullyQualifiedName
- The fully-qualified name of the column, not null.deleteColumn(String, String)
default void deleteColumn(String namespace, String columnName)
ColumnDeletedEvent
will be fired.columnName
- The name identifying the attribute, must not be null.namespace
- The namespace of the column, or null to indicate no namespace.<T> void createColumn(String fullyQualifiedName, Class<? extends T> type, boolean isImmutable)
T
- The generic type of the column.fullyQualifiedName
- The fully-qualified name identifying the attribute.type
- The type of the column.isImmutable
- if true, this column can never be deletedcreateColumn(String, String, Class, boolean)
default <T> void createColumn(String namespace, String columnName, Class<? extends T> type, boolean isImmutable)
T
- The generic type of the column.columnName
- The name identifying the attribute.namespace
- The namespace for the column, or null to indicate no namespace.type
- The type of the column.isImmutable
- if true, this column can never be deleted<T> void createColumn(String fullyQualifiedName, Class<? extends T> type, boolean isImmutable, T defaultValue)
T
- The generic type of the column.fullyQualifiedName
- The fully-qualified name identifying the attribute.type
- The type of the column.isImmutable
- if true, this column can never be deleteddefaultValue
- The default value for the column. Must be of the specified type or null.createColumn(String, String, Class, boolean, Object)
default <T> void createColumn(String namespace, String columnName, Class<? extends T> type, boolean isImmutable, T defaultValue)
T
- The generic type of the column.columnName
- The name identifying the attribute.namespace
- The namespace for the column, or null to indicate no namespace.type
- The type of the column.isImmutable
- if true, this column can never be deleteddefaultValue
- The default value for the column. Must be of the specified type or null.<T> void createListColumn(String fullyQualifiedName, Class<T> listElementType, boolean isImmutable)
T
- The generic type of the elements of the list.fullyQualifiedName
- The fully-qualified name identifying the attribute.listElementType
- The type of the elements of the list.isImmutable
- if true, this column can never be deletedcreateListColumn(String, String, Class, boolean)
default <T> void createListColumn(String namespace, String columnName, Class<T> listElementType, boolean isImmutable)
T
- The generic type of the elements of the list.columnName
- The name identifying the attribute.namespace
- The namespace for the column, or null to indicate no namespace.listElementType
- The type of the elements of the list.isImmutable
- if true, this column can never be deleted<T> void createListColumn(String fullyQualifiedName, Class<T> listElementType, boolean isImmutable, List<T> defaultValue)
T
- The generic type of the elements of the list.fullyQualifiedName
- The fully-qualified name identifying the attribute.listElementType
- The type of the elements of the list.isImmutable
- if true, this column can never be deleteddefaultValue
- A default list for the column. Must be a List of the specified element type or null.createListColumn(String, String, Class, boolean, List)
default <T> void createListColumn(String namespace, String columnName, Class<T> listElementType, boolean isImmutable, List<T> defaultValue)
T
- The generic type of the elements of the list.columnName
- The name identifying the attribute.namespace
- The namespace for the column, or null to indicate no namespace.listElementType
- The type of the elements of the list.isImmutable
- if true, this column can never be deleteddefaultValue
- A default list for the column. Must be a List of the specified element type or null.CyRow getRow(Object primaryKey)
primaryKey
- The primary key index of the row to return.CyRow
identified by the specified key or a new
row identified by the key if one did not already exist.boolean rowExists(Object primaryKey)
primaryKey
- The primary key index of the row.boolean deleteRows(Collection<?> primaryKeys)
primaryKeys
- The primary keys of the rows to delete.List<CyRow> getAllRows()
String getLastInternalError()
Collection<CyRow> getMatchingRows(String fullyQualifiedName, Object value)
fullyQualifiedName
- the fully-qualified column name for which we want the rowsvalue
- the value for which we want the rows that contain itgetMatchingRows(String, String, Object)
default Collection<CyRow> getMatchingRows(String namespace, String columnName, Object value)
CyTable#USER_NAMESPACE
namespace.columnName
- the column for which we want the rowsnamespace
- the namespace that contains the column.value
- the value for which we want the rows that contain it<T> Collection<T> getMatchingKeys(String fullyQualifiedName, Object value, Class<T> type)
fullyQualifiedName
- the fully-qualified column name for which we want the row keysvalue
- the value for which we want the rows that contain itClassCastException
- if the keys are not of the given typegetMatchingKeys(String, String, Object, Class)
default <T> Collection<T> getMatchingKeys(String namespace, String columnName, Object value, Class<T> type)
CyTable#USER_NAMESPACE
namespace.columnName
- the column for which we want the row keysnamespace
- the namespace that contains the columnvalue
- the value for which we want the rows that contain itClassCastException
- if the keys are not of the given typeint countMatchingRows(String fullyQualifiedName, Object value)
fullyQualifiedName
- the fully-qualified column name to checkvalue
- the value we want to check forcountMatchingRows(String, String, Object)
default int countMatchingRows(String namespace, String columnName, Object value)
CyTable#USER_NAMESPACE
namespace.columnName
- the column to checknamespace
- the namespace that contains the columnvalue
- the value we want to check forint getRowCount()
String addVirtualColumn(String virtualColumn, String sourceColumn, CyTable sourceTable, String targetJoinKey, boolean isImmutable)
virtualColumn
- The name of the new virtual column, if this name already exists,
new column names with -1, -2 and so appended to this name on will
be tried until a non-existing name will be found.sourceColumn
- The name of the column in "sourceTable" that will be mapped to "virtualColumn".sourceTable
- The table that really contains the column that we're adding (all
updates and lookups of this new column will be redirected to here).
The table will be joined on the primary key column of this table.targetJoinKey
- The column in current table that will be used for the join. This
column will be joined with the primary key column of the source
table. These columns must be of the same type!isImmutable
- If true, this column cannot be deleted.void addVirtualColumns(CyTable sourceTable, String targetJoinKey, boolean isImmutable)
sourceTable
- The table that really contains the column that we're adding (all
updates and lookups of this new column will be redirected to here).
The table will be joined on the primary key column of this table.
None of the column names in "sourceTable" must exist in the current table!targetJoinKey
- The column in current table that will be used for the join. This
column will be joined with the primary key column of the source
table. These columns must be of the same type!isImmutable
- If true, these columns cannot be deleted.SavePolicy getSavePolicy()
void setSavePolicy(SavePolicy policy)
policy
- the policy to follow during the life-cycle of the CyTable.void swap(CyTable otherTable)
otherTable
- the table that we're being swapped with.
Note: the one "property" that is not being swapped is the SUID. Also, no events are being
fired to give any listeners a chance to react to the exchange!Copyright 2011-2015 Cytoscape Consortium. All rights reserved.