Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file 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.amazonaws.services.dynamodbv2.datamodeling;
 
 import java.util.Map;
 
A query expression.
 
 public class DynamoDBQueryExpression <T> {
 
     private boolean consistentRead = true;
     private boolean scanIndexForward = true;
     private T hashKeyValues;
     private Map<StringConditionrangeKeyConditions;
     private Integer limit;
     private String indexName;
     private Map<StringConditionqueryFilter;
     private String conditionalOperator;
    
Evaluates the query results and returns only the desired values.

The condition you specify is applied to the items queried; any items that do not match the expression are not returned.

 
     private String filterExpression;
    
One or more substitution variables for simplifying complex expressions.
 
     private java.util.Map<StringStringexpressionAttributeNames;

    
One or more values that can be substituted in an expression.
 
Returns whether this query uses consistent reads.
 
     public boolean isConsistentRead() {
         return ;
     }

    
Sets whether this query uses consistent reads.
 
     public void setConsistentRead(boolean consistentRead) {
         this. = consistentRead;
     }

    
Sets whether this query uses consistent reads and returns a pointer to this object for method-chaining.
 
     public DynamoDBQueryExpression<T> withConsistentRead(boolean consistentRead) {
         this. = consistentRead;
         return this;
     }

    
Returns whether this query scans forward.
 
     public boolean isScanIndexForward() {
         return ;
     }

    
Sets whether this query scans forward.
 
     public void setScanIndexForward(boolean scanIndexForward) {
         this. = scanIndexForward;
     }

    
Sets whether this query scans forward and returns a pointer to this object for method-chaining.
 
     public DynamoDBQueryExpression<T> withScanIndexForward(boolean scanIndexForward) {
         this. = scanIndexForward;
         return this;
    }

    
Returns the exclusive start key for this query.
        return ;
    }

    
Sets the exclusive start key for this query.
    public void setExclusiveStartKey(Map<StringAttributeValueexclusiveStartKey) {
        this. = exclusiveStartKey;
    }

    
Sets the exclusive start key for this query and returns a pointer to this object for method-chaining.
    public DynamoDBQueryExpression<T> withExclusiveStartKey(Map<StringAttributeValueexclusiveStartKey) {
        this. = exclusiveStartKey;
        return this;
    }

    
Returns the maximum number of items to retrieve in each service request to DynamoDB.

Note that when calling DynamoDBMapper.query, multiple requests are made to DynamoDB if needed to retrieve the entire result set. Setting this will limit the number of items retrieved by each request, NOT the total number of results that will be retrieved. Use DynamoDBMapper.queryPage to retrieve a single page of items from DynamoDB.

    public Integer getLimit() {
        return ;
    }

    
Sets the maximum number of items to retrieve in each service request to DynamoDB.

Note that when calling DynamoDBMapper.query, multiple requests are made to DynamoDB if needed to retrieve the entire result set. Setting this will limit the number of items retrieved by each request, NOT the total number of results that will be retrieved. Use DynamoDBMapper.queryPage to retrieve a single page of items from DynamoDB.

    public void setLimit(Integer limit) {
        this. = limit;
    }

    
Sets the maximum number of items to retrieve in each service request to DynamoDB and returns a pointer to this object for method-chaining.

Note that when calling DynamoDBMapper.query, multiple requests are made to DynamoDB if needed to retrieve the entire result set. Setting this will limit the number of items retrieved by each request, NOT the total number of results that will be retrieved. Use DynamoDBMapper.queryPage to retrieve a single page of items from DynamoDB.

    public DynamoDBQueryExpression<T> withLimit(Integer limit) {
        this. = limit;
        return this;
    }

    
Gets the hash key value(s) for this query. All hash key attributes for the table must be specified with this key object.
    public T getHashKeyValues() {
        return ;
    }


    
Sets the hash key value(s) for this query. All hash key attributes for the table must be specified with this key object. Note 1: Currently the DynamoDBMapper supports only one value per hash key. Note 2: Currently the Amazon DynamoDB supports only one hash key per table/index.
    public void setHashKeyValues(T hashKeyValues) {
        this. = hashKeyValues;
    }

    
Sets the hash key value(s) for this query. All hash key attributes for the table must be specified with this key object.
    public DynamoDBQueryExpression<T> withHashKeyValues(T hashKObject) {
        setHashKeyValues(hashKObject);
        return this;
    }

    
Gets the range key condition for this query. All range key attributes for the table must be specified by attribute name in the map.
    public Map<StringConditiongetRangeKeyConditions() {
        return ;
    }

    
