com.amazonaws.services.s3.iterable
Class S3Versions

java.lang.Object
  extended by com.amazonaws.services.s3.iterable.S3Versions
All Implemented Interfaces:
Iterable<S3VersionSummary>

public class S3Versions
extends Object
implements Iterable<S3VersionSummary>

Provides an easy way to iterate Amazon S3 object versions in a "foreach" statement. For example:

 for ( S3VersionSummary summary : S3Versions.forPrefix(s3, "my-bucket", "photos/") ) {
     System.out.printf("Version '%s' of key '%s'\n", summary.getVersionId(), summary.getKey());
 }
 

The list of S3VersionSummarys will be fetched lazily, a page at a time, as they are needed. The size of the page can be controlled with the withBatchSize(int) method.


Method Summary
static S3Versions forKey(AmazonS3 s3, String bucketName, String key)
          Constructs an iterable that covers the versions of a single Amazon S3 object.
 Integer getBatchSize()
           
 String getBucketName()
           
 String getKey()
           
 String getPrefix()
           
 AmazonS3 getS3()
           
static S3Versions inBucket(AmazonS3 s3, String bucketName)
          Constructs an iterable that covers all the object versions in an Amazon S3 bucket.
 Iterator<S3VersionSummary> iterator()
           
 S3Versions withBatchSize(int batchSize)
          Sets the batch size, i.e., how many S3VersionSummarys will be fetched at once.
static S3Versions withPrefix(AmazonS3 s3, String bucketName, String prefix)
          Constructs an iterable that covers the versions in an Amazon S3 bucket where the object key begins with the given prefix.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

inBucket

public static S3Versions inBucket(AmazonS3 s3,
                                  String bucketName)
Constructs an iterable that covers all the object versions in an Amazon S3 bucket.

Parameters:
s3 - The Amazon S3 client.
bucketName - The bucket name.
Returns:
An iterator for object version summaries.

withPrefix

public static S3Versions withPrefix(AmazonS3 s3,
                                    String bucketName,
                                    String prefix)
Constructs an iterable that covers the versions in an Amazon S3 bucket where the object key begins with the given prefix.

Parameters:
s3 - The Amazon S3 client.
bucketName - The bucket name.
prefix - The prefix.
Returns:
An iterator for object version summaries.

forKey

public static S3Versions forKey(AmazonS3 s3,
                                String bucketName,
                                String key)
Constructs an iterable that covers the versions of a single Amazon S3 object.

Parameters:
s3 - The Amazon S3 client.
bucketName - The bucket name.
key - The key.
Returns:
An iterator for object version summaries.

withBatchSize

public S3Versions withBatchSize(int batchSize)
Sets the batch size, i.e., how many S3VersionSummarys will be fetched at once.

Parameters:
batchSize - How many object summaries to fetch at once.

getBatchSize

public Integer getBatchSize()

getPrefix

public String getPrefix()

getKey

public String getKey()

getS3

public AmazonS3 getS3()

getBucketName

public String getBucketName()

iterator

public Iterator<S3VersionSummary> iterator()
Specified by:
iterator in interface Iterable<S3VersionSummary>


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.