public Iterator < StashTable > listTables ( ) { final String root = getRootPath ( ) ; final String prefix = String . format ( "%s/" , root ) ; return new AbstractIterator < StashTable > ( ) { Iterator < String > _commonPrefixes = Iterators . emptyIterator ( ) ; String _marker = null ; boolean _truncated = true ; @ Override protected StashTable computeNext ( ) { String dir = null ; while ( dir == null ) { if ( _commonPrefixes . hasNext ( ) ) { dir = _commonPrefixes . next ( ) ; if ( dir . isEmpty ( ) ) { // Ignore the empty directory if it comes back dir = null ; } else { // Strip the prefix and trailing "/" dir = dir . substring ( prefix . length ( ) , dir . length ( ) - 1 ) ; } } else if ( _truncated ) { ObjectListing response = _s3 . listObjects ( new ListObjectsRequest ( ) . withBucketName ( _bucket ) . withPrefix ( prefix ) . withDelimiter ( "/" ) . withMarker ( _marker ) . withMaxKeys ( 1000 ) ) ; _commonPrefixes = response . getCommonPrefixes ( ) . iterator ( ) ; _marker = response . getNextMarker ( ) ; _truncated = response . isTruncated ( ) ; } else { return endOfData ( ) ; } } String tablePrefix = prefix + dir + "/" ; String tableName = StashUtil . decodeStashTable ( dir ) ; return new StashTable ( _bucket , tablePrefix , tableName ) ; } } ; }
Gets all tables available in this stash .