Package com.jcabi.s3

Class 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"
     
    • Constructor Detail

      • Prefixed

        public Prefixed​(Bucket bucket,
                        String pfx)
        Public ctor.
        Parameters:
        bucket - Original bucket
        pfx - Prefix
    • Method Detail

      • region

        public Region region()
        Description copied from interface: Bucket
        Get region we're in.
        Specified by:
        region in interface Bucket
        Returns:
        Region
      • name

        public String name()
        Description copied from interface: Bucket
        Get bucket name.
        Specified by:
        name in interface Bucket
        Returns:
        Bucket name
      • ocket

        public Ocket ocket​(String key)
        Description copied from interface: Bucket
        Get object.
        Specified by:
        ocket in interface Bucket
        Parameters:
        key - Name of it in the bucket
        Returns:
        Ocket
      • exists

        public boolean exists()
                       throws IOException
        Description copied from interface: Bucket
        Checks if the bucket exists.
        Specified by:
        exists in interface Bucket
        Returns:
        If the bucket exists true, otherwise false
        Throws:
        IOException - If any failure happens
      • remove

        public void remove​(String key)
                    throws IOException
        Description copied from interface: Bucket
        Delete object from bucket.
        Specified by:
        remove in interface Bucket
        Parameters:
        key - Name of it in the bucket
        Throws:
        IOException - If not found or any other failure