Package com.jcabi.s3
Class Bucket.Prefixed
- java.lang.Object
-
- com.jcabi.s3.Bucket.Prefixed
-
- All Implemented Interfaces:
Bucket,Comparable<Bucket>
- Enclosing interface:
- Bucket
@Loggable(1) public static final class Bucket.Prefixed extends Object implements Bucket
Creates bucket with specified origin bucket and prefix.Basically this class is used to cut off ocket keys of underlying bucket by some string known as prefix. If key is not started with prefix, it will be omitted
Example of usage:
final Region region = new MkRegion( new TemporaryFolder().newFolder() ); final Bucket bucket = region.bucket("test"); new Ocket.Text(bucket.ocket("a/first.txt")).write(""); new Ocket.Text(bucket.ocket("a/b/hello.txt")).write(""); new Ocket.Text(bucket.ocket("a/b/f/2.txt")).write(""); Bucket.Prefixed prefixed = new Bucket.Prefixed( bucket, "a/b/" ); Iterable<String> list = prefixed.list( "" ); // contains "hello.txt" and "f/2.txt"
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.jcabi.s3.Bucket
Bucket.Prefixed
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Bucket bucket)booleanexists()Checks if the bucket exists.Iterable<String>list(String pfx)List object names with a given prefix.Stringname()Get bucket name.Ocketocket(String key)Get object.Regionregion()Get region we're in.voidremove(String key)Delete object from bucket.
-
-
-
Method Detail
-
exists
public boolean exists() throws IOExceptionDescription copied from interface:BucketChecks if the bucket exists.- Specified by:
existsin interfaceBucket- Returns:
- If the bucket exists
true, otherwisefalse - Throws:
IOException- If any failure happens
-
remove
public void remove(String key) throws IOException
Description copied from interface:BucketDelete object from bucket.- Specified by:
removein interfaceBucket- Parameters:
key- Name of it in the bucket- Throws:
IOException- If not found or any other failure
-
list
public Iterable<String> list(String pfx) throws IOException
Description copied from interface:BucketList object names with a given prefix.- Specified by:
listin interfaceBucket- Parameters:
pfx- Prefix to use- Returns:
- Iterable of names
- Throws:
IOException- If fails
-
compareTo
public int compareTo(Bucket bucket)
- Specified by:
compareToin interfaceComparable<Bucket>
-
-