Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 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.s3.model;
 

Contains options to return a list of summary information about the objects in the specified bucket. Depending on the request parameters, additional information is returned, such as common prefixes if a delimiter was specified. List results are always returned in lexicographic (alphabetical) order.

Buckets can contain a virtually unlimited number of keys, and the complete results of a list query can be extremely large. To manage large result sets, Amazon S3 uses pagination to split them into multiple responses. Always check the ObjectListing.isTruncated() method to see if the returned listing is complete, or if callers need to make additional calls to get more results. Alternatively, use the com.amazonaws.services.s3.AmazonS3Client.listNextBatchOfObjects(com.amazonaws.services.s3.model.ObjectListing) method as an easy way to get the next page of object listings.

Calling setDelimiter(java.lang.String) sets the delimiter, allowing groups of keys that share the delimiter-terminated prefix to be included in the returned listing. This allows applications to organize and browse their keys hierarchically, similar to how a file system organizes files into directories. These common prefixes can be retrieved through the ObjectListing.getCommonPrefixes() method.

For example, consider a bucket that contains the following keys:

  • "foo/bar/baz"
  • "foo/bar/bash"
  • "foo/bar/bang"
  • "foo/boo"
If calling listObjects with a prefix value of "foo/" and a delimiter value of "/" on this bucket, an ObjectListing is returned that contains one key ("foo/boo") and one entry in the common prefixes list ("foo/bar/"). To see deeper into the virtual hierarchy, make another call to listObjects setting the prefix parameter to any interesting common prefix to list the individual keys under that prefix.