Sets the range key condition for this query. All range key attributes for the table must be specified by attribute name in the map.

Parameters:
rangeKeyConditions a map from key name to condition NOTE: The current DynamoDB service only allows up to one range key condition per query. Providing more than one range key condition will result in an AmazonClientException.
    public void setRangeKeyConditions(Map<StringConditionrangeKeyConditions) {
        this. = rangeKeyConditions;
    }

    
Sets the range key condition for this query. All range key attributes for the table must be specified by attribute name in the map.

Parameters:
rangeKeyConditions a map from key name to condition NOTE: The current DynamoDB service only allows up to one range key condition per query. Providing more than one range key condition will result in an AmazonClientException.
    public DynamoDBQueryExpression<T> withRangeKeyConditions(Map<StringConditionrangeKeyConditions) {
        setRangeKeyConditions(rangeKeyConditions);
        return this;
    }

    
Sets one range key condition for this query, using the attribute name of the range key. All range key attributes for the table must be specified by using DynamoDBRangeKey or DynamoDBIndexRangeKey annotations before executing the query.
If the attribute is the primary range key
users should NOT set any index name for this query.
If the attribute is an index range key
DynamoDBMapper will automatically set the index name if the range key is annotated as only used by one local secondary index, otherwise users must set the index name manually by either setIndexName(java.lang.String) or withIndexName(java.lang.String).

Parameters:
rangeKeyAttributeName This can be either the primary range key of the table or an index range key.
rangeKeyCondition Condition specified on the given range key for this query.
    public DynamoDBQueryExpression<T> withRangeKeyCondition(String rangeKeyAttributeNameCondition rangeKeyCondition) {
        if (  == null )
             = new HashMap<StringCondition>();
        .put(rangeKeyAttributeNamerangeKeyCondition);
        return this;
    }

    
Returns the name of the index to be used by this query.
    public String getIndexName() {
        return ;
    }

    
Sets the name of the index to be used by this query. The hash key and/or range key of the index must be specified by adding DynamoDBIndexHashKey or DynamoDBIndexRangeKey annotations to the appropriate getter methods of the mapped object.
    public void setIndexName(String indexName) {
        this. = indexName;
    }

    
Sets the name of the index to be used by this query. The hash key and/or range key of the index must be specified by adding DynamoDBIndexHashKey or DynamoDBIndexRangeKey annotations to the appropriate getter methods of the mapped object.

Returns a pointer to this object for method-chaining.

    public DynamoDBQueryExpression<T> withIndexName(String indexName) {
        setIndexName(indexName);
        return this;
    }

    
Returns the query filter applied on this query.
    public Map<StringConditiongetQueryFilter() {
        return ;
    }

    
Sets the query filter applied on this query.
    public void setQueryFilter(Map<StringConditionqueryFilter) {
        this. = queryFilter;
    }

    
Sets the query filter applied on this query.

Returns a pointer to this object for method-chaining.

    public DynamoDBQueryExpression<T> withQueryFilter(Map<StringConditionqueryFilter) {
        setQueryFilter(queryFilter);
        return this;
    }

    
Adds a new condition to the the query filter.

Returns a pointer to this object for method-chaining.

Parameters:
attributeName The name of the attribute on which the specified condition operates.
condition The filter condition applied on the attribute.
    public DynamoDBQueryExpression<T> withQueryFilterEntry(String attributeNameCondition condition) {
        if ( == null) {
             = new HashMap<String,Condition>();
        }
        .put(attributeNamecondition);
        return this;
    }

    
Returns the logical operator on the query filter conditions.
    public String getConditionalOperator() {
        return ;
    }

    
Sets the logical operator on the query filter conditions.
    public void setConditionalOperator(String conditionalOperator) {
        this. = conditionalOperator;
    }

    
Sets the logical operator on the query filter conditions.

Returns a pointer to this object for method-chaining.

    public DynamoDBQueryExpression<T> withConditionalOperator(String conditionalOperator) {
        setConditionalOperator(conditionalOperator);
        return this;
    }

    
Sets the logical operator on the query filter conditions.
    public void setConditionalOperator(ConditionalOperator conditionalOperator) {
        this. = conditionalOperator.toString();
    }

    
Sets the logical operator on the query filter conditions.

Returns a pointer to this object for method-chaining.

    public DynamoDBQueryExpression<T> withConditionalOperator(ConditionalOperator conditionalOperator) {
        setConditionalOperator(conditionalOperator);
        return this;
    }

    
Evaluates the query results and returns only the desired values.

