Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2012-2015 DataStax Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.datastax.driver.core.querybuilder;
import com.datastax.driver.core.*;
import com.datastax.driver.core.exceptions.CodecNotFoundException;
import com.datastax.driver.core.policies.RetryPolicy;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
* Common ancestor to statements generated with the {@link QueryBuilder}.
*
* The actual query string will be generated and cached the first time it is requested,
* which is either when the driver tries to execute the query, or when you call certain
* public methods (for example {@link RegularStatement#getQueryString(CodecRegistry)},
* {@link #getObject(int, CodecRegistry)}).
*
* Whenever possible (and unless you call {@link #setForceNoValues(boolean)}, the builder
* will try to handle values passed to its methods as standalone values bound to the query
* string with placeholders. For instance:
*
* select().all().from("foo").where(eq("k", "the key"));
* // Is equivalent to:
* new SimpleStatement("SELECT * FROM foo WHERE k=?", "the key");
*
* There are a few exceptions to this rule:
*
*
for fixed-size number types, the builder can't guess what the actual CQL type
* is. Standalone values are sent to Cassandra in their serialized form, and number
* types aren't all serialized in the same way, so picking the wrong type could
* lead to a query error;
*
if the value is a "special" element like a function call, it can't be serialized.
* This also applies to collections mixing special elements and regular objects.
*
* In these cases, the builder will inline the value in the query string:
*
* select().all().from("foo").where(eq("k", 1));
* // Is equivalent to:
* new SimpleStatement("SELECT * FROM foo WHERE k=1");
*
* One final thing to consider is {@link CodecRegistry custom codecs}. If you've registered
* codecs to handle your own Java types against the cluster, then you can pass instances of
* those types to query builder methods. But should the builder have to inline those values,
* it needs your codecs to {@link TypeCodec#format(Object) convert them to string form}.
* That is why some of the public methods of this class take a {@code CodecRegistry} as a
* parameter:
*
* BuiltStatement s = select().all().from("foo").where(eq("k", myCustomObject));
* // if we do this codecs will definitely be needed:
* s.forceNoValues(true);
* s.getQueryString(myCodecRegistry);
*
* For convenience, there are no-arg versions of those methods that use
* {@link CodecRegistry#DEFAULT_INSTANCE}. But you should only use them if you are sure that
* no custom values will need to be inlined while building the statement, or if you have
* registered your custom codecs with the default registry instance. Otherwise, you will get
* a {@link CodecNotFoundException}.
*/
public abstract class BuiltStatement extends RegularStatement {
private static final Pattern lowercaseAlphanumeric = Pattern.compile("[a-z][a-z0-9_]*");
private final List partitionKey;
private final List