The total number of keys in a bucket doesn't substantially affect list performance, nor does the presence or absence of additional request parameters.

 
 public class ListObjectsRequest extends AmazonWebServiceRequest {

    
The name of the Amazon S3 bucket to list.
 
     private String bucketName;

    
Optional parameter restricting the response to keys which begin with the specified prefix. You can use prefixes to separate a bucket into different sets of keys in a way similar to how a file system uses folders.
 
     private String prefix;

    
Optional parameter indicating where in the bucket to begin listing. The list will only include keys that occur lexicographically after the marker. This enables pagination; to get the next page of results use the current value from ObjectListing.getNextMarker() as the marker for the next request to list objects.
 
     private String marker;

    
Optional parameter that causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the ObjectListing.getCommonPrefixes() list. These rolled-up keys are not returned elsewhere in the response. The most commonly used delimiter is "/", which simulates a hierarchical organization similar to a file system directory structure.
 
     private String delimiter;

    
Optional parameter indicating the maximum number of keys to include in the response. Amazon S3 might return fewer than this, but will not return more. Even if maxKeys is not specified, Amazon S3 will limit the number of results in the response.
    private Integer maxKeys;


    
Constructs a new ListObjectsRequest object. The caller must populate the object fields before the request is ready to be executed.

    public ListObjectsRequest() {}

    
Constructs a new ListObjectsRequest object and initializes all required and optional object fields.

Parameters:
bucketName The name of the bucket whose objects are to be listed.
prefix The prefix restricting what keys will be listed.
marker The key marker indicating where listing results should begin.
delimiter The delimiter for condensing common prefixes in the returned listing results.
maxKeys The maximum number of results to return.
See also:
ListObjectsRequest.ListObjectsRequest()
    public ListObjectsRequest(String bucketNameString prefixString markerString delimiterInteger maxKeys) {
        setBucketName(bucketName);
        setPrefix(prefix);
        setMarker(marker);
        setDelimiter(delimiter);
        setMaxKeys(maxKeys);
    }


    
Gets the name of the Amazon S3 bucket whose objects are to be listed.

Returns:
The name of the Amazon S3 bucket whose objects are to be listed.
See also:
setBucketName(java.lang.String)
withBucketName(java.lang.String)
    public String getBucketName() {
        return ;
    }

    
Sets the name of the Amazon S3 bucket whose objects are to be listed.

Parameters:
bucketName The name of the Amazon S3 bucket whose objects are to be listed.
See also:
getBucketName()
withBucketName(java.lang.String)
    public void setBucketName(String bucketName) {
        this. = bucketName;
    }

    
Sets the name of the Amazon S3 bucket whose objects are to be listed. Returns this ListObjectsRequest, enabling additional method calls to be chained together.

Parameters:
bucketName The name of the Amazon S3 bucket whose objects are to be listed.
Returns:
This ListObjectsRequest, enabling additional method calls to be chained together.
See also:
getBucketName()
setBucketName(java.lang.String)
    public ListObjectsRequest withBucketName(String bucketName) {
        setBucketName(bucketName);
        return this;
    }

    
Gets the optional prefix parameter and restricts the response to keys that begin with the specified prefix. Use prefixes to separate a bucket into different sets of keys, similar to how a file system organizes files into directories.

Returns:
The optional prefix parameter restricting the response to keys that begin with the specified prefix.
See also:
setPrefix(java.lang.String)
    public String getPrefix() {
        return ;
    }

    
Sets the optional prefix parameter, restricting the response to keys that begin with the specified prefix.

Parameters:
prefix The optional prefix parameter, restricting the response to keys that begin with the specified prefix.
See also:
getPrefix()
    public void setPrefix(String prefix) {
        this. = prefix;
    }

    
Sets the optional prefix parameter restricting the response to keys that begin with the specified prefix. Returns this ListObjectsRequest, enabling additional method calls to be chained together.

Parameters:
prefix The optional prefix parameter restricting the response to keys that begin with the specified prefix.
Returns:
This ListObjectsRequest, enabling additional method calls to be chained together.
See also:
getPrefix()
setPrefix(java.lang.String)
    public ListObjectsRequest withPrefix(String prefix) {
        setPrefix(prefix);
        return this;
    }

    
Gets the optional marker parameter indicating where in the bucket to begin listing. The list will only include keys that occur lexicographically after the marker.

Returns:
The optional marker parameter indicating where in the bucket to begin listing. The list will only include keys that occur lexicographically after the marker.
See also:
setMarker(java.lang.String)
withMarker(java.lang.String)
    public String getMarker() {
        return ;
    }

    
Sets the optional marker parameter indicating where in the bucket to begin listing. The list will only include keys that occur lexicographically after the marker.

Parameters:
marker The optional marker parameter indicating where in the bucket to begin listing. The list will only include keys that occur lexicographically after the marker.
See also:
getMarker()
withMarker(java.lang.String)
    public void setMarker(String marker) {
        this. = marker;
    }

    
Sets the optional marker parameter indicating where in the bucket to begin listing. Returns this ListObjectsRequest, enabling additional method calls to be chained together. The list will only include keys that occur lexicographically after the marker.

Parameters:
marker The optional parameter indicating where in the bucket to begin listing. The list will only include keys that occur lexicographically after the marker.
Returns:
This ListObjectsRequest, enabling additional method calls to be chained together.
See also:
getMarker()
setMarker(java.lang.String)
    public ListObjectsRequest withMarker(String marker) {
        setMarker(marker);
        return this;
    }

    
Gets the optional delimiter parameter that causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be combined into a single result element in the ObjectListing.getCommonPrefixes() list. These combined keys are not returned elsewhere in the response. The most commonly used delimiter is "/", which simulates a hierarchical organization similar to a file system directory structure.

Returns:
The optional delimiter parameter that causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be combined into a single result element in the ObjectListing.getCommonPrefixes() list.
See also:
setDelimiter(java.lang.String)
withDelimiter(java.lang.String)
    public String getDelimiter() {
        return ;
    }

    
Sets the optional delimiter parameter that causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be combined into a single result element in the ObjectListing.getCommonPrefixes() list.

Parameters:
delimiter The optional delimiter parameter that causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be combined into a single result element in the ObjectListing.getCommonPrefixes() list.
See also:
getDelimiter()
withDelimiter(java.lang.String)
    public void setDelimiter(String delimiter) {
        this. = delimiter;
    }

    
Sets the optional delimiter parameter that causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the ObjectListing.getCommonPrefixes() list. Returns this ListObjectsRequest, enabling additional method calls to be chained together.

Parameters:
delimiter The optional delimiter parameter that causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the ObjectListing.getCommonPrefixes() list.
Returns:
This ListObjectsRequest, enabling additional method calls to be chained together.
See also:
getDelimiter()
setDelimiter(java.lang.String)
    public ListObjectsRequest withDelimiter(String delimiter) {
        setDelimiter(delimiter);
        return this;
    }

    
Gets the optional maxKeys parameter indicating the maximum number of keys to include in the response. Amazon S3 might return fewer keys than specified, but will never return more. Even if the optional parameter is not specified, Amazon S3 will limit the number of results in the response.

Returns:
The optional parameter indicating the maximum number of keys to include in the response.
See also:
setMaxKeys(java.lang.Integer)
withMaxKeys(java.lang.Integer)
    public Integer getMaxKeys() {
        return ;
    }

    
Sets the optional maxKeys parameter indicating the maximum number of keys to include in the response.

Parameters:
maxKeys The optional parameter indicating the maximum number of keys to include in the response.
See also:
getMaxKeys()
withMaxKeys(java.lang.Integer)
    public void setMaxKeys(Integer maxKeys) {
        this. = maxKeys;
    }

    
Sets the optional maxKeys parameter indicating the maximum number of keys to include in the response. Returns this ListObjectsRequest, enabling additional method calls to be chained together.

Parameters:
maxKeys The optional parameter indicating the maximum number of keys to include in the response.
Returns:
This ListObjectsRequest, enabling additional method calls to be chained together.
See also:
getMaxKeys()
setMaxKeys(java.lang.Integer)
    public ListObjectsRequest withMaxKeys(Integer maxKeys) {
        setMaxKeys(maxKeys);
        return this;
    }
New to GrepCode? Check out our FAQ X