com.datastax.driver.core
Class ColumnDefinitions

java.lang.Object
  extended by com.datastax.driver.core.ColumnDefinitions
All Implemented Interfaces:
Iterable<ColumnDefinitions.Definition>

public class ColumnDefinitions
extends Object
implements Iterable<ColumnDefinitions.Definition>

Metadata describing the columns returned in a ResultSet or a PreparedStatement.

A columnDefinitions} instance is mainly a list of ColumnsDefinitions.Definition. The definitions or metadata for a column can be accessed either by:

When accessed by name, column selection is case insensitive. In case multiple columns only differ by the case of their name, then the column returned with be the first column that has been defined in CQL without forcing case sensitivity (that is, it has either been defined without quotes or is fully lowercase). If none of the columns have been defined in this manner, the first column matching (with case insensitivity) is returned. You can force the case of a selection by double quoting the name.

For example:

Note that the preceding rules mean that if a ColumnDefinitions object contains multiple occurrences of the exact same name (be it the same column multiple times or columns from different tables with the same name), you will have to use selection by index to disambiguate.


Nested Class Summary
static class ColumnDefinitions.Definition
          A column definition.
 
Method Summary
 List<ColumnDefinitions.Definition> asList()
          Returns a list containing all the definitions of this metadata in order.
 boolean contains(String name)
          Returns whether this metadata contains a given name.
 int getIndexOf(String name)
          The first index in this metadata of the povided name, if present.
 String getKeyspace(int i)
          Returns the keyspace of the ith column in this metadata.
 String getKeyspace(String name)
          Returns the keyspace of the first occurence of name in this metadata.
 String getName(int i)
          Returns the name of the ith column in this metadata.
 String getTable(int i)
          Returns the table of the ith column in this metadata.
 String getTable(String name)
          Returns the table of first occurence of name in this metadata.
 DataType getType(int i)
          Returns the type of the ith column in this metadata.
 DataType getType(String name)
          Returns the type of the first occurence of name in this metadata.
 Iterator<ColumnDefinitions.Definition> iterator()
          Returns an iterator over the ColumnDefinitions.Definition contained in this metadata.
 int size()
          Returns the number of columns described by this Columns instance.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

size

public int size()
Returns the number of columns described by this Columns instance.

Returns:
the number of columns described by this metadata.

contains

public boolean contains(String name)
Returns whether this metadata contains a given name.

Parameters:
name - the name to check.
Returns:
true if this metadata contains the column named name, false otherwise.

getIndexOf

public int getIndexOf(String name)
The first index in this metadata of the povided name, if present.

Parameters:
name - the name of the column.
Returns:
the index of the first occurrence of name in this metadata if contains(name), -1 otherwise.

iterator

public Iterator<ColumnDefinitions.Definition> iterator()
Returns an iterator over the ColumnDefinitions.Definition contained in this metadata. The order of the iterator will be the one of this metadata.

Specified by:
iterator in interface Iterable<ColumnDefinitions.Definition>
Returns:
an iterator over the ColumnDefinitions.Definition contained in this metadata.

asList

public List<ColumnDefinitions.Definition> asList()
Returns a list containing all the definitions of this metadata in order.

Returns:
a list of the ColumnDefinitions.Definition contained in this metadata.

getName

public String getName(int i)
Returns the name of the ith column in this metadata.

Parameters:
i - the index in this metadata.
Returns:
the name of the ith column in this metadata.
Throws:
IndexOutOfBoundsException - if i < 0 or i >= size()

getType

public DataType getType(int i)
Returns the type of the ith column in this metadata.

Parameters:
i - the index in this metadata.
Returns:
the type of the ith column in this metadata.
Throws:
IndexOutOfBoundsException - if i < 0 or i >= size()

getType

public DataType getType(String name)
Returns the type of the first occurence of name in this metadata.

Parameters:
name - the name of the column.
Returns:
the type of (the first occurence of) name in this metadata.
Throws:
IllegalArgumentException - if name is not in this metadata.

getKeyspace

public String getKeyspace(int i)
Returns the keyspace of the ith column in this metadata.

Parameters:
i - the index in this metadata.
Returns:
the keyspace of the ith column in this metadata.
Throws:
IndexOutOfBoundsException - if i < 0 or i >= size()

getKeyspace

public String getKeyspace(String name)
Returns the keyspace of the first occurence of name in this metadata.

Parameters:
name - the name of the column.
Returns:
the keyspace of (the first occurrence of) column name in this metadata.
Throws:
IllegalArgumentException - if name is not in this metadata.

getTable

public String getTable(int i)
Returns the table of the ith column in this metadata.

Parameters:
i - the index in this metadata.
Returns:
the table of the ith column in this metadata.
Throws:
IndexOutOfBoundsException - if i < 0 or i >= size()

getTable

public String getTable(String name)
Returns the table of first occurence of name in this metadata.

Parameters:
name - the name of the column.
Returns:
the table of (the first occurence of) column name in this metadata.
Throws:
IllegalArgumentException - if name is not in this metadata.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All rights reserved.