com.datastax.driver.core
Class SimpleStatement

java.lang.Object
  extended by com.datastax.driver.core.Query
      extended by com.datastax.driver.core.Statement
          extended by com.datastax.driver.core.SimpleStatement

public class SimpleStatement
extends Statement

A simple Statement implementation built directly from a query string.


Constructor Summary
SimpleStatement(String query)
          Creates a new SimpleStatement with the provided query string.
 
Method Summary
 String getQueryString()
          The query string.
 ByteBuffer getRoutingKey()
          The routing key for the query.
 SimpleStatement setRoutingKey(ByteBuffer... routingKeyComponents)
          Set the routing key for this query.
 SimpleStatement setRoutingKey(ByteBuffer routingKey)
          Set the routing key for this query.
 
Methods inherited from class com.datastax.driver.core.Statement
toString
 
Methods inherited from class com.datastax.driver.core.Query
disableTracing, enableTracing, getConsistencyLevel, getRetryPolicy, isTracing, setConsistencyLevel, setRetryPolicy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleStatement

public SimpleStatement(String query)
Creates a new SimpleStatement with the provided query string.

Parameters:
query - the query string.
Method Detail

getQueryString

public String getQueryString()
The query string.

Specified by:
getQueryString in class Statement
Returns:
the query string;

getRoutingKey

public ByteBuffer getRoutingKey()
The routing key for the query.

Note that unless the routing key has been explicitly set through setRoutingKey(java.nio.ByteBuffer), this will method will return null (to avoid having to parse the query string to retrieve the partition key).

Specified by:
getRoutingKey in class Query
Returns:
the routing key set through setRoutingKey(java.nio.ByteBuffer) is such a key was set, null otherwise.
See Also:
Query.getRoutingKey()

setRoutingKey

public SimpleStatement setRoutingKey(ByteBuffer routingKey)
Set the routing key for this query.

This method allows to manually provide a routing key for this query. It is thus optional since the routing key is only an hint for token aware load balancing policy but is never mandatory.

If the partition key for the query is composite, use the setRoutingKey(ByteBuffer...) method instead to build the routing key.

Parameters:
routingKey - the raw (binary) value to use as routing key.
Returns:
this SimpleStatement object.
See Also:
Query.getRoutingKey()

setRoutingKey

public SimpleStatement setRoutingKey(ByteBuffer... routingKeyComponents)
Set the routing key for this query.

See setRoutingKey(ByteBuffer) for more information. This method is a variant for when the query partition key is composite and thus the routing key must be built from multiple values.

Parameters:
routingKeyComponents - the raw (binary) values to compose to obtain the routing key.
Returns:
this SimpleStatement object.
See Also:
Query.getRoutingKey()


Copyright © 2013. All Rights Reserved.