Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011-2015 Amazon Technologies, 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://aws.amazon.com/apache2.0
   *
  * 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;
 
Options for filtering results from a scan operation. For example, callers can specify filter conditions so that only objects whose attributes match different conditions are returned (see com.amazonaws.services.dynamodbv2.model.ComparisonOperator for more information on the available comparison types).

 
 public class DynamoDBScanExpression {

    
Optional filter to limit the results of the scan.
 
     private Map<StringConditionscanFilter;

    
The exclusive start key for this scan.
 
     private Map<StringAttributeValueexclusiveStartKey;

    
The limit of items to scan during this scan.
 
     private Integer limit;

    
The total number of segments into which the scan will be divided. Only required for parallel scan operation.
 
     private Integer totalSegments;

    
The ID (zero-based) of the segment to be scanned. Only required for parallel scan operation.
 
     private Integer segment;

    
The logical operator on the filter conditions of this scan.
 
     private String conditionalOperator;

    
Evaluates the scan results and returns only the desired values.

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

 
     private String filterExpression;

    
One or more substitution variables for simplifying complex expressions. The following are some use cases for an ExpressionAttributeName:
  • Shorten an attribute name that is very long or unwieldy in an expression.

  • Create a placeholder for repeating occurrences of an attribute name in an expression.

  • Prevent special characters in an attribute name from being misinterpreted in an expression.

Use the # character in an expression to dereference an attribute name. For example, consider the following expression:

  • order.customerInfo.LastName = "Smith" OR order.customerInfo.LastName = "Jones"

Now suppose that you specified the following for ExpressionAttributeNames:

  • {"n":"order.customerInfo.LastName"}

The expression can now be simplified as follows:

  • #n = "Smith" OR #n = "Jones"

 
     private java.util.Map<String,StringexpressionAttributeNames;

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

Use the : character in an expression to dereference an attribute value. For example, consider the following expression:

  • ProductStatus IN ("Available","Backordered","Discontinued")

Now suppose that you specified the following for ExpressionAttributeValues:

  • { "a":{"S":"Available"}, "b":{"S":"Backordered"}, "d":{"S":"Discontinued"} }

The expression can now be simplified as follows:

  • ProductStatus IN (:a,:b,:c)

Optional index name that can be specified for the scan operation.
    private String indexName;

    
Returns the name of the index to be used by this scan; or null if there is none.
    public String getIndexName() {
        return ;
    }

    
Sets the name of the index to be used by this scan.
    public void setIndexName(String indexName) {
        this. = indexName;
    }

    
Sets the name of the index to be used by this scan.

Returns a pointer to this object for method-chaining.

    public DynamoDBScanExpression withIndexName(String indexName) {
        setIndexName(indexName);
        return this;
    }

    
Returns the scan filter as a map of attribute names to conditions.

Returns:
The scan filter as a map of attribute names to conditions.
    public Map<StringConditiongetScanFilter() {
        return ;
    }

    
Sets the scan filter to the map of attribute names to conditions given.

Parameters:
scanFilter The map of attribute names to conditions to use when filtering scan results.
    public void setScanFilter(Map<StringConditionscanFilter) {
        this. = scanFilter;
    }

    
Sets the scan filter to the map of attribute names to conditions given and returns a pointer to this object for method-chaining.

Parameters:
scanFilter The map of attribute names to conditions to use when filtering scan results.
    public DynamoDBScanExpression withScanFilter(Map<StringConditionscanFilter) {
        setScanFilter(scanFilter);
        return this;
    }

    
Adds a new filter condition to the current scan filter.

Parameters:
attributeName The name of the attribute on which the specified condition operates.
condition The condition which describes how the specified attribute is compared and if a row of data is included in the results returned by the scan operation.
    public void addFilterCondition(String attributeNameCondition condition) {
        if (  == null )
             = new HashMap<StringCondition>();
        .put(attributeNamecondition);
    }

    
Adds a new filter condition to the current scan filter and returns a pointer to this object for method-chaining.

Parameters:
attributeName The name of the attribute on which the specified condition operates.
condition The condition which describes how the specified attribute is compared and if a row of data is included in the results returned by the scan operation.
    public DynamoDBScanExpression withFilterConditionEntry(String attributeNameCondition condition) {
        if (  == null )
             = new HashMap<StringCondition>();
        .put(attributeNamecondition);
        return this;
    }


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

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

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

    
Returns the limit of items to scan during this scan.

Use with caution. Please note that this is not the same as the number of items to return from the scan operation -- the operation will cease and return as soon as this many items are scanned, even if no matching results are found. Furthermore, PaginatedScanList will execute as many scan operations as necessary until it either reaches the end of the result set as indicated by DynamoDB or enough elements are available to fulfill the list operation (e.g. iteration). Therefore, except when scanning without a scan filter, it's usually bad practice to set a low limit, since doing so will often generate the same amount of traffic to DynamoDB but with a greater number of round trips and therefore more overall latency.

    public Integer getLimit() {
        return ;
    }

    
Sets the limit of items to scan during this scan. Please note that this is not the same as the number of items to return from the scan operation -- the operation will cease and return as soon as this many items are scanned, even if no matching results are found.

See also:
getLimit()
    public void setLimit(Integer limit) {
        this. = limit;
    }

    
Sets the limit of items to scan and returns a pointer to this object for method-chaining. Please note that this is not the same as the number of items to return from the scan operation -- the operation will cease and return as soon as this many items are scanned, even if no matching results are found.

See also:
getLimit()
    public DynamoDBScanExpression withLimit(Integer limit) {
        this. = limit;
        return this;
    }

    
Returns the total number of segments into which the scan will be divided.
    public Integer getTotalSegments() {
        return ;
    }

    
Sets the total number of segments into which the scan will be divided.
    public void setTotalSegments(Integer totalSegments) {
        this. = totalSegments;
    }

    
Sets the total number of segments into which the scan will be divided and returns a pointer to this object for method-chaining.
    public DynamoDBScanExpression withTotalSegments(Integer totalSegments) {
        setTotalSegments(totalSegments);
        return this;
    }

    
Returns the ID of the segment to be scanned.
    public Integer getSegment() {
        return ;
    }

    
Sets the ID of the segment to be scanned.
    public void setSegment(Integer segment) {
        this. = segment;
    }

    
Sets the ID of the segment to be scanned and returns a pointer to this object for method-chaining.
    public DynamoDBScanExpression withSegment(Integer segment) {
        setSegment(segment);
        return this;
    }

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

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

    
Sets the logical operator on the filter conditions of this scan and returns a pointer to this object for method-chaining.
    public DynamoDBScanExpression withConditionalOperator(String conditionalOperator) {
        setConditionalOperator(conditionalOperator);
        return this;
    }

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

    
Sets the logical operator on the filter conditions of this scan and returns a pointer to this object for method-chaining.
        return withConditionalOperator(conditionalOperator.toString());
    }

    
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.ScanRequest.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.ScanRequest.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.ScanRequest.withFilterExpression(java.lang.String)
    public DynamoDBScanExpression withFilterExpression(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:
scanRequest#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.ScanRequest.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.ScanRequest.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.ScanRequest.addExpressionAttributeNamesEntry(java.lang.String,java.lang.String)
            String 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.ScanRequest.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.ScanRequest.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.ScanRequest.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.ScanRequest.addExpressionAttributeValuesEntry(java.lang.String,com.amazonaws.services.dynamodbv2.model.AttributeValue)
            AttributeValue 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