com.datastax.driver.core
Class TableMetadata

java.lang.Object
  extended by com.datastax.driver.core.TableMetadata

public class TableMetadata
extends Object

Describes a Table.


Nested Class Summary
static class TableMetadata.Options
           
 
Method Summary
 String asCQLQuery()
          Returns a CQL query representing this table.
 String exportAsString()
          Return a String containing CQL queries representing this table and the index on it.
 List<ColumnMetadata> getClusteringKey()
          Return the list of columns composing the clustering key for this table.
 ColumnMetadata getColumn(String name)
          Returns metadata on a column of this table.
 List<ColumnMetadata> getColumns()
          Returns a list containing all the columns of this table.
 KeyspaceMetadata getKeyspace()
          Returns the keyspace this table belong to.
 String getName()
          Returns the name of this table.
 TableMetadata.Options getOptions()
          The options of this table.
 List<ColumnMetadata> getPartitionKey()
          Return the list of columns composing the partition key for this table.
 List<ColumnMetadata> getPrimaryKey()
          Return the list of columns composing the primary key for this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public String getName()
Returns the name of this table.

Returns:
the name of this CQL table.

getKeyspace

public KeyspaceMetadata getKeyspace()
Returns the keyspace this table belong to.

Returns:
the keyspace metadata of the keyspace this table belong to.

getColumn

public ColumnMetadata getColumn(String name)
Returns metadata on a column of this table.

Parameters:
name - the name of the column to retrieve.
Returns:
the metadata for the name column if it exists, or null otherwise.

getColumns

public List<ColumnMetadata> getColumns()
Returns a list containing all the columns of this table. The order of the columns in the returned list will be consistent with the order of the columns returned by a SELECT * FROM thisTable: the first column will be the partition key, next will be the clustering keys in there defined order, and then will follow the rest of the columns in alphabetic order.

Returns:
a list containing the metadata for the columns of this table.

getPrimaryKey

public List<ColumnMetadata> getPrimaryKey()
Return the list of columns composing the primary key for this table. Note that a table will always have at least have a partition key (that may itself be one or more columns), so the returned list will at least have one element.

Returns:
the list of columns composing the primary key for this table.

getPartitionKey

public List<ColumnMetadata> getPartitionKey()
Return the list of columns composing the partition key for this table. Note that a table will always have a partition key so the returned list will at least have one element.

Returns:
the list of columns composing the partition key for this table.

getClusteringKey

public List<ColumnMetadata> getClusteringKey()
Return the list of columns composing the clustering key for this table.

Returns:
the list of columns composing the clustering key for this table. If the clustering key is empty, an empty list is returned.

getOptions

public TableMetadata.Options getOptions()
The options of this table.

Returns:
the options of this table.

exportAsString

public String exportAsString()
Return a String containing CQL queries representing this table and the index on it. In other words, this method returns the queries that would allow to recreate the schema of this table, along with the index defined on columns of this table. Note that the returned String is formatted to be human readable (for some defintion of human readable at least).

Returns:
the CQL queries representing this table schema as a {code String}.

asCQLQuery

public String asCQLQuery()
Returns a CQL query representing this table. This method returns a single 'CREATE TABLE' query with the options corresponding to this table definition. Note that the returned string will be a single line; the returned query is not formatted in any way.

Returns:
the 'CREATE TABLE' query corresponding to this table.
See Also:
exportAsString()


Copyright © 2013. All Rights Reserved.