Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011-2014 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.mobileconnectors.dynamodbv2.dynamodbmapper;
 
 import java.util.Map;
 
 import  com.amazonaws.services.dynamodbv2.model.AttributeValue;
 import  com.amazonaws.services.dynamodbv2.model.Condition;
 import  com.amazonaws.services.dynamodbv2.model.ConditionalOperator;

A query expression
 
 public class DynamoDBQueryExpression <T> {
 
     private boolean consistentRead = true;
     private boolean scanIndexForward = true;
     private T hashKeyValues;
     private Map<String, Condition> rangeKeyConditions;
     private Map<String, AttributeValue> exclusiveStartKey;
     private Integer limit;
     private String indexName;
     private Map<String, Condition> queryFilter;
     private String conditionalOperator;

    
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.
 
     public Map<String, AttributeValue> getExclusiveStartKey() {
         return ;
     }

    
Sets the exclusive start key for this query.
 
     public void setExclusiveStartKey(Map<String, AttributeValue> exclusiveStartKey) {
         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<String, AttributeValue> exclusiveStartKey) {
        this. = exclusiveStartKey;
        return this;
    }

    
Returns the limit of items to return from this query.
    public Integer getLimit() {
        return ;
    }

    
Sets the limit of items to return from this query.
    public void setLimit(Integer limit) {
        this. = limit;
    }

    
Sets the limit of items to return from this query and returns a pointer to this object for method-chaining.
    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.
    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<String, Condition> getRangeKeyConditions() {
        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 NOTE: The current DynamoDB service only allows up to one range key condition per query. Providing more than one range key conditions will result in an AmazonClientException
    public void setRangeKeyConditions(Map<String, Condition> rangeKeyConditions) {
        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 NOTE: The current DynamoDB service only allows up to one range key condition per query. Providing more than one range key conditions will result in an AmazonClientException
    public DynamoDBQueryExpression<T> withRangeKeyConditions(Map<String, Condition> rangeKeyConditions) {
        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 DynamoDBQueryExpression.setIndexName(String) or DynamoDBQueryExpression.withIndexName(String).

Parameters:
rangeKeyAttributeName This could 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 rangeKeyAttributeName, Condition rangeKeyCondition) {
        if (  == null )
             = new HashMap<String, Condition>();
        .put(rangeKeyAttributeNamerangeKeyCondition);
        return this;
    }
    
    
Returns the name of the index used by this query.
    public String getIndexName() {
        return ;
    }

    
Sets the name of the index to be used by this query. All index names must be specified by using DynamoDBIndexRangeKey annotation on the getter method of the corresponding index range key before executing the query.
    public void setIndexName(String indexName) {
        this. = indexName;
    }

    
Sets the name of the index to be used by this query. All index names must be specified by using DynamoDBIndexRangeKey annotation on the getter method of the corresponding index range key before executing the query.

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<String, Condition> getQueryFilter() {
        return ;
    }

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

    
Sets the query filter applied on this query.

Returns a pointer to this object for method-chaining.

    public DynamoDBQueryExpression<T> withQueryFilter(Map<String, Condition> queryFilter) {
        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 attributeName, Condition 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;
    }
New to GrepCode? Check out our FAQ X