The condition you specify is applied to the items queried; any items that do not match the expression are not returned.

Returns:
Evaluates the query results and returns only the desired values.

The condition you specify is applied to the items queried; any items that do not match the expression are not returned.

See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.getFilterExpression()
    public String getFilterExpression() {
        return ;
    }

    
Evaluates the query results and returns only the desired values.

The condition you specify is applied to the items queried; any items that do not match the expression are not returned.

Parameters:
filterExpression Evaluates the query results and returns only the desired values.

The condition you specify is applied to the items queried; any items that do not match the expression are not returned.

See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.setFilterExpression(java.lang.String)
    public void setFilterExpression(String filterExpression) {
        this. = filterExpression;
    }

    
Evaluates the query results and returns only the desired values.

The condition you specify is applied to the items queried; any items that do not match the expression are not returned.

Returns a reference to this object so that method calls can be chained together.

Parameters:
filterExpression Evaluates the query results and returns only the desired values.

The condition you specify is applied to the items queried; any items that do not match the expression are not returned.

Returns:
A reference to this updated object so that method calls can be chained together.
See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.withFilterExpression(java.lang.String)
            String filterExpression) {
        this. = filterExpression;
        return this;
    }

    
One or more substitution variables for simplifying complex expressions.

Returns:
One or more substitution variables for simplifying complex expressions.
See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.getExpressionAttributeNames()
        return ;
    }

    
One or more substitution variables for simplifying complex expressions.

Parameters:
expressionAttributeNames One or more substitution variables for simplifying complex expressions.
See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.setExpressionAttributeNames(java.util.Map)
    public void setExpressionAttributeNames(
            java.util.Map<StringStringexpressionAttributeNames) {
        this. = expressionAttributeNames;
    }

    
One or more substitution variables for simplifying complex expressions.

Parameters:
expressionAttributeNames One or more substitution variables for simplifying complex expressions.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.withExpressionAttributeNames(java.util.Map)
            java.util.Map<StringStringexpressionAttributeNames) {
        setExpressionAttributeNames(expressionAttributeNames);
        return this;
    }

    
One or more substitution variables for simplifying complex expressions. The method adds a new key-value pair into ExpressionAttributeNames parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into ExpressionAttributeNames.
value The corresponding value of the entry to be added into ExpressionAttributeNames.
See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.addExpressionAttributeNamesEntry(java.lang.String,java.lang.String)
            String keyString value) {
        if (null == this.) {
            this. = new java.util.HashMap<StringString>();
        }
        if (this..containsKey(key))
            throw new IllegalArgumentException("Duplicated keys ("
                    + key.toString() + ") are provided.");
        this..put(keyvalue);
        return this;
    }

    
Removes all the entries added into ExpressionAttributeNames.

Returns a reference to this object so that method calls can be chained together.

        this. = null;
        return this;
    }

    
One or more values that can be substituted in an expression.

Returns:
One or more values that can be substituted in an expression.
See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.getExpressionAttributeValues()
        return ;
    }

    
One or more values that can be substituted in an expression.

Parameters:
expressionAttributeValues One or more values that can be substituted in an expression.
See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.setExpressionAttributeValues(java.util.Map)
    public void setExpressionAttributeValues(
            java.util.Map<StringAttributeValueexpressionAttributeValues) {
        this. = expressionAttributeValues;
    }

    
One or more values that can be substituted in an expression.

Parameters:
expressionAttributeValues One or more values that can be substituted in an expression.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.withExpressionAttributeValues(java.util.Map)
            java.util.Map<StringAttributeValueexpressionAttributeValues) {
        setExpressionAttributeValues(expressionAttributeValues);
        return this;
    }

    
One or more values that can be substituted in an expression. The method adds a new key-value pair into ExpressionAttributeValues parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into ExpressionAttributeValues.
value The corresponding value of the entry to be added into ExpressionAttributeValues.
See also:
com.amazonaws.services.dynamodbv2.model.QueryRequest.addExpressionAttributeValuesEntry(java.lang.String,com.amazonaws.services.dynamodbv2.model.AttributeValue)
            String keyAttributeValue value) {
        if (null == this.) {
            this. = new java.util.HashMap<StringAttributeValue>();
        }
        if (this..containsKey(key))
            throw new IllegalArgumentException("Duplicated keys ("
                    + key.toString() + ") are provided.");
        this..put(keyvalue);
        return this;
    }

    
Removes all the entries added into ExpressionAttributeValues.

Returns a reference to this object so that method calls can be chained together.

        this. = null;
        return this;
    }
New to GrepCode? Check out our FAQ X